From f300b8065863733794ceb7c2a19526260d93cccc Mon Sep 17 00:00:00 2001 From: Aleksandar Janicijevic Date: Fri, 6 Sep 2024 11:09:37 -0400 Subject: [PATCH] Fixed Perfetto trace processor tests --- cmake/Templates/args.gn.in | 2 +- tests/omnitrace-python-tests.cmake | 3 ++- tests/omnitrace-testing.cmake | 1 + tests/validate-perfetto-proto.py | 13 +++++++++---- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/Templates/args.gn.in b/cmake/Templates/args.gn.in index 119ab4b93..860a10a84 100644 --- a/cmake/Templates/args.gn.in +++ b/cmake/Templates/args.gn.in @@ -16,7 +16,7 @@ enable_perfetto_fuzzers = false enable_perfetto_heapprofd = false enable_perfetto_tools = false enable_perfetto_trace_processor = true -enable_perfetto_trace_processor_httpd = false +enable_perfetto_trace_processor_httpd = true enable_perfetto_trace_processor_json = false enable_perfetto_trace_processor_linenoise = false enable_perfetto_trace_processor_percentile = false diff --git a/tests/omnitrace-python-tests.cmake b/tests/omnitrace-python-tests.cmake index 32d4c2c51..62416bb88 100644 --- a/tests/omnitrace-python-tests.cmake +++ b/tests/omnitrace-python-tests.cmake @@ -166,7 +166,8 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS}) NAME ${TEST_NAME}-validate-perfetto COMMAND ${_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/validate-perfetto-proto.py - -m ${TEST_PERFETTO_METRIC} ${TEST_ARGS} -p -i + -m ${TEST_PERFETTO_METRIC} ${TEST_ARGS} -p + -t ${PROJECT_BINARY_DIR}/external/perfetto/source/out/linux/trace_processor_shell -i PYTHON_VERSION ${_VERSION} FILE omnitrace-tests-output/${TEST_NAME}/${_VERSION}/${TEST_PERFETTO_FILE} DEPENDS ${TEST_NAME}-${_VERSION} diff --git a/tests/omnitrace-testing.cmake b/tests/omnitrace-testing.cmake index 9e4c88619..bb1cc77ec 100644 --- a/tests/omnitrace-testing.cmake +++ b/tests/omnitrace-testing.cmake @@ -985,6 +985,7 @@ function(OMNITRACE_ADD_VALIDATION_TEST) ${CMAKE_CURRENT_LIST_DIR}/validate-perfetto-proto.py -m "${TEST_PERFETTO_METRIC}" ${TEST_ARGS} -i ${PROJECT_BINARY_DIR}/omnitrace-tests-output/${TEST_NAME}/${TEST_PERFETTO_FILE} + -t ${PROJECT_BINARY_DIR}/external/perfetto/source/out/linux/trace_processor_shell WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) endif() diff --git a/tests/validate-perfetto-proto.py b/tests/validate-perfetto-proto.py index 29facafa0..3092feec3 100755 --- a/tests/validate-perfetto-proto.py +++ b/tests/validate-perfetto-proto.py @@ -2,10 +2,10 @@ import sys import argparse -from perfetto.trace_processor import TraceProcessor +from perfetto.trace_processor import TraceProcessor, TraceProcessorConfig -def load_trace(inp, max_tries=5, retry_wait=1): +def load_trace(inp, max_tries=5, retry_wait=1, bin_path=None): """Occasionally connecting to the trace processor fails with HTTP errors so this function tries to reduce spurious test failures""" @@ -13,7 +13,11 @@ def load_trace(inp, max_tries=5, retry_wait=1): tp = None while tp is None: try: - tp = TraceProcessor(trace=(inp)) + if bin_path: + config = TraceProcessorConfig(bin_path=bin_path) + tp = TraceProcessor(trace=(inp), config=config) + else: + tp = TraceProcessor(trace=(inp)) break except Exception as e: sys.stderr.write(f"{e}\n") @@ -71,6 +75,7 @@ def validate_perfetto(data, labels, counts, depths): "-p", "--print", action="store_true", help="Print the processed perfetto data" ) parser.add_argument("-i", "--input", type=str, help="Input file", required=True) + parser.add_argument("-t", "--trace_processor_shell", type=str, help="Path of trace_processor_shell") parser.add_argument( "--key-names", type=str, @@ -93,7 +98,7 @@ def validate_perfetto(data, labels, counts, depths): "The same number of labels, counts, and depths must be specified" ) - tp = load_trace(args.input) + tp = load_trace(args.input, bin_path=args.trace_processor_shell) if tp is None: raise ValueError(f"trace {args.input} could not be loaded")