[6.0] eac2d9f24 Always keep .c and .so files if vcl_keep is set
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Fri Feb 8 12:31:11 UTC 2019
commit eac2d9f24ee11c17c1807ed9656fdda5a9a8030d
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sun Dec 2 17:29:17 2018 +0000
Always keep .c and .so files if vcl_keep is set
Add tests for vcl_keep and move vmod_so_keep together.
Reported and diagnosed by jw @ irc.
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index 2b476307b..c42e889d7 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -346,11 +346,13 @@ mgt_VccCompile(struct cli *cli, struct vclprog *vcl, const char *vclname,
VSB_destroy(&sb);
if (status || C_flag) {
- (void)unlink(vp.csrcfile);
+ if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) {
+ (void)unlink(vp.csrcfile);
+ (void)unlink(vp.libfile);
+ (void)rmdir(vp.dir);
+ }
free(vp.csrcfile);
- (void)unlink(vp.libfile);
free(vp.libfile);
- (void)rmdir(vp.dir);
free(vp.dir);
if (status) {
VCLI_Out(cli, "VCL compilation failed");
diff --git a/bin/varnishtest/tests/c00095.vtc b/bin/varnishtest/tests/c00095.vtc
new file mode 100644
index 000000000..93ce3c8b6
--- /dev/null
+++ b/bin/varnishtest/tests/c00095.vtc
@@ -0,0 +1,84 @@
+varnishtest "vcl_keep and vmod_so_keep debug bits"
+
+feature topbuild
+
+server s1 {
+} -start
+
+varnish v1 -vcl+backend {
+} -start
+
+# Test valid and invalid VCL with vcl_keep unset
+
+varnish v1 -cliok "param.set debug -vcl_keep"
+
+varnish v1 -vcl+backend {
+}
+
+shell -err "test -f ./v1/vcl_vcl2.*/vgc.c"
+
+varnish v1 -errvcl {No backends or directors found} {
+}
+
+shell -err "test -f ./v1/vcl_vcl3.*/vgc.c"
+
+# Same but with vcl_keep set
+
+varnish v1 -cliok "param.set debug +vcl_keep"
+
+varnish v1 -vcl+backend {
+}
+
+shell {
+ test -f ./v1/vcl_vcl4.*/vgc.c &&
+ test -f ./v1/vcl_vcl4.*/vgc.so
+}
+
+varnish v1 -errvcl {No backends or directors found} {
+}
+
+shell {
+ test -f ./v1/vcl_vcl5.*/vgc.c &&
+ test -f ./v1/vcl_vcl5.*/vgc.so
+}
+
+# Test vmod with vmod_so_keep set
+
+varnish v1 -cliok "param.set debug +vmod_so_keep"
+
+varnish v1 -vcl+backend {
+ import std;
+}
+
+shell "test -f ./v1/vmod_cache/_vmod_std.*"
+
+varnish v1 -stop
+varnish v1 -cleanup
+
+# Ensure these are not deleted on exit
+
+shell {
+ test -f ./v1/vcl_vcl4.*/vgc.c &&
+ test -f ./v1/vcl_vcl4.*/vgc.so &&
+ test -f ./v1/vcl_vcl5.*/vgc.c &&
+ test -f ./v1/vcl_vcl5.*/vgc.so &&
+ test -f ./v1/vmod_cache/_vmod_std.*
+}
+
+varnish v2 -vcl+backend {
+} -start
+
+# And test vmod with vmod_so_keep unset
+
+varnish v2 -cliok "param.set debug -vmod_so_keep"
+
+varnish v2 -vcl+backend {
+ import std;
+}
+
+shell "test -f ./v2/vmod_cache/_vmod_std.*"
+
+varnish v2 -stop
+varnish v2 -cleanup
+
+shell -err "test -f ./v2/vmod_cache/_vmod_std.*"
diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc
index 7026f578e..a0bc5b2a3 100644
--- a/bin/varnishtest/tests/m00008.vtc
+++ b/bin/varnishtest/tests/m00008.vtc
@@ -47,14 +47,3 @@ varnish v1 -errvcl {Malformed VMOD std} {
backend default { .host = "${s1_sock}"; }
import std from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so";
}
-
-# Check creation and cleanup of copied shared objects for VMODs
-shell "test -e ./v1/vmod_cache/_vmod_std.*"
-
-# In case varnishtest was invoked with -L or -l, in which case the
-# bit is switched on.
-varnish v1 -cliok "param.set debug -vmod_so_keep"
-
-varnish v1 -stop
-varnish v1 -cleanup
-shell -err "test -e ./v1/vmod_cache/_vmod_std.*"
diff --git a/bin/varnishtest/tests/m00030.vtc b/bin/varnishtest/tests/m00030.vtc
deleted file mode 100644
index 4ea2e0ede..000000000
--- a/bin/varnishtest/tests/m00030.vtc
+++ /dev/null
@@ -1,17 +0,0 @@
-varnishtest "debug bit vmod_so_keep"
-
-feature topbuild
-
-varnish v1 -vcl {
- import std;
- backend b { .host = "${bad_backend}"; }
-} -start
-
-shell "test -e ./v1/vmod_cache/_vmod_std.*"
-
-varnish v1 -cliok "param.set debug +vmod_so_keep"
-
-# cf m00008.vtc
-varnish v1 -stop
-varnish v1 -cleanup
-shell "test -e ./v1/vmod_cache/_vmod_std.*"
More information about the varnish-commit
mailing list