[master] f74d821ad varnishtest: New macro_isdef() function
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Apr 17 20:12:07 UTC 2023
commit f74d821ad6cf770a4726b16af58e80594bca187e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Apr 14 15:22:30 2023 +0200
varnishtest: New macro_isdef() function
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index f4ffeedcc..12647c6ee 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -216,6 +216,26 @@ macro_undef(struct vtclog *vl, const char *instance, const char *name)
AZ(pthread_mutex_unlock(¯o_mtx));
}
+unsigned
+macro_isdef(const char *instance, const char *name)
+{
+ char buf1[256];
+ struct macro *m;
+
+ if (instance != NULL) {
+ bprintf(buf1, "%s_%s", instance, name);
+ name = buf1;
+ }
+
+ AZ(pthread_mutex_lock(¯o_mtx));
+ VTAILQ_FOREACH(m, ¯o_list, list)
+ if (!strcmp(name, m->name))
+ break;
+ AZ(pthread_mutex_unlock(¯o_mtx));
+
+ return (m != NULL);
+}
+
void
macro_cat(struct vtclog *vl, struct vsb *vsb, const char *b, const char *e)
{
diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h
index 0c33f1adf..ab0b8031a 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -132,8 +132,8 @@ int exec_file(const char *fn, const char *script, const char *tmpdir,
void macro_undef(struct vtclog *vl, const char *instance, const char *name);
void macro_def(struct vtclog *vl, const char *instance, const char *name,
- const char *fmt, ...)
- v_printflike_(4, 5);
+ const char *fmt, ...) v_printflike_(4, 5);
+unsigned macro_isdef(const char *instance, const char *name);
void macro_cat(struct vtclog *, struct vsb *, const char *, const char *);
struct vsb *macro_expand(struct vtclog *vl, const char *text);
struct vsb *macro_expandf(struct vtclog *vl, const char *, ...)
More information about the varnish-commit
mailing list