Test: End test early if a fatal error occurs
Vicki Pfau vi@endrift.com
Fri, 17 Jul 2020 02:55:11 -0700
1 files changed,
13 insertions(+),
2 deletions(-)
jump to
M
src/platform/test/cinema-main.c
→
src/platform/test/cinema-main.c
@@ -109,6 +109,7 @@ static Mutex jobMutex;
static Thread jobThreads[MAX_JOBS]; static int jobStatus; static ThreadLocal stringBuilder; +static ThreadLocal currentTest; bool CInemaTestInit(struct CInemaTest*, const char* directory, const char* filename); void CInemaTestRun(struct CInemaTest*);@@ -771,6 +772,9 @@ #endif
} else { baselineFound = _loadBaselinePNG(dir, &expected, frame, &test->status); } + if (test->status == CI_ERROR) { + break; + } if (baselineFound) { uint8_t* testPixels = image.data; uint8_t* expectPixels = expected.data;@@ -864,8 +868,6 @@ }
free(diff); } free(expected.data); - } else if (test->status == CI_ERROR) { - break; } else if (rebaseline && !video) { _writeBaseline(dir, &image, frame); } else if (!rebaseline) {@@ -905,7 +907,10 @@ CIlog(-1, "%s\n", test->name);
} else { CIlog(1, "%s: ", test->name); fflush(stdout); + ThreadLocalSetKey(currentTest, test); CInemaTestRun(test); + ThreadLocalSetKey(currentTest, NULL); + switch (test->status) { case CI_PASS: CIlog(1, "pass\n");@@ -975,6 +980,10 @@ }
void _log(struct mLogger* log, int category, enum mLogLevel level, const char* format, va_list args) { UNUSED(log); + if (level == mLOG_FATAL) { + struct CInemaTest* test = ThreadLocalGetValue(currentTest); + test->status = CI_ERROR; + } if (verbosity < 0) { return; }@@ -1071,6 +1080,8 @@ }
HashTableInit(&configTree, 0, free); MutexInit(&configMutex); + ThreadLocalInitKey(¤tTest); + ThreadLocalSetKey(currentTest, NULL); if (jobs == 1) { size_t i;