aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorE. Westbrook <git@westbrook.io>2020-03-28 15:14:18 -0600
committerEric Westbrook <github@westbrook.io>2020-03-28 22:21:23 +0000
commitc8b4fdf85829d98e185256fba10d50f5b35735a8 (patch)
treea09801bb1dc0b18809a2d0d53deaa3faf8e35270 /test
parent84e5336e8b9f364e675c3a55a8bb04c1fddb68bc (diff)
downloadluasocket-c8b4fdf85829d98e185256fba10d50f5b35735a8.tar.gz
luasocket-c8b4fdf85829d98e185256fba10d50f5b35735a8.tar.bz2
luasocket-c8b4fdf85829d98e185256fba10d50f5b35735a8.zip
test/getoptions: guard calls with pcall(); check result of getoption"linger"
Diffstat (limited to 'test')
-rwxr-xr-xtest/tcp-getoptions22
1 files changed, 18 insertions, 4 deletions
diff --git a/test/tcp-getoptions b/test/tcp-getoptions
index d98b189..fbcc884 100755
--- a/test/tcp-getoptions
+++ b/test/tcp-getoptions
@@ -4,18 +4,32 @@ local socket = require"socket"
4 4
5port = 8765 5port = 8765
6 6
7function pcalltest(msg, o, opt)
8 local a = { pcall(o.getoption, o, opt) }
9 if a[1] then
10 print(msg, opt, unpack(a))
11 else
12 print(msg, opt, 'fail: ' .. a[2])
13 end
14end
15
7function options(o) 16function options(o)
8 print("options for", o) 17 print("options for", o)
9 18
10 for _, opt in ipairs{ 19 for _, opt in ipairs{
11 "keepalive", "reuseaddr", 20 "keepalive", "reuseaddr",
12 "tcp-nodelay", "tcp-keepidle", "tcp-keepcnt", "tcp-keepintvl"} do 21 "tcp-nodelay", "tcp-keepidle", "tcp-keepcnt", "tcp-keepintvl"} do
13 print("getoption", opt, o:getoption(opt)) 22 pcalltest("getoption", o, opt)
14 end 23 end
15 24
16 print("getoption", "linger", 25 r = o:getoption'linger'
17 "on", o:getoption("linger").on, 26 if r then
18 "timeout", o:getoption("linger").timeout) 27 print("getoption", "linger",
28 "on", r.on,
29 "timeout", r.timeout)
30 else
31 print("getoption", "linger", "no result")
32 end
19end 33end
20 34
21local m = socket.tcp() 35local m = socket.tcp()