tp: modularise diff testing infrastructure
This CL is the inital implementation of a more modular approach to diff
testing trace processor instead of dumping everything into a single
folder. Instead, we break out tests into one of several categories
(including a legacy folder which retains non-modularised tests).
This makes these tests a lot more maintainable overall and much easier
both to modify existing tests and add new ones.
A follow up CL will introduce a much more user friendly test-adding
script to complement the modular approach and updates to docs with the
new way to add these tests.
Change-Id: I4f7f7a33d153e888ef504d3819ffdac47ac4918f
diff --git a/tools/diff_test_trace_processor.py b/tools/diff_test_trace_processor.py
index 6012375..e7fc030 100755
--- a/tools/diff_test_trace_processor.py
+++ b/tools/diff_test_trace_processor.py
@@ -247,17 +247,12 @@
return test_failure, perf_data
-def read_all_tests(test_type, query_metric_pattern, trace_pattern):
- if test_type == 'queries':
- index = os.path.join(ROOT_DIR, 'test', 'trace_processor', 'index')
- elif test_type == 'metrics':
- index = os.path.join(ROOT_DIR, 'test', 'metrics', 'index')
- else:
- assert False
+def read_all_tests_from_index(test_type, index_path, query_metric_pattern,
+ trace_pattern):
+ index_dir = os.path.dirname(index_path)
- index_dir = os.path.dirname(index)
- with open(index, 'r') as file:
- index_lines = file.readlines()
+ with open(index_path, 'r') as index_file:
+ index_lines = index_file.readlines()
tests = []
for line in index_lines:
@@ -284,7 +279,26 @@
tests.append(
Test(test_type, trace_path, query_path_or_metric, expected_path))
+ return tests
+
+def read_all_tests(test_type, query_metric_pattern, trace_pattern):
+ if test_type == 'queries':
+ include_index = os.path.join(ROOT_DIR, 'test', 'trace_processor',
+ 'include_index')
+ elif test_type == 'metrics':
+ include_index = os.path.join(ROOT_DIR, 'test', 'metrics', 'include_index')
+ else:
+ assert False
+
+ include_index_dir = os.path.dirname(include_index)
+ tests = []
+ with open(include_index, 'r') as include_file:
+ for index_relpath in include_file.readlines():
+ index_path = os.path.join(include_index_dir, index_relpath.strip())
+ tests.extend(
+ read_all_tests_from_index(test_type, index_path, query_metric_pattern,
+ trace_pattern))
return tests