xref: /aosp_15_r20/external/skia/tools/testrunners/common/TestRunner.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef TestRunner_DEFINED
9 #define TestRunner_DEFINED
10 
11 #include "tools/flags/CommandLineFlags.h"
12 
13 #include <map>
14 
15 namespace TestRunner {
16 namespace FlagValidators {
17 
18 void StringNonEmpty(std::string name, CommandLineFlags::StringArray flag);
19 
20 void StringAtMostOne(std::string name, CommandLineFlags::StringArray flag);
21 
22 void StringEven(std::string name, CommandLineFlags::StringArray flag);
23 
24 void IntGreaterOrEqual(std::string name, int flag, int min);
25 
26 void AllOrNone(std::map<std::string, bool> flags);
27 
28 void ExactlyOne(std::map<std::string, bool> flags);
29 
30 }  // namespace FlagValidators
31 
32 // Performs some common initialization steps, and logs all command-line arguments.
33 //
34 // It should be called by all test runners at the beginning of their main() function.
35 void InitAndLogCmdlineArgs(int argc, char** argv);
36 
37 // Determines whether a test case should be run based on the --match and --skip command-line flags.
38 bool ShouldRunTestCase(const char* name,
39                        CommandLineFlags::StringArray& matchFlag,
40                        CommandLineFlags::StringArray& skipFlag);
41 
42 // Logs a message to stdout.
43 //
44 // It prefixes the message with a timestamp, and suffixes it with a line break ("\n").
45 void Log(const char* format, ...) SK_PRINTF_LIKE(1, 2);
46 
47 }  // namespace TestRunner
48 
49 #endif  // TestRunner_DEFINED
50