summaryrefslogtreecommitdiffstats
path: root/tests/config/test.cfg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 20:37:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 20:37:50 +0000
commitc1f743ab2e4a7046d5500875a47d1f62c8624603 (patch)
tree709946d52f5f3bbaeb38be9e3f1d56d11f058237 /tests/config/test.cfg
parentInitial commit. (diff)
downloadknot-resolver-913a96f00351e791fb56b1cd60642cb5fc7f7683.tar.xz
knot-resolver-913a96f00351e791fb56b1cd60642cb5fc7f7683.zip
Adding upstream version 5.7.1.upstream/5.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/config/test.cfg')
-rw-r--r--tests/config/test.cfg46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/config/test.cfg b/tests/config/test.cfg
new file mode 100644
index 0000000..b45226c
--- /dev/null
+++ b/tests/config/test.cfg
@@ -0,0 +1,46 @@
+-- SPDX-License-Identifier: GPL-3.0-or-later
+-- disable output buffering to crashes do not leave us without log
+io.stdout:setvbuf('no')
+io.stderr:setvbuf('no')
+
+-- modify path to be able to load testing modules
+package.path = package.path .. ';' .. env.SOURCE_PATH .. '/?.lua'
+
+-- export testing module in globals
+local tapered = require('tapered.src.tapered')
+for k, v in pairs(tapered) do
+ _G[k] = v
+end
+
+-- don't send priming queries etc.
+modules.unload 'detect_time_skew'
+modules.unload 'priming'
+modules.unload 'ta_signal_query'
+modules.unload 'ta_update'
+
+-- load test
+local ffi = require('ffi')
+assert(type(env.TEST_FILE) == 'string')
+log_info(ffi.C.LOG_GRP_TESTS, 'processing test file %s', env.TEST_FILE)
+local tests = dofile(env.TEST_FILE)
+
+-- run test after processed config file
+-- default config will be used and we can test it.
+assert(type(tests) == 'table',
+ string.format('file %s did not return a table of test'
+ .. ' functions, did you forget return?',
+ env.TEST_FILE))
+
+local runtest = require('test_utils').test
+worker.coroutine(function ()
+ local at_least_one_test = false
+ for idx, t in ipairs(tests) do
+ assert(type(t) == 'function',
+ string.format('test table idx %d in file %s'
+ .. ' is not a function', idx, env.TEST_FILE))
+ at_least_one_test = true
+ runtest(t)
+ end
+ assert(at_least_one_test, 'test set is empty?! a typo in function name?')
+ done()
+end)