Test: Add rudimentary input playback
Vicki Pfau vi@endrift.com
Wed, 22 Jul 2020 16:55:05 -0700
1 files changed,
28 insertions(+),
2 deletions(-)
jump to
M
src/platform/test/cinema-main.c
→
src/platform/test/cinema-main.c
@@ -427,7 +427,7 @@ UNUSED(user);
mCoreConfigDeinit(value); } -static const char* _lookupValue(struct Table* configTree, const char* testName, const char* key) { +static const char* CInemaConfigGet(struct Table* configTree, const char* testName, const char* key) { _loadConfigTree(configTree, testName); char testKey[MAX_TEST];@@ -456,7 +456,7 @@ return NULL;
} bool CInemaConfigGetUInt(struct Table* configTree, const char* testName, const char* key, unsigned* out) { - const char* charValue = _lookupValue(configTree, testName, key); + const char* charValue = CInemaConfigGet(configTree, testName, key); if (!charValue) { return false; }@@ -672,6 +672,29 @@ CIerr(0, "Could not open output file %s\n", baselineName);
} } +static bool _updateInput(struct mCore* core, size_t frame, const char** input) { + if (!*input || !*input[0]) { + return false; + } + char* end; + uint32_t start = strtoul(*input, &end, 10); + if (end[0] != ':') { + return false; + } + if (start != frame) { + return true; + } + ++end; + *input = end; + uint32_t keys = strtoul(*input, &end, 16); + if (end[0] == ',') { + ++end; + } + *input = end; + core->setKeys(core, keys); + return true; +} + void CInemaTestRun(struct CInemaTest* test) { unsigned ignore = 0; MutexLock(&configMutex);@@ -724,12 +747,14 @@ unsigned limit = 9999;
unsigned skip = 0; unsigned fail = 0; unsigned video = 0; + const char* input = NULL; MutexLock(&configMutex); CInemaConfigGetUInt(&configTree, test->name, "frames", &limit); CInemaConfigGetUInt(&configTree, test->name, "skip", &skip); CInemaConfigGetUInt(&configTree, test->name, "fail", &fail); CInemaConfigGetUInt(&configTree, test->name, "video", &video); + input = CInemaConfigGet(&configTree, test->name, "input"); CInemaConfigLoad(&configTree, test->name, core); MutexUnlock(&configMutex);@@ -805,6 +830,7 @@ }
#endif for (frame = 0; limit; ++frame, --limit) { + _updateInput(core, frame, &input); core->runFrame(core); ++test->totalFrames; unsigned frameCounter = core->frameCounter(core);