From f65c93c80b04daf45f505fc67a435ee311776ffc Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 6 Sep 2019 11:33:24 +0100 Subject: [PATCH] tests: Improve result parser and introduce new result MalformedResult --- src/deqp/tests/info.volt | 2 + src/deqp/tests/parser.volt | 87 +++++++++++++++++++++++++++----------- src/deqp/tests/result.volt | 15 +++++-- 3 files changed, 75 insertions(+), 29 deletions(-) diff --git a/src/deqp/tests/info.volt b/src/deqp/tests/info.volt index d0b311f..2815511 100644 --- a/src/deqp/tests/info.volt +++ b/src/deqp/tests/info.volt @@ -146,6 +146,7 @@ fn format(res: Result, ref opts: PrintOptions) string case CompatibilityWarning: return "\u001b[33mCompatibilityWarning\u001b[0m"; case Pass: return "\u001b[32mPass\u001b[0m"; case NotListed: return "\u001b[32mNotListed\u001b[0m"; + case MalformedResult: return "\u001b[31mMalformedResult\u001b[0m"; } } else { final switch (res) with (Result) { @@ -159,6 +160,7 @@ fn format(res: Result, ref opts: PrintOptions) string case CompatibilityWarning: return "CompatibilityWarning"; case Pass: return "Pass"; case NotListed: return "NotListed"; + case MalformedResult: return "MalformedResult"; } } } diff --git a/src/deqp/tests/parser.volt b/src/deqp/tests/parser.volt index 30100a3..b7e1e23 100644 --- a/src/deqp/tests/parser.volt +++ b/src/deqp/tests/parser.volt @@ -228,27 +228,22 @@ fn parseResultsAndAssign(fileConsole: string, tests: Test[]) { console := cast(string) watt.read(fileConsole); - map: u32[string]; - foreach (index, test; tests/*suite.tests[offset .. offset + numTests]*/) { - map[test.name] = cast(u32)index; + state: ParseState; + state.tests = tests; + foreach (index, test; tests) { + state.map[test.name] = cast(u32)index; } - index: u32; - string testCase; foreach (l; watt.splitLines(console)) { - if (testCase.length == 0) { + if (state.testCase.length == 0) { auto i = watt.indexOf(l, HeaderName); if (i < 0) { continue; } else { - testCase = l[cast(size_t) i + HeaderName.length .. $ - 3]; - if (testCase in map is null) { - warn("\t\tCould not find test '%s'?!", testCase); - continue; - } - index = map[testCase]; + state.getTestCase(i, l); } } else { + auto iName = watt.indexOf(l, HeaderName); auto iPass = watt.indexOf(l, HeaderPass); auto iFail = watt.indexOf(l, HeaderFail); auto iSupp = watt.indexOf(l, HeaderSupp); @@ -256,38 +251,80 @@ fn parseResultsAndAssign(fileConsole: string, tests: Test[]) auto iIErr = watt.indexOf(l, HeaderIErr); auto iComp = watt.indexOf(l, HeaderComp); - if (iPass >= 0) { + if (iName >= 0) { + //info("Name %s", testCase); + state.setResult(Result.MalformedResult); + state.getTestCase(iName, l); + } else if (iPass >= 0) { //info("Pass %s", testCase); - tests[index].result = Result.Pass; + state.setResult(Result.Pass); } else if (iFail >= 0) { //auto res = l[iFail + startFail.length .. $ - 2].idup; - tests[index].result = Result.Fail; + state.setResult(Result.Fail); } else if (iSupp >= 0) { //info("!Sup %s", testCase); - tests[index].result = Result.NotSupported; + state.setResult(Result.NotSupported); } else if (iQual >= 0) { //info("Qual %s", testCase); - tests[index].result = Result.QualityWarning; + state.setResult(Result.QualityWarning); } else if (iIErr >= 0) { //auto res = l[iIErr + startIErr.length .. $ - 2].idup; - tests[index].result = Result.InternalError; + state.setResult(Result.InternalError); } else if (iComp >= 0) { //auto res = l[iComp + startComp.length .. $ - 2].idup; - tests[index].result = Result.CompatibilityWarning; - } else { - if (l.length > 0) { - continue; - } + state.setResult(Result.CompatibilityWarning); } - index++; - testCase = null; } } + + state.setResult(Result.MalformedResult); } private: +fn setResult(ref state: ParseState, r: Result) +{ + if (state.testCase.length == 0) { + return; + } + + state.tests[state.index].result = r; + state.testCase = null; +} + +fn getTestCase(ref state: ParseState, i: ptrdiff_t, l: string) +{ + if (l.length < HeaderName.length + 1) { + warn("\t\tReally weird TestCase line! '%s'", l); + } + + if (l.length < HeaderName.length + 4) { + warn("\t\tWeird TestCase line! '%s'", l); + return; + } + + state.testCase = l[cast(size_t) i + HeaderName.length .. $ - 3]; + + if (state.testCase in state.map is null) { + warn("\t\tCould not find test '%s'?!", state.testCase); + state.testCase = null; + return; + } + + state.index = state.map[state.testCase]; +} + + + +struct ParseState +{ + testCase: string; + map: u32[string]; + tests: Test[]; + index: u32; +}; + enum HeaderName = "Test case '"; enum HeaderIErr = "InternalError ("; enum HeaderPass = "Pass ("; diff --git a/src/deqp/tests/result.volt b/src/deqp/tests/result.volt index bdc7487..f2dca64 100644 --- a/src/deqp/tests/result.volt +++ b/src/deqp/tests/result.volt @@ -23,7 +23,8 @@ enum Result QualityWarning, CompatibilityWarning, Pass, - NotListed, //< For compare, the test wasn't in the regression file. + MalformedResult, //!< Parser can parse the results. + NotListed, //!< For compare, the test wasn't in the regression file. } fn isResultPassing(result: Result) bool @@ -39,6 +40,7 @@ fn isResultPassing(result: Result) bool case CompatibilityWarning: return true; case Pass: return true; case NotListed: return true; + case MalformedResult: return false; } } @@ -55,6 +57,7 @@ fn isResultFailing(result: Result) bool case CompatibilityWarning: return false; case Pass: return false; case NotListed: return false; + case MalformedResult: return true; } } @@ -123,6 +126,7 @@ public: numPass: u32; numQualityWarning: u32; numCompatibilityWarning: u32; + numMalformedResults: u32; suites: Suite[]; @@ -141,7 +145,8 @@ public: fn getBad() u32 { return numIncomplete + numFail + numInternalError + - numBadTerminate + numBadTerminatePass; + numBadTerminate + numBadTerminatePass + + numMalformedResults; } fn getSkip() u32 @@ -159,7 +164,7 @@ public: return numFail + numIncomplete + numInternalError + numNotSupported + numPass + numQualityWarning + numIncomplete + numInternalError + - numCompatibilityWarning; + numCompatibilityWarning + numMalformedResults; } fn count() @@ -167,7 +172,8 @@ public: // Reset the old numbers. numFail = numIncomplete = numInternalError = numNotSupported = numBadTerminate = numBadTerminatePass = numPass = - numQualityWarning = numCompatibilityWarning = 0; + numQualityWarning = numCompatibilityWarning = + numMalformedResults = 0; foreach (suite; suites) { foreach (test; suite.tests) { @@ -182,6 +188,7 @@ public: case Pass: numPass++; break; case NotSupported: numNotSupported++; break; case NotListed: break; + case MalformedResult: numMalformedResults++; break; } } }