summaryrefslogtreecommitdiffstats
path: root/tests/config
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2020-05-25 14:16:06 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2020-05-25 15:32:50 +0200
commit5d128baa740b8425314af5c636a8027b4c6680d9 (patch)
tree4f99423220d1e21764f528e5db72a573bb6d5b0c /tests/config
parenttests: move check_answer() into require('tests_utils') (diff)
downloadknot-resolver-5d128baa740b8425314af5c636a8027b4c6680d9.tar.xz
knot-resolver-5d128baa740b8425314af5c636a8027b4c6680d9.zip
tests check_answer(): do not return until finished
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/test_utils.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/config/test_utils.lua b/tests/config/test_utils.lua
index 24737e7c..5b391888 100644
--- a/tests/config/test_utils.lua
+++ b/tests/config/test_utils.lua
@@ -39,8 +39,10 @@ function M.not_contains(table, value, message)
return contains(fail, pass, table, value, message)
end
+-- Resolve a name and check the answer. Do *not* return until finished.
function M.check_answer(desc, qname, qtype, expected_rcode)
qtype_str = kres.tostring.type[qtype]
+ local done = false
callback = function(pkt)
same(pkt:rcode(), expected_rcode,
desc .. ': expecting answer for query ' .. qname .. ' ' .. qtype_str
@@ -48,8 +50,15 @@ function M.check_answer(desc, qname, qtype, expected_rcode)
ok((pkt:ancount() > 0) == (pkt:rcode() == kres.rcode.NOERROR),
desc ..': checking number of answers for ' .. qname .. ' ' .. qtype_str)
+ done = true
end
resolve(qname, qtype, kres.class.IN, {}, callback)
+
+ for delay = 0.1, 4, 0.5 do -- total max 14.9s in 8 steps
+ if done then return end
+ worker.sleep(delay)
+ end
+ if not done then fail('check_answer() timed out') end
end
return M