Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
skqp_main.cpp File Reference
#include <iostream>
#include <sys/stat.h>
#include "tools/skqp/src/skqp.h"
#include "include/core/SkData.h"
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"
#include "tools/Resources.h"

Go to the source code of this file.

Functions

static bool should_skip (const char *const *rules, size_t count, const char *name)
 
static void parse_args (int argc, char *argv[], Args *args)
 
int main (int argc, char *argv[])
 

Variables

static constexpr char kSkipUsage []
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 107 of file skqp_main.cpp.

107 {
108 Args args;
109 parse_args(argc, argv, &args);
110
111 SetResourcePath(std::string(args.assetDir + std::string("/resources")).c_str());
112 if (!sk_mkdir(args.outputDir)) {
113 std::cerr << "sk_mkdir(" << args.outputDir << ") failed.\n";
114 return 2;
115 }
116
117 StdAssetManager mgr(args.assetDir);
118 SkQP skqp;
119 skqp.init(&mgr, args.outputDir);
120 int ret = 0;
121
122 const char* const* matchRules = &argv[3];
123 size_t matchRulesCount = (size_t)(argc - 3);
124
125 // Unit Tests
126 for (SkQP::UnitTest test : skqp.getUnitTests()) {
127 auto testName = std::string("unitTest_") + SkQP::GetUnitTestName(test);
128 if (should_skip(matchRules, matchRulesCount, testName.c_str())) {
129 continue;
130 }
131 std::cout << "Starting: " << testName << " ";
132 std::vector<std::string> errors = skqp.executeTest(test);
133 if (!errors.empty()) {
134 std::cout << "[FAILED: " << errors.size() << " error(s)]" << std::endl;
135 for (const std::string& error : errors) {
136 std::cout << " " << error << std::endl;
137 }
138 ret = 1;
139 } else {
140 std::cout << "[PASSED]" << std::endl;
141 }
142 std::cout.flush();
143 }
144 skqp.makeReport();
145
146 return ret;
147}
void SetResourcePath(const char *resource)
Definition Resources.cpp:27
bool sk_mkdir(const char *path)
Definition skqp.h:42
void makeReport()
Definition skqp.cpp:192
std::vector< std::string > executeTest(UnitTest)
Definition skqp.cpp:147
void init(SkQPAssetManager *assetManager, const char *reportDirectory)
Definition skqp.cpp:120
static const char * GetUnitTestName(UnitTest)
Definition skqp.cpp:114
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
char ** argv
Definition library.h:9
static bool should_skip(const char *const *rules, size_t count, const char *name)
Definition skqp_main.cpp:67
static void parse_args(int argc, char *argv[], Args *args)
Definition skqp_main.cpp:97

◆ parse_args()

static void parse_args ( int  argc,
char *  argv[],
Args *  args 
)
static

Definition at line 97 of file skqp_main.cpp.

97 {
98 if (argc < 3) {
99 std::cerr << "Usage:\n " << argv[0] << " ASSET_DIR OUTPUT_DIR [TEST_MATCH_RULES]\n"
100 << kSkipUsage << '\n';
101 exit(1);
102 }
103 args->assetDir = argv[1];
104 args->outputDir = argv[2];
105}
exit(kErrorExitCode)
static constexpr char kSkipUsage[]
Definition skqp_main.cpp:56

◆ should_skip()

static bool should_skip ( const char *const *  rules,
size_t  count,
const char *  name 
)
static

Definition at line 67 of file skqp_main.cpp.

67 {
68 size_t testLen = strlen(name);
69 bool anyExclude = count == 0;
70 for (size_t i = 0; i < count; ++i) {
71 const char* matchName = rules[i];
72 size_t matchLen = strlen(matchName);
73 bool matchExclude, matchStart, matchEnd;
74 if ((matchExclude = matchName[0] == '~')) {
75 anyExclude = true;
76 matchName++;
77 matchLen--;
78 }
79 if ((matchStart = matchName[0] == '^')) {
80 matchName++;
81 matchLen--;
82 }
83 if ((matchEnd = matchName[matchLen - 1] == '$')) {
84 matchLen--;
85 }
86 if (matchStart ? (!matchEnd || matchLen == testLen)
87 && strncmp(name, matchName, matchLen) == 0
88 : matchEnd ? matchLen <= testLen
89 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0
90 : strstr(name, matchName) != nullptr) {
91 return matchExclude;
92 }
93 }
94 return !anyExclude;
95}
int count
const char * name
Definition fuchsia.cc:50

Variable Documentation

◆ kSkipUsage

constexpr char kSkipUsage[]
staticconstexpr
Initial value:
=
" TEST_MATCH_RULES:"
" [~][^]substring[$] [...] of name to run.\n"
" Multiple matches may be separated by spaces.\n"
" ~ causes a matching name to always be skipped\n"
" ^ requires the start of the name to match\n"
" $ requires the end of the name to match\n"
" ^ and $ requires an exact match\n"
" If a name does not match any list entry,\n"
" it is skipped unless some list entry starts with ~\n"

Definition at line 56 of file skqp_main.cpp.