Commit b7de3a9d authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Allow multiple -q options for VUTs

This makes the following queries equivalent:

    vut -g request -q '*Error' -q 'BerespStatus >= 500'

    vut -g request -q '
        *Error
        BerespStatus >= 500
    '

    vut -g request -q '(*Error) or (BerespStatus >= 500)'

We now have two ways to express "compound" VSL queries, although this
ultimately relies on multiline queries.
parent c061b8eb
......@@ -89,3 +89,8 @@ shell -match "^500 503 $" {
RespStatus == 503 # query 2
'
}
shell -match "^500 503 $" {
# multiple -q options
./ncsa.sh -q 'RespStatus == 500' -q 'RespStatus == 503'
}
......@@ -75,7 +75,9 @@
#define VUT_OPT_q \
VOPT("q:", "[-q <query>]", "VSL query", \
"Specifies the VSL query to use." \
"Specifies the VSL query to use. When multiple -q" \
" options are specified, all queries are considered" \
" as if the 'or' operator was used to combine them." \
)
#define VUT_OPT_r \
......
......@@ -50,6 +50,7 @@
#include "vas.h"
#include "miniobj.h"
#include "vcs.h"
#include "vsb.h"
#include "vut.h"
......@@ -126,6 +127,30 @@ VUT_Error(struct VUT *vut, int status, const char *fmt, ...)
exit(status);
}
static void
vut_arg_q(struct VUT *vut, const char *arg)
{
struct vsb *vsb;
char *s;
AN(arg);
if (vut->q_arg == NULL) {
REPLACE(vut->q_arg, arg);
return;
}
vsb = VSB_new_auto();
AN(vsb);
AZ(VSB_printf(vsb, "%s\n%s", vut->q_arg, arg));
AZ(VSB_finish(vsb));
s = strdup(VSB_data(vsb));
REPLACE(vut->q_arg, s);
VSB_clear(vsb);
VSB_destroy(&vsb);
}
int
VUT_Arg(struct VUT *vut, int opt, const char *arg)
{
......@@ -169,8 +194,7 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg)
return (1);
case 'q':
/* Query to use */
AN(arg);
REPLACE(vut->q_arg, arg);
vut_arg_q(vut, arg);
return (1);
case 'r':
/* Binary file input */
......
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