mirror of
https://github.com/mirror/wget.git
synced 2025-03-26 11:42:23 +08:00
Use a LOG_COMPILER for running fuzz tests
This prevents needing a special case in the fuzz tests to detect valgrind usage and a new exec. Instead, we simply detect the environment in a shell script and start the test with valgrind in the first place. * fuzz/test-runner.sh: New script for running the fuzz tests * fuzz/main.c (main): Remove code for re-running under valgrind * fuzz/Makefile.am: Set the LOG_COMPILER to test-runner.sh and remember to add it to the list of extra files for packaging
This commit is contained in:
parent
db4d5b6eb3
commit
cf788d60e4
@ -21,6 +21,8 @@ WGET_TESTS = \
|
||||
wget_robots_fuzzer$(EXEEXT) \
|
||||
wget_url_fuzzer$(EXEEXT)
|
||||
|
||||
EXTRA_DIST = test-runner.sh
|
||||
|
||||
if WITH_NTLM
|
||||
WGET_TESTS += wget_ntlm_fuzzer$(EXEEXT)
|
||||
endif
|
||||
@ -33,6 +35,7 @@ if FUZZING
|
||||
else
|
||||
AM_CPPFLAGS += -DTEST_RUN
|
||||
AM_TESTS_ENVIRONMENT = export VALGRIND_TESTS"=@VALGRIND_TESTS@";
|
||||
LOG_COMPILER = $(top_srcdir)/fuzz/test-runner.sh
|
||||
TESTS = $(WGET_TESTS)
|
||||
check_PROGRAMS = $(WGET_TESTS)
|
||||
MAIN = main.c fuzzer.h
|
||||
|
17
fuzz/main.c
17
fuzz/main.c
@ -68,26 +68,9 @@ static int test_all_from(const char *dirname)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// if VALGRIND testing is enabled, we have to call ourselves with valgrind checking
|
||||
const char *valgrind = getenv("VALGRIND_TESTS");
|
||||
const char *target;
|
||||
size_t target_len;
|
||||
|
||||
if (!valgrind || !*valgrind || !strcmp(valgrind, "0")) {
|
||||
// fallthrough
|
||||
}
|
||||
else if (!strcmp(valgrind, "1")) {
|
||||
char cmd[strlen(argv[0]) + 256];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS=\"\" valgrind --error-exitcode=301 --leak-check=yes --show-reachable=yes --track-origins=yes %s", argv[0]);
|
||||
return system(cmd) != 0;
|
||||
} else {
|
||||
char cmd[strlen(valgrind) + strlen(argv[0]) + 32];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS="" %s %s", valgrind, argv[0]);
|
||||
return system(cmd) != 0;
|
||||
}
|
||||
|
||||
if ((target = strrchr(argv[0], SLASH))) {
|
||||
if (strrchr(target, '/'))
|
||||
target = strrchr(target, '/');
|
||||
|
9
fuzz/test-runner.sh
Executable file
9
fuzz/test-runner.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
WRAPPER=""
|
||||
|
||||
if [ -n "$VALGRIND_TESTS" ]; then
|
||||
WRAPPER="valgrind --error-exitcode=301 --leak-check=yes --show-reachable=yes --track-origins=yes"
|
||||
fi
|
||||
|
||||
exec $WRAPPER "$@"
|
Loading…
Reference in New Issue
Block a user