Commit 5ec560fb by Jamie Madill Committed by Commit Bot

Add restricted trace golden image script test.

The script reads the list of tests from the restricted traces JSON and runs angle_perftests once for each test. Running the tests in a batch seems unstable on some platfroms so running each test separately works around that limitation. It does not yet interact with Skia Gold. The Gold integration will come later once this basic skeleton is running on the bots. Also updates the perf tests to exit more quickly with --one-frame-only. This will speed up the screenshots. Example run with trigger.py: https://chromium-swarm.appspot.com/task?id=4ecb985330a33910 Bug: angleproject:4090 Bug: b/168049670 Test: tested with trigger.py Change-Id: I52820dfba2acfbc5d638673c37297877e8476adb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2417641 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 8f7970cb
......@@ -40,7 +40,7 @@ constexpr double kMicroSecondsPerSecond = 1e6;
constexpr double kNanoSecondsPerSecond = 1e9;
constexpr double kCalibrationRunTimeSeconds = 1.0;
constexpr double kMaximumRunTimeSeconds = 10.0;
constexpr unsigned int kNumTrials = 3;
constexpr uint32_t kNumTrials = 3;
struct TraceCategory
{
......@@ -222,9 +222,14 @@ void ANGLEPerfTest::run()
}
// Do another warmup run. Seems to consistently improve results.
doRunLoop(kMaximumRunTimeSeconds);
if (gStepsToRunOverride != 1)
{
doRunLoop(kMaximumRunTimeSeconds);
}
uint32_t numTrials = gStepsToRunOverride == 1 ? 1 : kNumTrials;
for (unsigned int trial = 0; trial < kNumTrials; ++trial)
for (uint32_t trial = 0; trial < numTrials; ++trial)
{
doRunLoop(kMaximumRunTimeSeconds);
printResults();
......
......@@ -21,6 +21,12 @@ const char *gScreenShotDir = nullptr;
bool gVerboseLogging = false;
} // namespace angle
namespace
{
// The same as --screenshot-dir, but used by Chrome tests.
constexpr char kRenderTestDirArg[] = "--render-test-output-dir=";
} // namespace
using namespace angle;
void ANGLEProcessPerfTestArgs(int *argc, char **argv)
......@@ -66,6 +72,10 @@ void ANGLEProcessPerfTestArgs(int *argc, char **argv)
{
gVerboseLogging = true;
}
else if (strncmp(kRenderTestDirArg, argv[argIndex], strlen(kRenderTestDirArg)) == 0)
{
gScreenShotDir = argv[argIndex] + strlen(kRenderTestDirArg);
}
else
{
argv[argcOutCount++] = argv[argIndex];
......
......@@ -63,3 +63,14 @@ angle_shared_library("angle_restricted_traces") {
configs += [ "//build/config/compiler:no_optimize" ]
}
}
group("angle_restricted_trace_gold_tests") {
testonly = true
data_deps = [ "$angle_root/src/tests:angle_perftests" ]
data = [
"restricted_trace_gold_tests.py",
"restricted_traces.json",
"//testing/scripts/common.py",
"//testing/xvfb.py",
]
}
#! /usr/bin/env python
#
# [VPYTHON:BEGIN]
# wheel: <
# name: "infra/python/wheels/psutil/${vpython_platform}"
# version: "version:5.2.2"
# >
# wheel: <
# name: "infra/python/wheels/six-py2_py3"
# version: "version:1.10.0"
# >
# [VPYTHON:END]
#
# Copyright 2020 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# restricted_trace_gold_tests.py:
# Uses Skia Gold (https://skia.org/dev/testing/skiagold) to run pixel tests with ANGLE traces.
#
# Requires vpython to run standalone. Run with --help for usage instructions.
import argparse
import contextlib
import json
import os
import shutil
import sys
import tempfile
import traceback
# Add //src/testing into sys.path for importing xvfb and test_env, and
# //src/testing/scripts for importing common.
d = os.path.dirname
THIS_DIR = d(os.path.abspath(__file__))
ANGLE_SRC_DIR = d(d(d(THIS_DIR)))
sys.path.insert(0, os.path.join(ANGLE_SRC_DIR, 'testing'))
sys.path.insert(0, os.path.join(ANGLE_SRC_DIR, 'testing', 'scripts'))
# Handle the Chromium-relative directory as well. As long as one directory
# is valid, Python is happy.
CHROMIUM_SRC_DIR = d(d(ANGLE_SRC_DIR))
sys.path.insert(0, os.path.join(CHROMIUM_SRC_DIR, 'testing'))
sys.path.insert(0, os.path.join(CHROMIUM_SRC_DIR, 'testing', 'scripts'))
import common
import test_env
import xvfb
def IsWindows():
return sys.platform == 'cygwin' or sys.platform.startswith('win')
DEFAULT_TEST_SUITE = 'angle_perftests'
DEFAULT_TEST_PREFIX = '--gtest_filter=TracePerfTest.Run/vulkan_'
@contextlib.contextmanager
def temporary_dir(prefix=''):
path = tempfile.mkdtemp(prefix=prefix)
try:
yield path
finally:
shutil.rmtree(path)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--isolated-script-test-output', type=str, required=True)
parser.add_argument('--test-suite', help='Test suite to run.', default=DEFAULT_TEST_SUITE)
parser.add_argument('--render-test-output-dir', help='Directory to store screenshots')
parser.add_argument('--xvfb', help='Start xvfb.', action='store_true')
args, extra_flags = parser.parse_known_args()
env = os.environ.copy()
if 'GTEST_TOTAL_SHARDS' in env and int(env['GTEST_TOTAL_SHARDS']) != 1:
print('Sharding not yet implemented.')
sys.exit(1)
def run_tests(args, tests, extra_flags, env, screenshot_dir):
for test in tests['traces']:
with common.temporary_file() as tempfile_path:
cmd = [
args.test_suite,
DEFAULT_TEST_PREFIX + test,
'--render-test-output-dir=%s' % screenshot_dir,
'--one-frame-only',
] + extra_flags
if args.xvfb:
rc = xvfb.run_executable(cmd, env, stdoutfile=tempfile_path)
else:
rc = test_env.run_command_with_output(cmd, env=env, stdoutfile=tempfile_path)
if rc != 0:
return rc
return 0
rc = 0
try:
if IsWindows():
args.test_suite = '.\\%s.exe' % args.test_suite
else:
args.test_suite = './%s' % args.test_suite
# read test set
json_name = os.path.join(ANGLE_SRC_DIR, 'src', 'tests', 'restricted_traces',
'restricted_traces.json')
with open(json_name) as fp:
tests = json.load(fp)
if args.render_test_output_dir:
rc = run_tests(args, tests, extra_flags, env, args.render_test_output_dir)
else:
with temporary_dir('angle_trace_') as temp_dir:
rc = run_tests(args, tests, extra_flags, env, temp_dir)
except Exception:
traceback.print_exc()
rc = 1
return rc
# This is not really a "script test" so does not need to manually add
# any additional compile targets.
def main_compile_targets(args):
json.dump([], args.output)
if __name__ == '__main__':
# Conform minimally to the protocol defined by ScriptTest.
if 'compile_targets' in sys.argv:
funcs = {
'run': None,
'compile_targets': main_compile_targets,
}
sys.exit(common.run_script(sys.argv[1:], funcs))
sys.exit(main())
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