[master] d8ca2e995 varnishtest logexpect refactor: pull out common code from cmd_logexp for reuse
Nils Goroll
nils.goroll at uplex.de
Thu Jan 14 12:55:09 UTC 2021
commit d8ca2e99517952d34aef8142f2d0af053175329f
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Jan 14 11:20:45 2021 +0100
varnishtest logexpect refactor: pull out common code from cmd_logexp for reuse
Ref #3249
diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index 50b61a828..34997954b 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -588,11 +588,12 @@ logexp_wait(struct logexp *le)
le->run = 0;
}
+/* shared by expect and fail: parse from av[2] (vxid) onwards */
+
static void
-cmd_logexp_expect(CMD_ARGS)
+cmd_logexp_common(struct logexp *le, struct vtclog *vl,
+ int skip_max, char * const *av)
{
- struct logexp *le;
- int skip_max;
int vxid;
int tag;
vre_t *vre;
@@ -601,22 +602,6 @@ cmd_logexp_expect(CMD_ARGS)
struct logexp_test *test;
char *end;
- CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC);
- if (av[1] == NULL || av[2] == NULL || av[3] == NULL)
- vtc_fatal(vl, "Syntax error");
-
- if (av[4] != NULL && av[5] != NULL)
- vtc_fatal(vl, "Syntax error");
-
- if (!strcmp(av[1], "*"))
- skip_max = LE_ANY;
- else if (!strcmp(av[1], "?"))
- skip_max = LE_ALT;
- else {
- skip_max = (int)strtol(av[1], &end, 10);
- if (*end != '\0' || skip_max < 0)
- vtc_fatal(vl, "Not a positive integer: '%s'", av[1]);
- }
if (!strcmp(av[2], "*"))
vxid = LE_ANY;
else if (!strcmp(av[2], "="))
@@ -658,6 +643,32 @@ cmd_logexp_expect(CMD_ARGS)
VTAILQ_INSERT_TAIL(&le->tests, test, list);
}
+static void
+cmd_logexp_expect(CMD_ARGS)
+{
+ struct logexp *le;
+ int skip_max;
+ char *end;
+
+ CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC);
+ if (av[1] == NULL || av[2] == NULL || av[3] == NULL)
+ vtc_fatal(vl, "Syntax error");
+
+ if (av[4] != NULL && av[5] != NULL)
+ vtc_fatal(vl, "Syntax error");
+
+ if (!strcmp(av[1], "*"))
+ skip_max = LE_ANY;
+ else if (!strcmp(av[1], "?"))
+ skip_max = LE_ALT;
+ else {
+ skip_max = (int)strtol(av[1], &end, 10);
+ if (*end != '\0' || skip_max < 0)
+ vtc_fatal(vl, "Not a positive integer: '%s'", av[1]);
+ }
+ cmd_logexp_common(le, vl, skip_max, av);
+}
+
static void
logexp_spec(struct logexp *le, const char *spec)
{
More information about the varnish-commit
mailing list