Add command line argument to specify the rendertests file.

Change-Id: I53a8c2f168108fa5003c54ffece67fc20c38bb09
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275137
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: John Rosasco <rosasco@google.com>
Commit-Queue: John Rosasco <rosasco@google.com>
This commit is contained in:
Tyler Denniston 2020-03-05 10:38:17 -05:00 committed by Skia Commit-Bot
parent ec370976c6
commit 0cfcd1c9bb
6 changed files with 43 additions and 23 deletions

View File

@ -1,7 +1,7 @@
{ {
"program": { "program": {
"binary": "bin/skqp", "binary": "bin/skqp",
"args" : [ "/pkg/data", "tmp/logs" ] "args" : [ "/pkg/data", "skqp/rendertests_fuchsia.txt", "/tmp/logs" ]
}, },
"sandbox": { "sandbox": {
"dev": [ "dev": [

View File

@ -186,6 +186,9 @@ bool sk_mkdir(const char* path) {
retval = _mkdir(path); retval = _mkdir(path);
#else #else
retval = mkdir(path, 0777); retval = mkdir(path, 0777);
if (retval) {
perror("mkdir() failed with error: ");
}
#endif #endif
return 0 == retval; return 0 == retval;
} }

View File

@ -115,7 +115,7 @@ void Java_org_skia_skqp_SkQP_nInit(JNIEnv* env, jobject object, jobject assetMan
jassert(env, gAAssetManager,); jassert(env, gAAssetManager,);
std::lock_guard<std::mutex> lock(gMutex); std::lock_guard<std::mutex> lock(gMutex);
gSkQP.init(&gAndroidAssetManager, reportDirectory.c_str()); gSkQP.init(&gAndroidAssetManager, nullptr, reportDirectory.c_str());
auto backends = gSkQP.getSupportedBackends(); auto backends = gSkQP.getSupportedBackends();
jassert(env, backends.size() > 0,); jassert(env, backends.size() > 0,);

View File

@ -45,7 +45,7 @@
static constexpr char kRenderTestCSVReport[] = "out.csv"; static constexpr char kRenderTestCSVReport[] = "out.csv";
static constexpr char kRenderTestReportPath[] = "report.html"; static constexpr char kRenderTestReportPath[] = "report.html";
static constexpr char kRenderTestsPath[] = "skqp/rendertests.txt"; static constexpr char kDefaultRenderTestsPath[] = "skqp/rendertests.txt";
static constexpr char kUnitTestReportPath[] = "unit_tests.txt"; static constexpr char kUnitTestReportPath[] = "unit_tests.txt";
static constexpr char kUnitTestsPath[] = "skqp/unittests.txt"; static constexpr char kUnitTestsPath[] = "skqp/unittests.txt";
@ -89,8 +89,11 @@ static void get_unit_tests(SkQPAssetManager* mgr, std::vector<SkQP::UnitTest>* u
} }
static void get_render_tests(SkQPAssetManager* mgr, static void get_render_tests(SkQPAssetManager* mgr,
const char *renderTestsIn,
std::vector<SkQP::GMFactory>* gmlist, std::vector<SkQP::GMFactory>* gmlist,
std::unordered_map<std::string, int64_t>* gmThresholds) { std::unordered_map<std::string, int64_t>* gmThresholds) {
// Runs all render tests if the |renderTests| file can't be found or is empty.
const char *renderTests = renderTestsIn ? renderTestsIn : kDefaultRenderTestsPath;
auto insert = [gmThresholds](const char* s, size_t l) { auto insert = [gmThresholds](const char* s, size_t l) {
SkASSERT(l > 1) ; SkASSERT(l > 1) ;
if (l > 0 && s[l - 1] == '\n') { // strip line endings. if (l > 0 && s[l - 1] == '\n') { // strip line endings.
@ -117,7 +120,7 @@ static void get_render_tests(SkQPAssetManager* mgr,
} }
gmThresholds->insert({std::move(key), value}); // (*gmThresholds)[s] = value; gmThresholds->insert({std::move(key), value}); // (*gmThresholds)[s] = value;
}; };
if (sk_sp<SkData> dat = mgr->open(kRenderTestsPath)) { if (sk_sp<SkData> dat = mgr->open(renderTests)) {
readlines(dat->data(), dat->size(), insert); readlines(dat->data(), dat->size(), insert);
} }
using GmAndName = std::pair<SkQP::GMFactory, std::string>; using GmAndName = std::pair<SkQP::GMFactory, std::string>;
@ -246,7 +249,7 @@ SkQP::SkQP() {}
SkQP::~SkQP() {} SkQP::~SkQP() {}
void SkQP::init(SkQPAssetManager* am, const char* reportDirectory) { void SkQP::init(SkQPAssetManager* am, const char* renderTests, const char* reportDirectory) {
SkASSERT_RELEASE(!fAssetManager); SkASSERT_RELEASE(!fAssetManager);
SkASSERT_RELEASE(am); SkASSERT_RELEASE(am);
fAssetManager = am; fAssetManager = am;
@ -255,9 +258,7 @@ void SkQP::init(SkQPAssetManager* am, const char* reportDirectory) {
SkGraphics::Init(); SkGraphics::Init();
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
/* If the file "skqp/rendertests.txt" does not exist or is empty, run all get_render_tests(fAssetManager, renderTests, &fGMs, &fGMThresholds);
render tests. Otherwise only run tests mentioned in that file. */
get_render_tests(fAssetManager, &fGMs, &fGMThresholds);
/* If the file "skqp/unittests.txt" does not exist or is empty, run all gpu /* If the file "skqp/unittests.txt" does not exist or is empty, run all gpu
unit tests. Otherwise only run tests mentioned in that file. */ unit tests. Otherwise only run tests mentioned in that file. */
get_unit_tests(fAssetManager, &fUnitTests); get_unit_tests(fAssetManager, &fUnitTests);

View File

@ -64,9 +64,10 @@ public:
Initialize Skia and the SkQP. Should be executed only once. Initialize Skia and the SkQP. Should be executed only once.
@param assetManager - provides assets for the models. Does not take ownership. @param assetManager - provides assets for the models. Does not take ownership.
@param renderTests - file containing list of render tests.
@param reportDirectory - where to write out report. @param reportDirectory - where to write out report.
*/ */
void init(SkQPAssetManager* assetManager, const char* reportDirectory); void init(SkQPAssetManager* assetManager, const char* renderTests, const char* reportDirectory);
struct RenderOutcome { struct RenderOutcome {
// All three values will be 0 if the test passes. // All three values will be 0 if the test passes.

View File

@ -30,6 +30,12 @@ public:
private: private:
std::string fPrefix; std::string fPrefix;
}; };
struct Args {
char *assetDir;
char *renderTests;
char *outputDir;
};
} }
static constexpr char kSkipUsage[] = static constexpr char kSkipUsage[] =
@ -73,25 +79,34 @@ static bool should_skip(const char* const* rules, size_t count, const char* name
return !anyExclude; return !anyExclude;
} }
int main(int argc, char** argv) { static void parse_args(int argc, char *argv[], Args *args) {
if (argc < 3) { if (argc < 4) {
std::cerr << "Usage:\n " << argv[0] std::cerr << "Usage:\n " << argv[0]
<< " ASSET_DIRECTORY_PATH SKQP_REPORT_PATH [TEST_MATCH_RULES]\n" << " ASSET_DIR RENDER_TESTS OUTPUT_DIR [TEST_MATCH_RULES]\n"
<< kSkipUsage << '\n'; << kSkipUsage << '\n';
return 1; exit(1);
} }
SetResourcePath((std::string(argv[1]) + "/resources").c_str()); args->assetDir = argv[1];
if (!sk_mkdir(argv[2])) { args->renderTests = argv[2];
std::cerr << "sk_mkdir(" << argv[2] << ") failed.\n"; args->outputDir = argv[3];
}
int main(int argc, char *argv[]) {
Args args;
parse_args(argc, argv, &args);
SetResourcePath(std::string(args.assetDir + std::string("/resources")).c_str());
if (!sk_mkdir(args.outputDir)) {
std::cerr << "sk_mkdir(" << args.outputDir << ") failed.\n";
return 2; return 2;
} }
StdAssetManager mgr(argv[1]); StdAssetManager mgr(args.assetDir);
SkQP skqp; SkQP skqp;
skqp.init(&mgr, argv[2]); skqp.init(&mgr, args.renderTests, args.outputDir);
int ret = 0; int ret = 0;
const char* const* matchRules = &argv[3]; const char* const* matchRules = &argv[4];
size_t matchRulesCount = (size_t)(argc - 3); size_t matchRulesCount = (size_t)(argc - 4);
// Rendering Tests // Rendering Tests
std::ostream& out = std::cout; std::ostream& out = std::cout;