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.
parent cca34010
......@@ -345,11 +345,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");
......
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.*"
......@@ -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.*"
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.*"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment