Test: Actually add CInema core config loading
Vicki Pfau vi@endrift.com
Thu, 25 Jun 2020 02:12:27 -0700
1 files changed,
30 insertions(+),
1 deletions(-)
jump to
M
src/platform/test/cinema-main.c
→
src/platform/test/cinema-main.c
@@ -303,7 +303,36 @@ }
void CInemaConfigLoad(struct Table* configTree, const char* testName, struct mCore* core) { _loadConfigTree(configTree, testName); - // TODO: Write + + char testKey[MAX_TEST] = {0}; + char* keyEnd = testKey; + const char* pos; + while (true) { + pos = strchr(testName, '.'); + size_t maxlen = sizeof(testKey) - (keyEnd - testKey) - 1; + size_t len; + if (pos) { + len = pos - testName; + } else { + len = strlen(testName); + } + if (len > maxlen) { + len = maxlen; + } + strncpy(keyEnd, testName, len); + keyEnd += len; + + struct mCoreConfig* config = HashTableLookup(configTree, testKey); + if (config) { + core->loadConfig(core, config); + } + if (!pos) { + break; + } + testName = pos + 1; + keyEnd[0] = '.'; + ++keyEnd; + } } bool CInemaTestInit(struct CInemaTest* test, const char* directory, const char* filename) {