diff options
author | Petr Špaček <petr.spacek@nic.cz> | 2019-12-20 15:18:00 +0100 |
---|---|---|
committer | Petr Špaček <petr.spacek@nic.cz> | 2019-12-20 15:18:00 +0100 |
commit | 317e620f494fff8dcb5877e3f69a4b4a5a5b0387 (patch) | |
tree | 918cf3cd5869bbacda9ca670533bcecb0eec2261 /tests/config/net.test.lua | |
parent | modules/http: fix net.listen in config tests (diff) | |
download | knot-resolver-317e620f494fff8dcb5877e3f69a4b4a5a5b0387.tar.xz knot-resolver-317e620f494fff8dcb5877e3f69a4b4a5a5b0387.zip |
tests: sanity check for net.listen() and net.list()
Diffstat (limited to 'tests/config/net.test.lua')
-rw-r--r-- | tests/config/net.test.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/config/net.test.lua b/tests/config/net.test.lua index 805d215a..1b693eb8 100644 --- a/tests/config/net.test.lua +++ b/tests/config/net.test.lua @@ -1,10 +1,33 @@ +local kr_table_len = require('kluautil').kr_table_len + +local function test_env_no_listen() + -- config tests are executed with env variable KRESD_NO_LISTEN=1 + -- so net.list() should be an empty table + same(kr_table_len(net.list()), 0, + "env 'KRESD_NO_LISTEN=1' prevents kresd from listening") +end + local function test_freebind() boom(net.listen, {'192.0.2.1', 50049}, 'net.listen() without freebind should fail') + -- TODO: same(kr_table_len(net.list()), 0, + -- "net.listen() failure does not modify output from net.list()") ok(net.listen('192.0.2.1', 50049, { freebind=true }), 'net.listen() with freebind succeeds') + local net_list = net.list() + -- same(list length == 2) + same(net_list[1].transport.protocol, 'udp', + 'net.listen({freebind = true}) without kind starts UDP listener') + same(net_list[2].transport.protocol, 'tcp', + 'net.listen({freebind = true}) without kind starts TCP listener') + same(net_list[1].transport.freebind, true, + 'net.listen({freebind = true}) enables FREEBIND for UDP listener') + same(net_list[2].transport.freebind, true, + 'net.listen({freebind = true}) enables FREEBIND for TCP listener') + end return { + test_env_no_listen, test_freebind, } |