1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
skip_if(not existsonpath("netstat"))
includecommon("netsync.lua")
mtn_setup()
netsync.setup()
math.randomseed(get_pid())
local port = math.random(1024, 65535)
-- test with host:port
srv = netsync.start({"--bind", "localhost:" .. port})
check({"netstat", "-a", "-n"}, 0, true, false)
check(qgrep("127[.]0[.]0[.]1[.:]" .. port, "stdout"))
srv:stop()
-- test with ip:port
srv = netsync.start({"--bind", "127.0.0.1:" .. port})
check({"netstat", "-a", "-n"}, 0, true, false)
check(qgrep("127[.]0[.]0[.]1[.:]" .. port, "stdout"))
srv:stop()
-- test only with :port
srv = netsync.start({"--bind", ":" .. port})
check({"netstat", "-a", "-n"}, 0, true, false)
check(qgrep("([*]|0[.]0[.]0[.]0)[.:]" .. port, "stdout"))
srv:stop()
|