diff -Nru lua-sec-0.9/debian/changelog lua-sec-0.9/debian/changelog --- lua-sec-0.9/debian/changelog 2019-12-30 09:53:07.000000000 +0000 +++ lua-sec-0.9/debian/changelog 2020-01-03 14:50:17.000000000 +0000 @@ -1,3 +1,9 @@ +lua-sec (0.9-3) unstable; urgency=medium + + * fix tests, let the OS choose a free port + + -- Victor Seva Fri, 03 Jan 2020 15:50:17 +0100 + lua-sec (0.9-2) unstable; urgency=medium * update to debhelper 12 diff -Nru lua-sec-0.9/debian/patches/0001-test.patch lua-sec-0.9/debian/patches/0001-test.patch --- lua-sec-0.9/debian/patches/0001-test.patch 2019-12-30 09:53:07.000000000 +0000 +++ lua-sec-0.9/debian/patches/0001-test.patch 2020-01-03 14:50:17.000000000 +0000 @@ -4,14 +4,14 @@ --- test.lua | 2 ++ - test.sh | 13 +++++++++++++ - 2 files changed, 15 insertions(+) + test.sh | 14 ++++++++++++++ + 2 files changed, 16 insertions(+) create mode 100644 test.lua create mode 100644 test.sh diff --git a/test.lua b/test.lua new file mode 100644 -index 0000000..7b00731 +index 0000000..7681667 --- /dev/null +++ b/test.lua @@ -0,0 +1,2 @@ @@ -19,7 +19,7 @@ +if rc == true then os.exit(0) elseif rc== 0 then os.exit(0) else os.exit(1); end diff --git a/test.sh b/test.sh new file mode 100644 -index 0000000..5af8612 +index 0000000..dbb2e1c --- /dev/null +++ b/test.sh @@ -0,0 +1,14 @@ diff -Nru lua-sec-0.9/debian/patches/0003-oneshot-let-the-OS-choose-a-free-port.patch lua-sec-0.9/debian/patches/0003-oneshot-let-the-OS-choose-a-free-port.patch --- lua-sec-0.9/debian/patches/0003-oneshot-let-the-OS-choose-a-free-port.patch 1970-01-01 00:00:00.000000000 +0000 +++ lua-sec-0.9/debian/patches/0003-oneshot-let-the-OS-choose-a-free-port.patch 2020-01-03 14:50:17.000000000 +0000 @@ -0,0 +1,61 @@ +From: Victor Seva +Date: Fri, 3 Jan 2020 14:02:36 +0100 +Subject: oneshot: let the OS choose a free port + +--- + samples/oneshot/client.lua | 4 +++- + samples/oneshot/server.lua | 4 +++- + test.sh | 9 ++++++--- + 3 files changed, 12 insertions(+), 5 deletions(-) + +diff --git a/samples/oneshot/client.lua b/samples/oneshot/client.lua +index 48bc0bb..b652698 100644 +--- a/samples/oneshot/client.lua ++++ b/samples/oneshot/client.lua +@@ -15,7 +15,9 @@ local params = { + } + + local peer = socket.tcp() +-peer:connect("127.0.0.1", 8888) ++local port = 8888 ++if arg[1] then port = arg[1] end ++peer:connect("127.0.0.1", port) + + -- [[ SSL wrapper + peer = assert( ssl.wrap(peer, params) ) +diff --git a/samples/oneshot/server.lua b/samples/oneshot/server.lua +index b3bcd8d..0952986 100644 +--- a/samples/oneshot/server.lua ++++ b/samples/oneshot/server.lua +@@ -21,7 +21,9 @@ local ctx = assert(ssl.newcontext(params)) + + local server = socket.tcp() + server:setoption('reuseaddr', true) +-assert( server:bind("127.0.0.1", 8888) ) ++assert( server:bind("127.0.0.1", 0) ) ++local ip, port = server:getsockname() ++io.stderr:write(port) + server:listen() + + local peer = server:accept() +diff --git a/test.sh b/test.sh +index dbb2e1c..b6b5d43 100644 +--- a/test.sh ++++ b/test.sh +@@ -5,10 +5,13 @@ set -x + set -m + + cd samples/oneshot/ +- +-lua$1 server.lua & ++port_file=$(mktemp) ++lua$1 server.lua 2>${port_file} & + sleep 1 + ret=0 +-lua$1 client.lua || ret=$? ++port=$(cat ${port_file}) ++echo "server port is: $port" ++lua$1 client.lua $port || ret=$? + kill -9 %1 || true ++rm -f ${port_file} + exit $ret diff -Nru lua-sec-0.9/debian/patches/series lua-sec-0.9/debian/patches/series --- lua-sec-0.9/debian/patches/series 2019-12-30 09:53:07.000000000 +0000 +++ lua-sec-0.9/debian/patches/series 2020-01-03 14:50:17.000000000 +0000 @@ -1,2 +1,3 @@ 0001-test.patch 0002-lua-sec.h.patch +0003-oneshot-let-the-OS-choose-a-free-port.patch