mirror of
https://gitlab.com/gnuwget/wget2.git
synced 2026-02-01 14:41:08 +00:00
* Makefile.am: Fix make target 'fuzz-coverage' * configure.ac: Enable building static library by default, add option --enable-fuzzing * fuzz/Makefile.am: Add wget_options_fuzzer, check for FUZZING (set with --enable-fuzzing) * fuzz/README.md: Amend the text * fuzz/main.c: Use printf() instead of wget_info_printf() * fuzz/run-clang.sh: Use fuzzer binaries built by 'make' * fuzz/wget_options_fuzzer.c: New fuzzer * fuzz/wget_options_fuzzer.dict: New fuzzer dictionary * fuzz/wget_options_fuzzer.in/*: Initial fuzz corpora * libwget/net.c: Skip IP address resolution when fuzzing * src/log.c: Don't create files when fuzzing, don't print to console when fuzzing * src/options.c: Add set_exit_status() and get_exit_status(), don't print --help / --version to console when fuzzing, do not call exit() - return error instead, fix recursion level in _read_config(), don't create files when fuzzing, fix memory leaks in deinit() * src/stats.c: Don't create files when fuzzing * src/wget.c: Remove set_exit_status() * src/wget_main.h: Remove exit_status_t * src/wget_options.h: Add exit_status_t * tests/test-plugin.c: Fix expected exit codes from 1 to 2 This is for application fuzzing (namely code from src/). The code in src/ had to be prepared in certain ways, but it doesn't add significant overhead, even makes the code cleaner in some ways. Several of these changes have already been committed into the master branch.
69 lines
2.6 KiB
Makefile
69 lines
2.6 KiB
Makefile
# got some hints from https://gitorious.org/openismus-playground/examplelib/source
|
|
|
|
if HAVE_PO
|
|
SUBDIRS = po
|
|
else
|
|
SUBDIRS =
|
|
endif
|
|
|
|
SUBDIRS += lib include libwget examples src data $(LIBWGET_DOCS) fuzz unit-tests
|
|
|
|
if WITH_MICROHTTPD
|
|
SUBDIRS += tests
|
|
endif
|
|
|
|
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
|
|
|
## Install the generated pkg-config file (.pc) into the expected location for
|
|
## architecture-dependent package configuration information. Occasionally,
|
|
## pkg-config files are also used for architecture-independent data packages,
|
|
## in which case the correct install location would be $(datadir)/pkgconfig.
|
|
pkgconfigdir = $(libdir)/pkgconfig
|
|
pkgconfig_DATA = libwget.pc
|
|
|
|
EXTRA_DIST = cfg.mk build-aux/config.rpath m4/gnulib-cache.m4
|
|
|
|
dist-hook: gen-ChangeLog
|
|
|
|
.PHONY: gen-ChangeLog check-valgrind
|
|
|
|
gen-ChangeLog:
|
|
$(AM_V_GEN)if test -d .git; then \
|
|
git log --no-merges --date=short \
|
|
--pretty='format:%ad %an <%ae>%w(0,0,5)%+B' | sed '/^[1-9].*/G' \
|
|
> $(distdir)/ChangeLog; \
|
|
fi
|
|
|
|
check-valgrind:
|
|
TESTS_ENVIRONMENT="VALGRIND_TESTS=1" $(MAKE) check
|
|
|
|
clean-lcov:
|
|
rm -rf wget2.info */*.gc?? */.libs/*.gc?? lcov/
|
|
lcov --zerocounters --directory src/ --directory libwget/
|
|
|
|
LCOV_INFO=wget2.info
|
|
check-coverage: clean clean-lcov
|
|
$(MAKE) CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
|
|
lcov --capture --initial --directory src/ --directory libwget/.libs --output-file $(LCOV_INFO)
|
|
$(MAKE) CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage" VALGRIND_TESTS=0 check
|
|
lcov --capture --directory src/ --directory libwget/.libs --output-file $(LCOV_INFO)
|
|
lcov --remove $(LCOV_INFO) '*/test_linking.c' '*/css_tokenizer.lex' -o $(LCOV_INFO)
|
|
genhtml --prefix . --ignore-errors source $(LCOV_INFO) --legend --title "Wget2" --output-directory=lcov
|
|
@echo
|
|
@echo "You can now view the coverage report with 'xdg-open lcov/index.html'"
|
|
|
|
fuzz-coverage: clean clean-lcov
|
|
$(MAKE) -C lib
|
|
$(MAKE) -C libwget CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
|
|
$(MAKE) -C src CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
|
|
$(MAKE) -C fuzz check CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
|
|
lcov --capture --initial --directory libwget/.libs --directory fuzz --directory src --output-file $(LCOV_INFO)
|
|
lcov --capture --directory libwget/.libs --directory fuzz --directory src --output-file $(LCOV_INFO)
|
|
lcov --remove $(LCOV_INFO) '*/test_linking.c' '*/css_tokenizer.lex' -o $(LCOV_INFO)
|
|
genhtml --prefix . --ignore-errors source $(LCOV_INFO) --legend --title "Wget2-fuzz" --output-directory=lcov
|
|
@echo
|
|
@echo "You can now view the coverage report with 'xdg-open lcov/index.html'"
|
|
|
|
check-local:
|
|
$(MAKE) -s syntax-check >/dev/null
|