Commit a4f7faec authored by Nils Goroll's avatar Nils Goroll

Test that vmod code is still present when calling a task_priv .fini

Tests 20ab2abc
parent 20ab2abc
......@@ -44,8 +44,8 @@ varnish v1 -vcl+backend {
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 = VCL_Log {^func something to remember}
expect 0 = VCL_Log {^obj something to remember}
expect 4 = VCL_Log {^func something to remember}
expect 2 = VCL_Log {^obj something to remember}
} -start
client c1 {
......
......@@ -61,7 +61,11 @@ varnish v1 -arg "-p debug=+vclrel" -vcl+backend {
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 = Debug {^test_priv_task.*new.$}
expect 0 = Debug {^test_priv_task.*update.$}
expect 0 = Debug {^test_priv_task.*exists.$}
expect 0 = VCL_Log {^func something to remember}
expect 0 = Debug {^test_priv_task.*exists.$}
expect 0 = VCL_Log {^obj something to remember}
expect * 1002 Begin fetch$
......@@ -77,8 +81,14 @@ logexpect l1 -v v1 -g raw -d 1 {
expect 0 = VCL_Log ^bar
expect * 0 Debug {^vcl1: VCL_EVENT_COLD}
expect * 0 CLI {^Rd vcl.discard}
expect 0 = Debug {^test_priv_task.*new.$}
expect 0 = Debug {^test_priv_task.*update.$}
expect 0 = Debug {^test_priv_task.*exists.$}
expect * = VCL_Log {^func cleaning up}
expect 0 = Debug {^test_priv_task.*exists.$}
expect 0 = VCL_Log {^obj cleaning up}
expect 0 = Debug {^priv_task_free}
} -start
client c1 {
......
......@@ -123,16 +123,27 @@ xyzzy_test_priv_call(VRT_CTX, struct vmod_priv *priv)
}
}
static void
priv_task_free(void *ptr)
{
AN(ptr);
VSL(SLT_Debug, 0, "priv_task_free(%p)", ptr);
free(ptr);
}
VCL_STRING v_matchproto_(td_debug_test_priv_task)
xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (s == NULL || *s == '\0') {
return priv->priv;
VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (exists)",
priv, priv->priv);
} else if (priv->priv == NULL) {
priv->priv = strdup(s);
priv->free = free;
priv->free = priv_task_free;
VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (new)",
priv, priv->priv);
} else {
char *n = realloc(priv->priv,
strlen(priv->priv) + strlen(s) + 2);
......@@ -141,7 +152,11 @@ xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s)
strcat(n, " ");
strcat(n, s);
priv->priv = n;
VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (update)",
priv, priv->priv);
}
if (priv->priv != NULL)
assert(priv->free == priv_task_free);
return (priv->priv);
}
......
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