Commit 373e1c9f authored by Damien Octeau's avatar Damien Octeau

Fixed a bug with the validation flag that is not available when the procedure...

Fixed a bug with the validation flag that is not available when the procedure are called for performance experiments. Fixed some display bugs.
parent 30d43d21
...@@ -26,7 +26,7 @@ from linking import ic3_data_pb2 ...@@ -26,7 +26,7 @@ from linking import ic3_data_pb2
cdef set SAMPLES = set() cdef set SAMPLES = set()
def MakeApplication(application_pb): def MakeApplication(application_pb, validate):
"""Generates an Application object from a protobuf. """Generates an Application object from a protobuf.
Args: Args:
...@@ -52,7 +52,7 @@ def MakeApplication(application_pb): ...@@ -52,7 +52,7 @@ def MakeApplication(application_pb):
sample) sample)
cdef list components = [] cdef list components = []
for pb_component in application_pb.components: for pb_component in application_pb.components:
components.append(MakeComponent(pb_component, application)) components.append(MakeComponent(pb_component, application, validate))
application.components = components application.components = components
cdef tuple component_maps cdef tuple component_maps
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
from linking.applications cimport Application from linking.applications cimport Application
cdef int GetSkippedFilterCount() cdef int GetSkippedFilterCount()
cdef Component MakeComponent(object component_pb, Application application) cdef Component MakeComponent(object component_pb, Application application,
bint validate)
cdef class Component(object): cdef class Component(object):
cdef readonly unicode name cdef readonly unicode name
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
# limitations under the License. # limitations under the License.
"""A class and factory for Android application components.""" """A class and factory for Android application components."""
import gflags
from linking.applications cimport Application from linking.applications cimport Application
from linking.target_data cimport AddComponent from linking.target_data cimport AddComponent
from linking.intent_filters cimport IntentFilter from linking.intent_filters cimport IntentFilter
...@@ -25,19 +23,18 @@ from linking.intent_filters cimport MakeIntentFilter ...@@ -25,19 +23,18 @@ from linking.intent_filters cimport MakeIntentFilter
from linking.intents cimport MakeComponentIntent from linking.intents cimport MakeComponentIntent
FLAGS = gflags.FLAGS
cdef int _id = 0 cdef int _id = 0
cdef int _skipped_imprecise_filters = 0 cdef int _skipped_imprecise_filters = 0
cdef Component MakeComponent(object component_pb, Application application): cdef Component MakeComponent(object component_pb, Application application,
bint validate):
"""Generates a Component object from a protobuf. """Generates a Component object from a protobuf.
Args: Args:
component_pb: A Component protobuf object. component_pb: A Component protobuf object.
application: An Application object. application: An Application object.
validate: True if validation is being performed.
Returns: A linking.Component object. Returns: A linking.Component object.
""" """
...@@ -68,7 +65,7 @@ cdef Component MakeComponent(object component_pb, Application application): ...@@ -68,7 +65,7 @@ cdef Component MakeComponent(object component_pb, Application application):
for intent_filter_pb in component_pb.intent_filters: for intent_filter_pb in component_pb.intent_filters:
intent_filter = MakeIntentFilter(intent_filter_pb, result) intent_filter = MakeIntentFilter(intent_filter_pb, result)
if intent_filter.IsPrecise() or not FLAGS.validate: if intent_filter.IsPrecise() or not validate:
filters.append(intent_filter) filters.append(intent_filter)
else: else:
global _skipped_imprecise_filters global _skipped_imprecise_filters
......
...@@ -32,12 +32,13 @@ intent_count = 0 ...@@ -32,12 +32,13 @@ intent_count = 0
intent_filter_count = 0 intent_filter_count = 0
def FetchData(protobufs, protodirs): def FetchData(protobufs, protodirs, validate):
"""Fetches data from disk. """Fetches data from disk.
Args: Args:
protobufs: A list of paths to protobufs. protobufs: A list of paths to protobufs.
protodirs: A list of paths to directories containing protobufs. protodirs: A list of paths to directories containing protobufs.
validate: True if validation is being performed.
Returns: A tuple with the set of applications, the set of components, the list Returns: A tuple with the set of applications, the set of components, the list
of Intents and the set of Intent Filters. of Intents and the set of Intent Filters.
...@@ -50,13 +51,14 @@ def FetchData(protobufs, protodirs): ...@@ -50,13 +51,14 @@ def FetchData(protobufs, protodirs):
if protobufs: if protobufs:
for file_path in protobufs: for file_path in protobufs:
ProcessFile(file_path, apps, components, intents, intent_filters) ProcessFile(file_path, apps, components, intents, intent_filters,
validate)
if protodirs: if protodirs:
for directory in protodirs: for directory in protodirs:
for file_path in os.listdir(directory): for file_path in os.listdir(directory):
ProcessFile(os.path.join(directory, file_path), apps, components, ProcessFile(os.path.join(directory, file_path), apps, components,
intents, intent_filters) intents, intent_filters, validate)
print 'Applications: %s' % len(apps) print 'Applications: %s' % len(apps)
print 'Exit points: %s' % exit_point_count print 'Exit points: %s' % exit_point_count
...@@ -65,7 +67,7 @@ def FetchData(protobufs, protodirs): ...@@ -65,7 +67,7 @@ def FetchData(protobufs, protodirs):
return apps, components, intents, intent_filters return apps, components, intents, intent_filters
def ProcessFile(file_path, apps, components, intents, intent_filters): def ProcessFile(file_path, apps, components, intents, intent_filters, validate):
"""Loads a single protobuf. """Loads a single protobuf.
Args: Args:
...@@ -74,6 +76,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters): ...@@ -74,6 +76,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters):
components: The set of components. components: The set of components.
intents: The list of Intents. intents: The list of Intents.
intent_filters: The set of Intent Filters. intent_filters: The set of Intent Filters.
validate: True if validation is being performed.
""" """
LOGGER.debug('Loading %s.', file_path) LOGGER.debug('Loading %s.', file_path)
...@@ -91,7 +94,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters): ...@@ -91,7 +94,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters):
else: else:
application.ParseFromString(file_contents_string) application.ParseFromString(file_contents_string)
application_wrapper = applications.MakeApplication(application) application_wrapper = applications.MakeApplication(application, validate)
global exit_point_count global exit_point_count
exit_point_count += application_wrapper.exit_point_count exit_point_count += application_wrapper.exit_point_count
global intent_count global intent_count
......
...@@ -100,7 +100,7 @@ def FindLinks(protobufs, protodirs=None, skip_empty=False, stats=None, ...@@ -100,7 +100,7 @@ def FindLinks(protobufs, protodirs=None, skip_empty=False, stats=None,
cdef dict intent_links = {} cdef dict intent_links = {}
applications, components, intents, intent_filters = fetch_data.FetchData( applications, components, intents, intent_filters = fetch_data.FetchData(
protobufs, protodirs) protobufs, protodirs, validate)
PrepareForQueries(applications) PrepareForQueries(applications)
if stats is not None: if stats is not None:
......
...@@ -53,7 +53,7 @@ def RunExperiments(protobufs, data_points, file_path): ...@@ -53,7 +53,7 @@ def RunExperiments(protobufs, data_points, file_path):
if size < protobuf_count: if size < protobuf_count:
for _ in range(count): for _ in range(count):
RunExperimentForSize(protobufs, size, file_path) RunExperimentForSize(protobufs, size, file_path)
LOGGER.info('Processed %s apps.') LOGGER.info('Processed %s apps.', size)
RunExperimentForSize(protobufs, protobuf_count, file_path) RunExperimentForSize(protobufs, protobuf_count, file_path)
...@@ -81,8 +81,6 @@ def RunExperimentForSize(protobufs, size, stats): ...@@ -81,8 +81,6 @@ def RunExperimentForSize(protobufs, size, stats):
process.start() process.start()
process.join() process.join()
LOGGER.info('test %s', os.getpid())
def LoadDataPoints(data_points_path): def LoadDataPoints(data_points_path):
data_points = [] data_points = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment