]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests: print stack traces from check_answer callback function
authorPetr Špaček <petr.spacek@nic.cz>
Wed, 8 Jul 2020 12:43:09 +0000 (14:43 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 8 Dec 2020 17:15:02 +0000 (18:15 +0100)
tests/config/test_utils.lua

index 53b6c09c891760d9c5ec154b2506d4db1371fdc6..15a14520f3704dd1ad1f1a4daa355fe5b6b544c4 100644 (file)
@@ -81,8 +81,17 @@ function M.check_answer(desc, qname, qtype, expected_rcode, expected_rdata)
                        end
                end
                done = true
-       end
-       resolve(qname, qtype, kres.class.IN, {}, callback)
+               end
+       resolve(qname, qtype, kres.class.IN, {},
+               function(...)
+                       local ok, err = xpcall(callback, debug.traceback, ...)
+                       if not ok then
+                               fail('error in check_answer callback function')
+                               io.stderr:write(string.format('%s\n', err))
+                               os.exit(2)
+                       end
+               end
+       )
 
        for delay = 0.1, 4, 0.5 do -- total max 14.9s in 8 steps
                if done then return end