Hello,
Here is a simple patch to add a Makefile target to run all "*.vtc"
regression testing files found in 'reg-tests' directory.
It comes with a first VTC file in relation with f874a83 bug fix commit
for LUA. This VTC file parent directory is 'reg-tests/lua'.
I have copied and pasted the commit log at the beginning of the vtc
file. I think this would be a good practice so that to link the vtc
files to the bug it is supposed to test for any regression.
Regards,
Fred.
>From e05d7a9815c2b05e596740fb780e42c77931b6f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= <flecai...@haproxy.com>
Date: Mon, 18 Jun 2018 19:32:10 +0200
Subject: [PATCH] MINOR: tests: First regression testing file.
Add a makefile target 'reg-tests' to run all regression testing file
found in 'reg-tests' directory.
Add reg-tests/lua/h00000.vtc first regression testing file for a LUA
fixed by f874a83 commit.
---
.gitignore | 1 +
Makefile | 5 ++++
reg-tests/lua/h00000.lua | 3 ++
reg-tests/lua/h00000.vtc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
create mode 100644 reg-tests/lua/h00000.lua
create mode 100644 reg-tests/lua/h00000.vtc
diff --git a/.gitignore b/.gitignore
index 73eaeae..32a8a84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@
!/tests
!/debian
!/scripts
+!/reg-tests
# Reject some generic files
*.o
*~
diff --git a/Makefile b/Makefile
index 5d17004..06f8ac9 100644
--- a/Makefile
+++ b/Makefile
@@ -996,3 +996,8 @@ update-version:
echo "$(VERSION)" > VERSION
echo "$(SUBVERS)" > SUBVERS
echo "$(VERDATE)" > VERDATE
+
+reg-tests:
+ @find reg-tests -type f -name "*.vtc" -print0 | \
+ xargs -0 $(VARNISHTEST_PROGRAM) -l -t5
+.PHONY: reg-tests
diff --git a/reg-tests/lua/h00000.lua b/reg-tests/lua/h00000.lua
new file mode 100644
index 0000000..d2401fa
--- /dev/null
+++ b/reg-tests/lua/h00000.lua
@@ -0,0 +1,3 @@
+core.register_action("foo", { "http-req" }, function(txn)
+ txn.sc:ipmask(txn.f:src(), 24, 112)
+end)
diff --git a/reg-tests/lua/h00000.vtc b/reg-tests/lua/h00000.vtc
new file mode 100644
index 0000000..2b2ffb0
--- /dev/null
+++ b/reg-tests/lua/h00000.vtc
@@ -0,0 +1,74 @@
+# commit f874a83
+# BUG/MINOR: lua: Segfaults with wrong usage of types.
+#
+# Patrick reported that this simple configuration made haproxy segfaults:
+#
+# global
+# lua-load /tmp/haproxy.lua
+#
+# frontend f1
+# mode http
+# bind :8000
+# default_backend b1
+#
+# http-request lua.foo
+#
+# backend b1
+# mode http
+# server s1 127.0.0.1:8080
+#
+# with this '/tmp/haproxy.lua' script:
+#
+# core.register_action("foo", { "http-req" }, function(txn)
+# txn.sc:ipmask(txn.f:src(), 24, 112)
+# end)
+#
+# This is due to missing initialization of the array of arguments
+# passed to hlua_lua2arg_check() which makes it enter code with
+# corrupted arguments.
+#
+# Thanks a lot to Patrick Hemmer for having reported this issue.
+
+
+varnishtest "Basic LUA test h00000"
+feature ignore_unknown_macro
+
+server s1 -repeat 2 {
+ rxreq
+ txresp
+} -start
+
+haproxy h1 -conf {
+ global
+ lua-load ${testdir}/h00000.lua
+
+ frontend fe1
+ mode http
+ bind "fd@${fe1}"
+ default_backend b1
+
+ http-request lua.foo
+
+ backend b1
+ mode http
+ server s1 ${s1_addr}:${s1_port}
+
+} -start
+
+client c0 -connect ${h1_fe1_sock} {
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+}
+
+client c1 -connect ${h1_fe1_sock} {
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+}
+
+client c0 -start
+client c1 -start
+
+client c0 -wait
+client c1 -wait
--
2.1.4