chromium/tools/perf/testdata/dummy_gtest

#!/usr/bin/env vpython3
# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This is a fake version of a non-Telemetry performance test (gtest_perf_test).

It is used by ../scripts_smoke_unittest.py.
"""

import argparse
import os
import sys
import shutil

# This is just a random line of output that can be converted into graph_json.
print(r"*RESULT clockless_video_playback_vp8: bear_silent.webm= 53.406108056578425 runs/s")

# Simulate trace file generation when "--trace-dir" switch is present.
parser = argparse.ArgumentParser()
parser.add_argument(
    "--argument-to-check-that-arguments-work", action='store_true')
parser.add_argument(
    "--trace-dir",
    type=str,
    help="Simulate trace file generation to the given path.")
options, _ = parser.parse_known_args(sys.argv[1:])
if options.trace_dir:
  trace_file = os.path.join(os.path.dirname(__file__), 'dummy_trace.json')
  shutil.copy(trace_file, options.trace_dir)

  test_result_file = os.path.join(
      os.path.dirname(__file__), 'dummy_luci_test_result_template.json')
  with open(test_result_file, 'r') as f:
    test_result = f.read()
  test_result = test_result.replace(
      'FULL_TRACE_FILE_PATH', os.path.join(options.trace_dir,
                                           'dummy_trace.json'))
  test_result = ''.join([line.strip() for line in test_result.splitlines()])
  with open(
      os.path.join(options.trace_dir, 'dummy_luci_test_result.json'), 'w') as f:
    f.write(test_result)
if options.argument_to_check_that_arguments_work:
  print('Arguments worked!')
else:
  print('--argument-to-check-that-arguments-work was not passed. Failing.')
  sys.exit(1)