[master] 8590a2a49 varnishtest: Support vsl debugging with a suicide trigger

Nils Goroll nils.goroll at uplex.de
Mon Feb 7 13:52:06 UTC 2022


commit 8590a2a49a614dab4c5d0c7ccb79bf39706b1da9
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Feb 7 11:42:42 2022 +0100

    varnishtest: Support vsl debugging with a suicide trigger
    
    Setting breakpoints in a debugger on select vsl events is tidious,
    so add a simple facility to trigger abort() with a logexpect command.

diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index ff727b4fc..b9a1300be 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -162,6 +162,7 @@
 #define LE_SEEN  (-4)
 #define LE_FAIL  (-5)
 #define LE_CLEAR (-6)	// clear fail list
+#define LE_ABORT (-7)
 
 struct logexp_test {
 	unsigned			magic;
@@ -213,10 +214,12 @@ static VTAILQ_HEAD(, logexp)		logexps =
 
 static cmd_f cmd_logexp_expect;
 static cmd_f cmd_logexp_fail;
+static cmd_f cmd_logexp_abort;
 
 static const struct cmds logexp_cmds[] = {
 	{ "expect",		cmd_logexp_expect },
 	{ "fail",		cmd_logexp_fail },
+	{ "abort",		cmd_logexp_abort },
 	{ NULL,			NULL },
 };
 
@@ -354,6 +357,9 @@ logexp_next(struct logexp *le)
 		VTAILQ_INSERT_TAIL(&le->fail, le->test, faillist);
 		logexp_next(le);
 		return;
+	case LE_ABORT:
+		abort();
+		NEEDLESS(return);
 	default:
 		vtc_log(le->vl, 3, "test | %s", VSB_data(le->test->str));
 	}
@@ -745,6 +751,21 @@ cmd_logexp_fail(CMD_ARGS)
 	cmd_logexp_common(le, vl, LE_FAIL, av);
 }
 
+/* aid vsl debugging */
+static void
+cmd_logexp_abort(CMD_ARGS)
+{
+
+	struct logexp *le;
+
+	CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC);
+
+	if (av[1] == NULL || av[2] == NULL || av[3] == NULL)
+		vtc_fatal(vl, "Syntax error");
+
+	cmd_logexp_common(le, vl, LE_ABORT, av);
+}
+
 static void
 logexp_spec(struct logexp *le, const char *spec)
 {


More information about the varnish-commit mailing list