Load the SkSL error tests when SkQP::init is executed.
Change-Id: I28d4859c13dfdf42da12d02899416aa86c944662 Bug: skia:13042 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521219 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
097e63584e
commit
3bdeedc497
@ -23,6 +23,7 @@
|
||||
#include "src/utils/SkOSPath.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestHarness.h"
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/fonts/TestFontMgr.h"
|
||||
#ifdef SK_GL
|
||||
#include "tools/gpu/gl/GLTestContext.h"
|
||||
@ -109,6 +110,38 @@ static std::vector<SkQP::UnitTest> get_unit_tests(const ExclusionList& exclusion
|
||||
return unitTests;
|
||||
}
|
||||
|
||||
// Returns a list of every SkSL error test to be run.
|
||||
static std::vector<SkQP::SkSLErrorTest> get_sksl_error_tests(const ExclusionList& exclusionList) {
|
||||
std::vector<SkQP::SkSLErrorTest> skslErrorTests;
|
||||
|
||||
auto iterateFn = [&](const char* directory, const char* extension) {
|
||||
SkString resourceDirectory = GetResourcePath(directory);
|
||||
SkOSFile::Iter iter(resourceDirectory.c_str(), extension);
|
||||
SkString name;
|
||||
|
||||
while (iter.next(&name, /*getDir=*/false)) {
|
||||
if (exclusionList.isExcluded(name.c_str())) {
|
||||
continue;
|
||||
}
|
||||
SkString path(SkOSPath::Join(directory, name.c_str()));
|
||||
sk_sp<SkData> shaderText = GetResourceAsData(path.c_str());
|
||||
if (!shaderText) {
|
||||
continue;
|
||||
}
|
||||
skslErrorTests.push_back({name.c_str(), static_cast<const char*>(shaderText->data())});
|
||||
}
|
||||
};
|
||||
|
||||
// Android only supports runtime shaders, not color filters or blenders.
|
||||
iterateFn("sksl/runtime_errors/", ".rts");
|
||||
|
||||
auto lt = [](const SkQP::SkSLErrorTest& a, const SkQP::SkSLErrorTest& b) {
|
||||
return a.name < b.name;
|
||||
};
|
||||
std::sort(skslErrorTests.begin(), skslErrorTests.end(), lt);
|
||||
return skslErrorTests;
|
||||
}
|
||||
|
||||
static std::unique_ptr<sk_gpu_test::TestContext> make_test_context(SkQP::SkiaBackend backend) {
|
||||
using U = std::unique_ptr<sk_gpu_test::TestContext>;
|
||||
switch (backend) {
|
||||
@ -213,6 +246,7 @@ void SkQP::init(SkQPAssetManager* assetManager, const char* reportDirectory) {
|
||||
}
|
||||
|
||||
fUnitTests = get_unit_tests(exclusionList);
|
||||
fSkSLErrorTests = get_sksl_error_tests(exclusionList);
|
||||
fSupportedBackends = get_backends();
|
||||
|
||||
print_backend_info((fReportDirectory + "/grdump.txt").c_str(), fSupportedBackends);
|
||||
@ -232,7 +266,7 @@ std::vector<std::string> SkQP::executeTest(SkQP::UnitTest test) {
|
||||
test->fContextOptionsProc(&options);
|
||||
}
|
||||
test->fProc(&r, options);
|
||||
fUnitTestResults.push_back(UnitTestResult{test, r.fErrors});
|
||||
fTestResults.push_back(TestResult{test->fName, r.fErrors});
|
||||
return r.fErrors;
|
||||
}
|
||||
|
||||
@ -250,13 +284,13 @@ void SkQP::makeReport() {
|
||||
}
|
||||
SkFILEWStream unitOut(SkOSPath::Join(fReportDirectory.c_str(), kUnitTestReportPath).c_str());
|
||||
SkASSERT_RELEASE(unitOut.isValid());
|
||||
for (const SkQP::UnitTestResult& result : fUnitTestResults) {
|
||||
unitOut.writeText(GetUnitTestName(result.fUnitTest));
|
||||
if (result.fErrors.empty()) {
|
||||
for (const SkQP::TestResult& result : fTestResults) {
|
||||
unitOut.writeText(result.name.c_str());
|
||||
if (result.errors.empty()) {
|
||||
unitOut.writeText(" PASSED\n* * *\n");
|
||||
} else {
|
||||
write(&unitOut, SkStringPrintf(" FAILED (%zu errors)\n", result.fErrors.size()));
|
||||
for (const std::string& err : result.fErrors) {
|
||||
write(&unitOut, SkStringPrintf(" FAILED (%zu errors)\n", result.errors.size()));
|
||||
for (const std::string& err : result.errors) {
|
||||
write(&unitOut, err);
|
||||
unitOut.newline();
|
||||
}
|
||||
|
@ -46,6 +46,11 @@ public:
|
||||
};
|
||||
using UnitTest = const skiatest::Test*;
|
||||
|
||||
struct SkSLErrorTest {
|
||||
std::string name;
|
||||
std::string shaderText;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** These functions provide a descriptive name for the given value.*/
|
||||
@ -71,17 +76,21 @@ public:
|
||||
/** @return a sorted list of all Skia GPU unit tests */
|
||||
const std::vector<UnitTest>& getUnitTests() const { return fUnitTests; }
|
||||
|
||||
/** @return a sorted list of all SkSL error tests */
|
||||
const std::vector<SkSLErrorTest>& getSkSLErrorTests() const { return fSkSLErrorTests; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
struct UnitTestResult {
|
||||
UnitTest fUnitTest;
|
||||
std::vector<std::string> fErrors;
|
||||
struct TestResult {
|
||||
std::string name;
|
||||
std::vector<std::string> errors;
|
||||
};
|
||||
std::vector<UnitTestResult> fUnitTestResults;
|
||||
std::vector<TestResult> fTestResults;
|
||||
std::vector<SkiaBackend> fSupportedBackends;
|
||||
std::string fReportDirectory;
|
||||
std::vector<UnitTest> fUnitTests;
|
||||
std::vector<SkSLErrorTest> fSkSLErrorTests;
|
||||
|
||||
SkQP(const SkQP&) = delete;
|
||||
SkQP& operator=(const SkQP&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user