Hash :
e495e7fd
Author :
Date :
2022-10-14T13:52:47
Redo perf and trace test parameters. - Moves common argument parsing code into test_util. - Changes the perf test arg parsing to use the common functions. - Adds new --use-angle and --use-gl parameters to the trace tests. - Also adds new --offscreen and --vsync parameters to the traces. - Removes the now unneeded --enable-all-trace-tests argument. - Both --arg=value and --arg value work in test suites now. Now, instead of using --enable-all-trace-tests you can specify the backend with --use-angle=swiftshader, --offscreen, or combinations of those parameters. The test names are the same as they were before, but only the configured tests will run in a session. We could opt to simplify the test names in later CLs if we want to simplify the test running. Ideally we'd keep the perf reporting the same because then we'd keep the time series the same on the test infra. This also allows us to split up the trace tests into separate targets on the bots, which will better allow us to control the workloads and sampling of the tests. For example: - angle_perftests becomes - angle_perftests (microbenchmarks) - angle_trace_perf_vulkan_tests (traces with vulkan back-end) - angle_trace_perf_native_tests (traces with system GL) Bug: angleproject:7755 Change-Id: I537168f3a6de96425dfda05ed98220eff9b19b76 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3956937 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
//
// Copyright 2014 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.
//
// test_utils.h: declaration of OS-specific utility functions
#ifndef UTIL_TEST_UTILS_H_
#define UTIL_TEST_UTILS_H_
#include <functional>
#include <string>
#include <vector>
#include "common/angleutils.h"
#include "util/Timer.h"
namespace angle
{
// Cross platform equivalent of the Windows Sleep function
void Sleep(unsigned int milliseconds);
void SetLowPriorityProcess();
// Write a debug message, either to a standard output or Debug window.
void WriteDebugMessage(const char *format, ...);
// Set thread affinity and priority.
bool StabilizeCPUForBenchmarking();
// Set a crash handler to print stack traces.
using CrashCallback = std::function<void()>;
void InitCrashHandler(CrashCallback *callback);
void TerminateCrashHandler();
// Print a stack back trace.
void PrintStackBacktrace();
// Deletes a file or directory.
bool DeleteSystemFile(const char *path);
// Reads a file contents into a string. Note: this method cannot be exported across a shared module
// boundary because it does memory allocation.
bool ReadEntireFileToString(const char *filePath, std::string *contentsOut);
// Compute a file's size.
bool GetFileSize(const char *filePath, uint32_t *sizeOut);
class ProcessHandle;
class Process : angle::NonCopyable
{
public:
virtual bool started() = 0;
virtual bool finished() = 0;
virtual bool finish() = 0;
virtual bool kill() = 0;
virtual int getExitCode() = 0;
double getElapsedTimeSeconds() const { return mTimer.getElapsedWallClockTime(); }
const std::string &getStdout() const { return mStdout; }
const std::string &getStderr() const { return mStderr; }
protected:
friend class ProcessHandle;
virtual ~Process();
Timer mTimer;
std::string mStdout;
std::string mStderr;
};
enum class ProcessOutputCapture
{
Nothing,
// Capture stdout only
StdoutOnly,
// Capture stdout, and pipe stderr to stdout
StdoutAndStderrInterleaved,
// Capture stdout and stderr separately
StdoutAndStderrSeparately,
};
class ProcessHandle final : angle::NonCopyable
{
public:
ProcessHandle();
ProcessHandle(Process *process);
ProcessHandle(const std::vector<const char *> &args, ProcessOutputCapture captureOutput);
~ProcessHandle();
ProcessHandle(ProcessHandle &&other);
ProcessHandle &operator=(ProcessHandle &&rhs);
Process *operator->() { return mProcess; }
const Process *operator->() const { return mProcess; }
operator bool() const { return mProcess != nullptr; }
void reset();
private:
Process *mProcess;
};
// Launch a process and optionally get the output. Uses a vector of c strings as command line
// arguments to the child process. Returns a Process handle which can be used to retrieve
// the stdout and stderr outputs as well as the exit code.
//
// Pass false for stdoutOut/stderrOut if you don't need to capture them.
//
// On success, returns a Process pointer with started() == true.
// On failure, returns a Process pointer with started() == false.
Process *LaunchProcess(const std::vector<const char *> &args, ProcessOutputCapture captureOutput);
int NumberOfProcessors();
const char *GetNativeEGLLibraryNameWithExtension();
// Intercept Metal shader cache access to avoid slow caching mechanism that caused the test timeout
// in the past. Note:
// - If there is NO "--skip-file-hooking" switch in the argument list:
// - This function will re-launch the app with additional argument "--skip-file-hooking".
// - The running process's image & memory will be re-created.
// - If there is "--skip-file-hooking" switch in the argument list, this function will do nothing.
#if defined(ANGLE_PLATFORM_APPLE)
void InitMetalFileAPIHooking(int argc, char **argv);
#endif
enum ArgHandling
{
Delete,
Preserve,
};
bool ParseIntArgWithHandling(const char *flag,
int *argc,
char **argv,
int argIndex,
int *valueOut,
ArgHandling handling);
bool ParseIntArg(const char *flag, int *argc, char **argv, int argIndex, int *valueOut);
bool ParseFlag(const char *flag, int *argc, char **argv, int argIndex, bool *flagOut);
bool ParseStringArg(const char *flag, int *argc, char **argv, int argIndex, std::string *valueOut);
bool ParseCStringArg(const char *flag, int *argc, char **argv, int argIndex, const char **valueOut);
void AddArg(int *argc, char **argv, const char *arg);
uint32_t GetPlatformANGLETypeFromArg(const char *useANGLEArg, uint32_t defaultPlatformType);
uint32_t GetANGLEDeviceTypeFromArg(const char *useANGLEArg, uint32_t defaultDeviceType);
} // namespace angle
#endif // UTIL_TEST_UTILS_H_