Code Coverage: vinyl-cache/bin/vinyltest/vtest2/src/vtest_api.h
 
82217aa4fc7094b3610340078afaf78cd95a8ec9
 
0
/*-
1
 * Copyright (c) 2008-2011 Varnish Software AS
2
 * All rights reserved.
3
 *
4
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
5
 *
6
 * SPDX-License-Identifier: BSD-2-Clause
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 *
29
 * The stuff extensions should/will need to function
30
 */
31
32
struct vtclog;
33
34
#define VTC_CHECK_NAME(vl, nm, type, chr)                               \
35 10217
        do {                                                            \
36 10217
                AN(nm);                                                 \
37 10217
                if (*(nm) != chr)                                       \
38 10217
                        vtc_fatal(vl,                                   \
39 0
                            type " name must start with '%c' (got %s)", \
40 0
                            chr, nm);                                   \
41 10217
        } while (0)
42
43
#define ARGZ(vl, av, n)                                                 \
44 16473
        do {                                                            \
45 16473
                if ((av)[n] != NULL)                                    \
46 16473
                        vtc_fatal(vl, "Unexpected argument: %s",        \
47 0
                            (av)[n]);                                   \
48 16473
        } while (0)
49
50
#define ARGN(vl, av, n)                                                 \
51 27845
        do {                                                            \
52 27845
                AN(n);                                                  \
53 27845
                if ((av)[n] == NULL)                                    \
54 27845
                        vtc_fatal(vl,                                   \
55 0
                            "Missing argument after: %s",               \
56 0
                            (av)[(n) - 1]);                             \
57 27845
        } while (0)
58
59
#define CMD_ARGS char * const *av, void *priv, struct vtclog *vl
60 17732
#define CMDS_F_NONE             0x0
61 5490
#define CMDS_F_GLOBAL           0x1
62 26928
#define CMDS_F_SHUT             0x2
63
64
typedef void cmd_f(CMD_ARGS);
65
66
struct cmds {
67
        unsigned                magic;
68
#define CMDS_MAGIC              0x9ccc797d
69
        const char              *name;
70
        cmd_f                   *cmd;
71
        unsigned                flags;
72
};
73
74
extern vtim_dur vtc_maxdur;
75
extern int vtc_stop;            /* Abandon current test, no error */
76
extern volatile sig_atomic_t vtc_error; /* Error, bail out */
77
extern int leave_temp;
78
extern const char *default_listen_addr;
79
extern char *vmod_path;
80
extern struct vsb *params_vsb;
81
extern pthread_t vtc_thread;
82
83
void parse_string(struct vtclog *vl, void *priv, const char *spec);
84
85
void add_cmd(const char *name, cmd_f *cmd, unsigned flags);
86
87
void vtc_dump(struct vtclog *vl, int lvl, const char *pfx,
88
    const char *str, int len);
89
90
void vtc_fatal(struct vtclog *vl, const char *, ...)
91
    v_noreturn_ v_printflike_(2,3);
92
93
void vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...)
94
    v_printflike_(3, 4);
95
96
void vtc_log_set_cmd(struct vtclog *vl, const struct cmds *cmds);
97
98
void *vtc_record(struct vtclog *, int, struct vsb *);
99
void vtc_logclose(void *arg);
100
struct vtclog *vtc_logopen(const char *id, ...) v_printflike_(1, 2);
101
void vtc_wait4(struct vtclog *, long, int, int, int);
102
103
void cmd_server_gen_vcl(struct vsb *vsb);
104
105
typedef char* macro_f(int, char *const *, const char **);
106
void extmacro_def(const char *name, macro_f *func, const char *fmt, ...)
107
    v_printflike_(3, 4);
108
109
void macro_undef(struct vtclog *vl, const char *instance, const char *name);
110
void macro_def(struct vtclog *vl, const char *instance, const char *name,
111
    const char *fmt, ...) v_printflike_(4, 5);
112
void macro_cat(struct vtclog *, struct vsb *, const char *, const char *);
113
unsigned macro_isdef(const char *instance, const char *name);
114
struct vsb *macro_expand(struct vtclog *vl, const char *text);
115
struct vsb *macro_expandf(struct vtclog *vl, const char *, ...)
116
    v_printflike_(2, 3);
117
118
enum i_mode_where_e {
119
        top_builddir,
120
        top_srcdir
121
};
122
123
// basically build_path
124
void i_mode_add(enum i_mode_where_e where, const char *subdir, const char *pfx,
125
    const char *sfx);