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
cdef set SAMPLES = set()
def MakeApplication(application_pb):
def MakeApplication(application_pb, validate):
"""Generates an Application object from a protobuf.
Args:
......@@ -52,7 +52,7 @@ def MakeApplication(application_pb):
sample)
cdef list components = []
for pb_component in application_pb.components:
components.append(MakeComponent(pb_component, application))
components.append(MakeComponent(pb_component, application, validate))
application.components = components
cdef tuple component_maps
......
......@@ -18,7 +18,8 @@
from linking.applications cimport Application
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 readonly unicode name
......
......@@ -16,8 +16,6 @@
# limitations under the License.
"""A class and factory for Android application components."""
import gflags
from linking.applications cimport Application
from linking.target_data cimport AddComponent
from linking.intent_filters cimport IntentFilter
......@@ -25,19 +23,18 @@ from linking.intent_filters cimport MakeIntentFilter
from linking.intents cimport MakeComponentIntent
FLAGS = gflags.FLAGS
cdef int _id = 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.
Args:
component_pb: A Component protobuf object.
application: An Application object.
validate: True if validation is being performed.
Returns: A linking.Component object.
"""
......@@ -68,7 +65,7 @@ cdef Component MakeComponent(object component_pb, Application application):
for intent_filter_pb in component_pb.intent_filters:
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)
else:
global _skipped_imprecise_filters
......
......@@ -32,12 +32,13 @@ intent_count = 0
intent_filter_count = 0
def FetchData(protobufs, protodirs):
def FetchData(protobufs, protodirs, validate):
"""Fetches data from disk.
Args:
protobufs: A list of paths to 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
of Intents and the set of Intent Filters.
......@@ -50,13 +51,14 @@ def FetchData(protobufs, protodirs):
if 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:
for directory in protodirs:
for file_path in os.listdir(directory):
ProcessFile(os.path.join(directory, file_path), apps, components,
intents, intent_filters)
intents, intent_filters, validate)
print 'Applications: %s' % len(apps)
print 'Exit points: %s' % exit_point_count
......@@ -65,7 +67,7 @@ def FetchData(protobufs, protodirs):
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.
Args:
......@@ -74,6 +76,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters):
components: The set of components.
intents: The list of Intents.
intent_filters: The set of Intent Filters.
validate: True if validation is being performed.
"""
LOGGER.debug('Loading %s.', file_path)
......@@ -91,7 +94,7 @@ def ProcessFile(file_path, apps, components, intents, intent_filters):
else:
application.ParseFromString(file_contents_string)
application_wrapper = applications.MakeApplication(application)
application_wrapper = applications.MakeApplication(application, validate)
global exit_point_count
exit_point_count += application_wrapper.exit_point_count
global intent_count
......
......@@ -100,7 +100,7 @@ def FindLinks(protobufs, protodirs=None, skip_empty=False, stats=None,
cdef dict intent_links = {}
applications, components, intents, intent_filters = fetch_data.FetchData(
protobufs, protodirs)
protobufs, protodirs, validate)
PrepareForQueries(applications)
if stats is not None:
......
......@@ -53,7 +53,7 @@ def RunExperiments(protobufs, data_points, file_path):
if size < protobuf_count:
for _ in range(count):
RunExperimentForSize(protobufs, size, file_path)
LOGGER.info('Processed %s apps.')
LOGGER.info('Processed %s apps.', size)
RunExperimentForSize(protobufs, protobuf_count, file_path)
......@@ -81,8 +81,6 @@ def RunExperimentForSize(protobufs, size, stats):
process.start()
process.join()
LOGGER.info('test %s', os.getpid())
def LoadDataPoints(data_points_path):
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