Skip to content

Commit

Permalink
Fixed Perfetto trace processor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanicijamd committed Sep 6, 2024
1 parent d0e2793 commit f300b80
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/Templates/args.gn.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/omnitrace-python-tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions tests/omnitrace-testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
13 changes: 9 additions & 4 deletions tests/validate-perfetto-proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

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"""

n = 0
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")
Expand Down Expand Up @@ -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,
Expand All @@ -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")
Expand Down

0 comments on commit f300b80

Please sign in to comment.