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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/bin/sh
_=[[
. "${0%%/*}/regress.sh"
exec runlua "$0" "$@"
]]
require"regress".export".*"
local function uname()
return check(check(io.popen("uname -a", "r")):read"*a")
end
local function localpath(s)
local family, pathname = check(fileresult(s:localname()))
check(family == socket.AF_UNIX, "wrong address family (%s)", tostring(family))
return pathname
end
info"creating socket pair"
local a, b = check(socket.pair(socket.AF_UNIX))
info"check that pathname is nil"
check(localpath(a) == nil, "pathname of AF_UNIX socket pair not nil (%q)", localpath(a))
a:close()
b:close()
if uname():find"Linux" then
local pathname = "\00082-localname-garbage.sock"
info("creating abstract socket at %q", pathname)
local srv = check(socket.listen{ path = pathname })
local a, b
info("checking for abstract socket pathname")
check(localpath(srv) == pathname, "bad pathname (%q)", localpath(srv))
local main = cqueues.new()
main:wrap(function ()
info("accepting connection at %q", pathname)
a = check(srv:accept())
end)
main:wrap(function ()
info("connecting to %q", pathname)
b = check(socket.connect{ path = pathname })
end)
check(main:loop())
check(localpath(a) == pathname, "pathname of connected AF_UNIX socket wrong (%q)", localpath(a))
check(localpath(b) == nil, "pathname of connected AF_UNIX socket not nil (%q)", localpath(b))
end
say("OK")
|