Skip to content

Commit

Permalink
tests: Improve result parser and introduce new result MalformedResult
Browse files Browse the repository at this point in the history
  • Loading branch information
Wallbraker committed Sep 6, 2019
1 parent 5205a4f commit f65c93c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/deqp/tests/info.volt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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";
}
}
}
87 changes: 62 additions & 25 deletions src/deqp/tests/parser.volt
Original file line number Diff line number Diff line change
Expand Up @@ -228,66 +228,103 @@ 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);
auto iQual = watt.indexOf(l, HeaderQual);
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 (";
Expand Down
15 changes: 11 additions & 4 deletions src/deqp/tests/result.volt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down Expand Up @@ -123,6 +126,7 @@ public:
numPass: u32;
numQualityWarning: u32;
numCompatibilityWarning: u32;
numMalformedResults: u32;

suites: Suite[];

Expand All @@ -141,7 +145,8 @@ public:
fn getBad() u32
{
return numIncomplete + numFail + numInternalError +
numBadTerminate + numBadTerminatePass;
numBadTerminate + numBadTerminatePass +
numMalformedResults;
}

fn getSkip() u32
Expand All @@ -159,15 +164,16 @@ public:
return numFail + numIncomplete + numInternalError +
numNotSupported + numPass + numQualityWarning +
numIncomplete + numInternalError +
numCompatibilityWarning;
numCompatibilityWarning + numMalformedResults;
}

fn count()
{
// 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) {
Expand All @@ -182,6 +188,7 @@ public:
case Pass: numPass++; break;
case NotSupported: numNotSupported++; break;
case NotListed: break;
case MalformedResult: numMalformedResults++; break;
}
}
}
Expand Down

0 comments on commit f65c93c

Please sign in to comment.