Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
1d5b03eb
Commit
1d5b03eb
authored
Mar 27, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve vtc_wait4() so it can also handle vtc_process' needs.
parent
5823ee99
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
48 deletions
+31
-48
vtc.h
bin/varnishtest/vtc.h
+1
-1
vtc_process.c
bin/varnishtest/vtc_process.c
+3
-35
vtc_subr.c
bin/varnishtest/vtc_subr.c
+26
-11
vtc_varnish.c
bin/varnishtest/vtc_varnish.c
+1
-1
No files found.
bin/varnishtest/vtc.h
View file @
1d5b03eb
...
@@ -138,7 +138,7 @@ void b64_settings(const struct http *hp, const char *s);
...
@@ -138,7 +138,7 @@ void b64_settings(const struct http *hp, const char *s);
struct
vsb
*
vtc_hex_to_bin
(
struct
vtclog
*
vl
,
const
char
*
arg
);
struct
vsb
*
vtc_hex_to_bin
(
struct
vtclog
*
vl
,
const
char
*
arg
);
void
vtc_expect
(
struct
vtclog
*
,
const
char
*
,
const
char
*
,
const
char
*
,
void
vtc_expect
(
struct
vtclog
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
);
const
char
*
,
const
char
*
);
void
vtc_wait4
(
struct
vtclog
*
,
long
,
int
,
int
);
void
vtc_wait4
(
struct
vtclog
*
,
long
,
int
,
int
,
int
);
/* vtc_term.c */
/* vtc_term.c */
struct
term
*
Term_New
(
struct
vtclog
*
,
int
,
int
);
struct
term
*
Term_New
(
struct
vtclog
*
,
int
,
int
);
...
...
bin/varnishtest/vtc_process.c
View file @
1d5b03eb
...
@@ -32,8 +32,6 @@
...
@@ -32,8 +32,6 @@
#include "config.h"
#include "config.h"
#include <sys/ioctl.h> // Linux: struct winsize
#include <sys/ioctl.h> // Linux: struct winsize
#include <sys/resource.h>
#include <sys/wait.h>
#include <ctype.h>
#include <ctype.h>
#include <errno.h>
#include <errno.h>
...
@@ -85,7 +83,6 @@ struct process {
...
@@ -85,7 +83,6 @@ struct process {
pthread_mutex_t
mtx
;
pthread_mutex_t
mtx
;
pthread_t
tp
;
pthread_t
tp
;
unsigned
hasthread
;
unsigned
hasthread
;
int
status
;
struct
term
*
term
;
struct
term
*
term
;
int
lin
;
int
lin
;
...
@@ -247,10 +244,9 @@ static void *
...
@@ -247,10 +244,9 @@ static void *
process_thread
(
void
*
priv
)
process_thread
(
void
*
priv
)
{
{
struct
process
*
p
;
struct
process
*
p
;
struct
rusage
ru
;
struct
vev_root
*
evb
;
struct
vev_root
*
evb
;
struct
vev
*
ev
;
struct
vev
*
ev
;
int
core
,
sig
,
ext
,
r
;
int
r
;
CAST_OBJ_NOTNULL
(
p
,
priv
,
PROCESS_MAGIC
);
CAST_OBJ_NOTNULL
(
p
,
priv
,
PROCESS_MAGIC
);
...
@@ -293,8 +289,8 @@ process_thread(void *priv)
...
@@ -293,8 +289,8 @@ process_thread(void *priv)
vtc_fatal
(
p
->
vl
,
"VEV_Once() = %d, error %s"
,
r
,
vtc_fatal
(
p
->
vl
,
"VEV_Once() = %d, error %s"
,
r
,
strerror
(
errno
));
strerror
(
errno
));
r
=
wait4
(
p
->
pid
,
&
p
->
status
,
0
,
&
ru
);
vtc_wait4
(
p
->
vl
,
p
->
pid
,
p
->
expect_exit
,
p
->
expect_signal
,
p
->
allow_core
);
closefd
(
&
p
->
f_stdout
);
closefd
(
&
p
->
f_stdout
);
closefd
(
&
p
->
f_stderr
);
closefd
(
&
p
->
f_stderr
);
...
@@ -304,35 +300,7 @@ process_thread(void *priv)
...
@@ -304,35 +300,7 @@ process_thread(void *priv)
macro_undef
(
p
->
vl
,
p
->
name
,
"pid"
);
macro_undef
(
p
->
vl
,
p
->
name
,
"pid"
);
p
->
pid
=
-
1
;
p
->
pid
=
-
1
;
vtc_log
(
p
->
vl
,
2
,
"R 0x%04x Status: %04x (u %.6f s %.6f)"
,
r
,
p
->
status
,
ru
.
ru_utime
.
tv_sec
+
1e-6
*
ru
.
ru_utime
.
tv_usec
,
ru
.
ru_stime
.
tv_sec
+
1e-6
*
ru
.
ru_stime
.
tv_usec
);
AZ
(
pthread_mutex_unlock
(
&
p
->
mtx
));
AZ
(
pthread_mutex_unlock
(
&
p
->
mtx
));
sig
=
WTERMSIG
(
p
->
status
);
ext
=
WEXITSTATUS
(
p
->
status
);
#ifdef WCOREDUMP
core
=
WCOREDUMP
(
p
->
status
);
vtc_log
(
p
->
vl
,
2
,
"Exit code: %04x sig %d exit %d core %d"
,
p
->
status
,
sig
,
ext
,
core
);
#else
core
=
0
;
vtc_log
(
p
->
vl
,
2
,
"Exit code: %04x sig %d exit %d"
,
p
->
status
,
sig
,
ext
);
#endif
if
(
core
&&
!
p
->
allow_core
)
vtc_fatal
(
p
->
vl
,
"Core dump"
);
if
(
p
->
expect_signal
>=
0
&&
sig
!=
p
->
expect_signal
)
vtc_fatal
(
p
->
vl
,
"Expected signal %d got %d"
,
p
->
expect_signal
,
sig
);
else
if
(
sig
!=
0
&&
sig
!=
-
p
->
expect_signal
)
vtc_fatal
(
p
->
vl
,
"Expected signal %d got %d"
,
-
p
->
expect_signal
,
sig
);
if
(
ext
!=
p
->
expect_exit
)
vtc_fatal
(
p
->
vl
,
"Expected exit %d got %d"
,
p
->
expect_exit
,
ext
);
VEV_Destroy
(
&
evb
);
VEV_Destroy
(
&
evb
);
if
(
p
->
log
==
1
)
{
if
(
p
->
log
==
1
)
{
...
...
bin/varnishtest/vtc_subr.c
View file @
1d5b03eb
...
@@ -132,8 +132,22 @@ vtc_expect(struct vtclog *vl,
...
@@ -132,8 +132,22 @@ vtc_expect(struct vtclog *vl,
olhs
,
lhs
,
cmp
,
rhs
);
olhs
,
lhs
,
cmp
,
rhs
);
}
}
/**********************************************************************
* Wait for a subprocess.
*
* if expect_signal > 0, the process must die on that signal.
* if expect_signal < 0, dying on that signal is allowed, but not required.
* if allow_core > 0, a coredump is allowed, but not required.
* otherwise, the process must die on exit(expect_status)
*/
#ifndef WCOREDUMP
# define WCOREDUMP(s) (-1)
#endif
void
void
vtc_wait4
(
struct
vtclog
*
vl
,
long
pid
,
int
expect_status
,
int
expect_signal
)
vtc_wait4
(
struct
vtclog
*
vl
,
long
pid
,
int
expect_status
,
int
expect_signal
,
int
allow_core
)
{
{
int
status
,
r
;
int
status
,
r
;
struct
rusage
ru
;
struct
rusage
ru
;
...
@@ -148,20 +162,21 @@ vtc_wait4(struct vtclog *vl, long pid, int expect_status, int expect_signal)
...
@@ -148,20 +162,21 @@ vtc_wait4(struct vtclog *vl, long pid, int expect_status, int expect_signal)
ru
.
ru_stime
.
tv_sec
+
1e-6
*
ru
.
ru_stime
.
tv_usec
ru
.
ru_stime
.
tv_sec
+
1e-6
*
ru
.
ru_stime
.
tv_usec
);
);
if
(
WIFEXITED
(
status
)
&&
(
WEXITSTATUS
(
status
)
==
expect_status
))
if
(
WIFEXITED
(
status
)
&&
expect_signal
<=
0
&&
(
WEXITSTATUS
(
status
)
==
expect_status
))
return
;
return
;
if
(
WIFSIGNALED
(
status
)
&&
(
WTERMSIG
(
status
)
==
expect_signal
))
if
(
expect_signal
<
0
)
expect_signal
=
-
expect_signal
;
if
(
WIFSIGNALED
(
status
)
&&
WCOREDUMP
(
status
)
<=
allow_core
&&
WTERMSIG
(
status
)
==
expect_signal
)
return
;
return
;
#ifdef WCOREDUMP
vtc_log
(
vl
,
1
,
"Expected exit: 0x%x signal: %d core: %d"
,
vtc_fatal
(
vl
,
"Bad exit code: 0x%04x exit 0x%x signal %d core %d"
,
expect_status
,
expect_signal
,
allow_core
);
vtc_fatal
(
vl
,
"Bad exit status: 0x%04x exit 0x%x signal %d core %d"
,
status
,
status
,
WEXITSTATUS
(
status
),
WEXITSTATUS
(
status
),
WIFSIGNALED
(
status
)
?
WTERMSIG
(
status
)
:
0
,
WIFSIGNALED
(
status
)
?
WTERMSIG
(
status
)
:
0
,
WCOREDUMP
(
status
));
WCOREDUMP
(
status
));
#else
vtc_fatal
(
vl
,
"Bad exit code: 0x%04x exit 0x%x signal %d"
,
status
,
WEXITSTATUS
(
status
),
WIFSIGNALED
(
status
)
?
WTERMSIG
(
status
)
:
0
);
#endif
}
}
bin/varnishtest/vtc_varnish.c
View file @
1d5b03eb
...
@@ -647,7 +647,7 @@ varnish_cleanup(struct varnish *v)
...
@@ -647,7 +647,7 @@ varnish_cleanup(struct varnish *v)
/* Pick up the VSL thread */
/* Pick up the VSL thread */
AZ
(
pthread_join
(
v
->
tp_vsl
,
&
p
));
AZ
(
pthread_join
(
v
->
tp_vsl
,
&
p
));
vtc_wait4
(
v
->
vl
,
v
->
pid
,
v
->
expect_exit
,
0
);
vtc_wait4
(
v
->
vl
,
v
->
pid
,
v
->
expect_exit
,
0
,
0
);
v
->
pid
=
0
;
v
->
pid
=
0
;
}
}
...
...
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