Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent3
Commits
230d8f2d
Commit
230d8f2d
authored
May 31, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://git.varnish-cache.org/git/varnish-cache
Conflicts: bin/varnishtest/vtc_varnish.c
parents
01fbdaca
50a77ab0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
34 deletions
+86
-34
Makefile.am
bin/varnishtest/Makefile.am
+1
-1
vtc.c
bin/varnishtest/vtc.c
+63
-10
vtc.h
bin/varnishtest/vtc.h
+3
-9
vtc_main.c
bin/varnishtest/vtc_main.c
+12
-7
vtc_varnish.c
bin/varnishtest/vtc_varnish.c
+2
-2
cli_common.c
lib/libvarnish/cli_common.c
+5
-5
No files found.
bin/varnishtest/Makefile.am
View file @
230d8f2d
...
...
@@ -2,7 +2,7 @@
TESTS_PARALLELISM
=
3
check
:
varnishtest
./varnishtest
-j
$(TESTS_PARALLELISM)
$(srcdir)
/tests/
*
.vtc
./varnishtest
-
i
-
j
$(TESTS_PARALLELISM)
$(srcdir)
/tests/
*
.vtc
@
echo
"==================="
@
echo
"All tests succeeded"
@
echo
"==================="
...
...
bin/varnishtest/vtc.c
View file @
230d8f2d
...
...
@@ -60,6 +60,7 @@ volatile sig_atomic_t vtc_error; /* Error encountered */
int
vtc_stop
;
/* Stops current test without error */
pthread_t
vtc_thread
;
static
struct
vtclog
*
vltop
;
int
in_tree
=
0
;
/* Are we running in-tree */
/**********************************************************************
* Macro facility
...
...
@@ -73,8 +74,6 @@ struct macro {
static
VTAILQ_HEAD
(,
macro
)
macro_list
=
VTAILQ_HEAD_INITIALIZER
(
macro_list
);
struct
_extmacro_list
extmacro_list
=
VTAILQ_HEAD_INITIALIZER
(
extmacro_list
);
static
pthread_mutex_t
macro_mtx
;
static
void
...
...
@@ -192,6 +191,65 @@ macro_expand(struct vtclog *vl, const char *text)
return
(
vsb
);
}
/* extmacro is a list of macro's that are defined from the
command line and are applied to the macro list of each test
instance. No locking is required as they are set before any tests
are started.
*/
struct
extmacro
{
VTAILQ_ENTRY
(
extmacro
)
list
;
char
*
name
;
char
*
val
;
};
static
VTAILQ_HEAD
(,
extmacro
)
extmacro_list
=
VTAILQ_HEAD_INITIALIZER
(
extmacro_list
);
void
extmacro_def
(
const
char
*
name
,
const
char
*
fmt
,
...)
{
char
buf
[
256
];
struct
extmacro
*
m
;
va_list
ap
;
VTAILQ_FOREACH
(
m
,
&
extmacro_list
,
list
)
if
(
!
strcmp
(
name
,
m
->
name
))
break
;
if
(
m
==
NULL
&&
fmt
!=
NULL
)
{
m
=
calloc
(
sizeof
*
m
,
1
);
AN
(
m
);
REPLACE
(
m
->
name
,
name
);
VTAILQ_INSERT_TAIL
(
&
extmacro_list
,
m
,
list
);
}
if
(
fmt
!=
NULL
)
{
AN
(
m
);
va_start
(
ap
,
fmt
);
free
(
m
->
val
);
vbprintf
(
buf
,
fmt
,
ap
);
va_end
(
ap
);
m
->
val
=
strdup
(
buf
);
AN
(
m
->
val
);
}
else
if
(
m
!=
NULL
)
{
VTAILQ_REMOVE
(
&
extmacro_list
,
m
,
list
);
free
(
m
->
name
);
free
(
m
->
val
);
free
(
m
);
}
}
const
char
*
extmacro_get
(
const
char
*
name
)
{
struct
extmacro
*
m
;
VTAILQ_FOREACH
(
m
,
&
extmacro_list
,
list
)
if
(
!
strcmp
(
name
,
m
->
name
))
return
(
m
->
val
);
return
(
NULL
);
}
/**********************************************************************
* Execute a file
*/
...
...
@@ -476,7 +534,6 @@ exec_file(const char *fn, const char *script, const char *tmpdir,
{
unsigned
old_err
;
char
*
cwd
,
*
p
;
char
topbuild
[
BUFSIZ
];
FILE
*
f
;
struct
extmacro
*
m
;
...
...
@@ -491,14 +548,10 @@ exec_file(const char *fn, const char *script, const char *tmpdir,
VTAILQ_FOREACH
(
m
,
&
extmacro_list
,
list
)
macro_def
(
vltop
,
NULL
,
m
->
name
,
m
->
val
);
/*
We are still in bin/varnishtest at this point
*/
/*
Other macro definitions
*/
cwd
=
getcwd
(
NULL
,
PATH_MAX
);
bprintf
(
topbuild
,
"%s/%s"
,
cwd
,
TOP_BUILDDIR
);
macro_def
(
vltop
,
NULL
,
"topbuild"
,
topbuild
);
AN
(
getcwd
(
topbuild
,
sizeof
topbuild
));
macro_def
(
vltop
,
NULL
,
"pwd"
,
topbuild
);
macro_def
(
vltop
,
NULL
,
"pwd"
,
cwd
);
macro_def
(
vltop
,
NULL
,
"topbuild"
,
"%s/%s"
,
cwd
,
TOP_BUILDDIR
);
macro_def
(
vltop
,
NULL
,
"bad_ip"
,
"10.255.255.255"
);
/* Move into our tmpdir */
...
...
bin/varnishtest/vtc.h
View file @
230d8f2d
...
...
@@ -49,15 +49,6 @@ struct cmds {
cmd_f
*
cmd
;
};
struct
extmacro
{
VTAILQ_ENTRY
(
extmacro
)
list
;
char
*
name
;
char
*
val
;
};
VTAILQ_HEAD
(
_extmacro_list
,
extmacro
);
extern
struct
_extmacro_list
extmacro_list
;
void
parse_string
(
char
*
buf
,
const
struct
cmds
*
cmd
,
void
*
priv
,
struct
vtclog
*
vl
);
...
...
@@ -92,3 +83,6 @@ int exec_file(const char *fn, const char *script, const char *tmpdir,
void
macro_def
(
struct
vtclog
*
vl
,
const
char
*
instance
,
const
char
*
name
,
const
char
*
fmt
,
...);
struct
vsb
*
macro_expand
(
struct
vtclog
*
vl
,
const
char
*
text
);
void
extmacro_def
(
const
char
*
name
,
const
char
*
fmt
,
...);
const
char
*
extmacro_get
(
const
char
*
name
);
bin/varnishtest/vtc_main.c
View file @
230d8f2d
...
...
@@ -97,18 +97,13 @@ static int
parse_D_opt
(
char
*
arg
)
{
char
*
p
,
*
q
;
struct
extmacro
*
m
;
p
=
arg
;
q
=
strchr
(
p
,
'='
);
if
(
!
q
)
return
(
0
);
*
q
++
=
'\0'
;
m
=
calloc
(
sizeof
*
m
,
1
);
AN
(
m
);
REPLACE
(
m
->
name
,
p
);
REPLACE
(
m
->
val
,
q
);
VTAILQ_INSERT_TAIL
(
&
extmacro_list
,
m
,
list
);
extmacro_def
(
p
,
"%s"
,
q
);
return
(
1
);
}
...
...
@@ -153,6 +148,7 @@ usage(void)
fprintf
(
stderr
,
"usage: varnishtest [options] file ...
\n
"
);
#define FMT " %-28s # %s\n"
fprintf
(
stderr
,
FMT
,
"-D name=val"
,
"Define macro for use in scripts"
);
fprintf
(
stderr
,
FMT
,
"-i"
,
"Find varnishd in build tree"
);
fprintf
(
stderr
,
FMT
,
"-j jobs"
,
"Run this many tests in parallel"
);
fprintf
(
stderr
,
FMT
,
"-k"
,
"Continue on test failure"
);
fprintf
(
stderr
,
FMT
,
"-l"
,
"Leave /tmp/vtc.* if test fails"
);
...
...
@@ -161,6 +157,9 @@ usage(void)
fprintf
(
stderr
,
FMT
,
"-q"
,
"Quiet mode: report only failues"
);
fprintf
(
stderr
,
FMT
,
"-t duration"
,
"Time tests out after this long"
);
fprintf
(
stderr
,
FMT
,
"-v"
,
"Verbose mode: always report test log"
);
fprintf
(
stderr
,
"
\n
"
);
fprintf
(
stderr
,
" Overridable macro definitions:
\n
"
);
fprintf
(
stderr
,
FMT
,
"varnishd"
,
"Path to varnishd to use [varnishd]"
);
exit
(
1
);
}
...
...
@@ -331,9 +330,11 @@ main(int argc, char * const *argv)
struct
vtc_tst
*
tp
;
char
*
p
;
extmacro_def
(
"varnishd"
,
"varnishd"
);
/* Default to path lookup */
setbuf
(
stdout
,
NULL
);
setbuf
(
stderr
,
NULL
);
while
((
ch
=
getopt
(
argc
,
argv
,
"D:j:klLn:qt:v"
))
!=
-
1
)
{
while
((
ch
=
getopt
(
argc
,
argv
,
"D:
i
j:klLn:qt:v"
))
!=
-
1
)
{
switch
(
ch
)
{
case
'D'
:
if
(
!
parse_D_opt
(
optarg
))
{
...
...
@@ -342,6 +343,10 @@ main(int argc, char * const *argv)
exit
(
2
);
}
break
;
case
'i'
:
/* Look for varnishd relative to varnishtest */
extmacro_def
(
"varnishd"
,
"../varnishd/varnishd"
);
break
;
case
'j'
:
npar
=
strtoul
(
optarg
,
NULL
,
0
);
break
;
...
...
bin/varnishtest/vtc_varnish.c
View file @
230d8f2d
...
...
@@ -251,8 +251,8 @@ varnish_launch(struct varnish *v)
vtc_log
(
v
->
vl
,
2
,
"Launch"
);
vsb
=
VSB_new_auto
();
AN
(
vsb
);
VSB_printf
(
vsb
,
"cd ${
topbuild}/bin/varnishd
&&"
);
VSB_printf
(
vsb
,
"
./varnishd
-d -d -n %s"
,
v
->
workdir
);
VSB_printf
(
vsb
,
"cd ${
pwd}
&&"
);
VSB_printf
(
vsb
,
"
${varnishd}
-d -d -n %s"
,
v
->
workdir
);
VSB_printf
(
vsb
,
" -l 10m,1m,-"
);
VSB_printf
(
vsb
,
" -p auto_restart=off"
);
VSB_printf
(
vsb
,
" -p syslog_cli_traffic=off"
);
...
...
lib/libvarnish/cli_common.c
View file @
230d8f2d
...
...
@@ -123,12 +123,12 @@ read_tmo(int fd, char *ptr, unsigned len, double tmo)
pfd
.
fd
=
fd
;
pfd
.
events
=
POLLIN
;
i
=
poll
(
&
pfd
,
1
,
(
int
)(
tmo
*
1e3
));
if
(
i
==
0
)
{
errno
=
ETIMEDOUT
;
return
(
-
1
);
}
for
(
j
=
0
;
len
>
0
;
)
{
i
=
poll
(
&
pfd
,
1
,
(
int
)(
tmo
*
1e3
));
if
(
i
==
0
)
{
errno
=
ETIMEDOUT
;
return
(
-
1
);
}
i
=
read
(
fd
,
ptr
,
len
);
if
(
i
<
0
)
return
(
i
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment