From 2f6afc99d596e831445890ef4268e74c1085cbf2 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Fri, 16 Jan 2026 11:17:29 -0500 Subject: [PATCH] gcov testing --- Makefile | 2 +- mkgcov.sh | 6 ++++-- src/firejail/x11.c | 12 ++++++++++++ test/apparmor/apparmor.sh | 3 +++ test/appimage/appimage.sh | 3 +++ test/apps/apps.sh | 3 +++ test/capabilities/capabilities.sh | 3 +++ test/chroot/chroot.sh | 3 +++ test/environment/environment.sh | 3 +++ test/fcopy/fcopy.sh | 5 +++++ test/filters/filters.sh | 3 +++ test/firecfg/firecfg.sh | 4 +++- test/fnetfilter/fnetfilter.sh | 3 +++ test/fnettrace/fnettrace.sh | 2 ++ test/fs/fs.sh | 3 +++ test/network/network.sh | 3 +++ test/private-etc/private-etc.sh | 3 +++ test/profiles/profiles.sh | 3 ++- test/seccomp-extra/seccomp-extra.sh | 3 +++ test/sysutils/sysutils.sh | 3 +++ test/utils/utils.sh | 3 +++ 21 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 119cfd9d9..9fe930a80 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,7 @@ clean: .PHONY: distclean distclean: clean - $(RM) -r autom4te.cache config.log config.mk config.sh config.status test/fnetfilter/outfile test/fnettrace/index.html test/chroot/unchroot + $(RM) -r autom4te.cache config.log config.mk config.sh config.status test/fnetfilter/outfile test/fnettrace/index.html test/chroot/unchroot test/fcopy/src/dircopy.exp .PHONY: install install: all config.mk diff --git a/mkgcov.sh b/mkgcov.sh index f51d4c435..48608e0b9 100755 --- a/mkgcov.sh +++ b/mkgcov.sh @@ -12,9 +12,11 @@ # run as regular user: ./gcov.sh # result in gcov-dir/index.html +echo +echo "checking gcov data" +echo - -if test -f ../../src/firejail/main.gcno; then +if test -f src/firejail/main.gcno; then rm -fr gcov-dir sleep 1 mkdir gcov-dir diff --git a/src/firejail/x11.c b/src/firejail/x11.c index 094d3ad60..c0a501d93 100644 --- a/src/firejail/x11.c +++ b/src/firejail/x11.c @@ -18,6 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "firejail.h" +#include "../include/gcov_wrapper.h" #include #include #include @@ -75,6 +76,7 @@ int x11_display(void) { if (arg_debug) fprintf(stderr, "DISPLAY=%s parsed as %lu\n", display_str, display); + __gcov_flush(); return (int)display; } @@ -116,6 +118,8 @@ static int x11_abstract_sockets_present(void) { free(linebuf); fclose(fp); + + __gcov_flush(); return found; } @@ -196,6 +200,8 @@ static int random_display_number(void) { "exiting...\n", stderr); exit(1); } + + __gcov_flush(); return display; } #endif @@ -397,6 +403,7 @@ void x11_start_xvfb(int argc, char **argv) { // jail process ends and releases terminal wait(NULL); // fulneral + __gcov_flush(); exit(0); } @@ -640,6 +647,7 @@ void x11_start_xephyr(int argc, char **argv) { // jail process ends and releases terminal wait(NULL); // fulneral + __gcov_flush(); exit(0); } @@ -697,6 +705,7 @@ static char * get_title_arg_str() { strcpy(title_arg_str, title_start); } + __gcov_flush(); return title_arg_str; } @@ -1074,6 +1083,7 @@ static void __attribute__((noreturn)) x11_start_xpra_new(int argc, char **argv, } // start + __gcov_flush(); server = fork(); if (server < 0) errExit("fork"); @@ -1139,6 +1149,7 @@ void x11_start_xpra(int argc, char **argv) { x11_start_xpra_new(argc, argv, display_str); else x11_start_xpra_old(argc, argv, display, display_str); + __gcov_flush(); } @@ -1166,6 +1177,7 @@ void x11_start(int argc, char **argv) { fprintf(stderr, " Fedora: sudo dnf install xorg-x11-server-Xephyr\n"); exit(0); } + __gcov_flush(); } #endif diff --git a/test/apparmor/apparmor.sh b/test/apparmor/apparmor.sh index 019e6796b..356624d0b 100755 --- a/test/apparmor/apparmor.sh +++ b/test/apparmor/apparmor.sh @@ -33,3 +33,6 @@ if [[ -f /sys/kernel/security/apparmor/profiles ]]; then else echo "TESTING SKIP: no apparmor support in Linux kernel (test/filters/apparmor.exp)" fi + +cd ../../ +./mkgcov.sh diff --git a/test/appimage/appimage.sh b/test/appimage/appimage.sh index ecbc6bd3c..f3d810fc0 100755 --- a/test/appimage/appimage.sh +++ b/test/appimage/appimage.sh @@ -18,3 +18,6 @@ echo "TESTING: AppImage args (test/appimage/appimage-args.exp)" echo "TESTING: AppImage trace (test/appimage/appimage-trace.exp)" ./appimage-trace.exp + +cd ../../ +./mkgcov.sh diff --git a/test/apps/apps.sh b/test/apps/apps.sh index cb8f6179f..0e3fb152a 100755 --- a/test/apps/apps.sh +++ b/test/apps/apps.sh @@ -20,3 +20,6 @@ for app in "${apps[@]}"; do fi sleep 1 done + +cd ../../ +./mkgcov.sh diff --git a/test/capabilities/capabilities.sh b/test/capabilities/capabilities.sh index 13a02a811..8bdf7a7bb 100755 --- a/test/capabilities/capabilities.sh +++ b/test/capabilities/capabilities.sh @@ -23,3 +23,6 @@ echo "TESTING: capabilities join (test/filters/caps-join.exp)" echo "TESTING: firemon caps (test/utils/firemon-caps.exp)" ./firemon-caps.exp + +cd ../../ +./mkgcov.sh diff --git a/test/chroot/chroot.sh b/test/chroot/chroot.sh index f1c534fbc..82210541a 100755 --- a/test/chroot/chroot.sh +++ b/test/chroot/chroot.sh @@ -25,3 +25,6 @@ echo "TESTING: unchroot as root (test/chroot/unchroot-as-root.exp)" sudo ./unchroot-as-root.exp rm -f unchroot + +cd ../../ +./mkgcov.sh diff --git a/test/environment/environment.sh b/test/environment/environment.sh index 756554380..a92a5e0f2 100755 --- a/test/environment/environment.sh +++ b/test/environment/environment.sh @@ -101,3 +101,6 @@ echo "TESTING: keep fd errors (test/environment/keep-fd-bad.exp)" echo "TESTING: retain umask (test/environment/umask.exp)" (umask 123 && ./umask.exp) + +cd ../../ +./mkgcov.sh diff --git a/test/fcopy/fcopy.sh b/test/fcopy/fcopy.sh index a5cf58891..127054767 100755 --- a/test/fcopy/fcopy.sh +++ b/test/fcopy/fcopy.sh @@ -30,3 +30,8 @@ echo "TESTING: fcopy directory (test/fcopy/dircopy.exp)" rm -fr dest/* rm -f src/dircopy.exp + +cd ../.. +./mkgcov.sh + + diff --git a/test/filters/filters.sh b/test/filters/filters.sh index e91f0da75..08ad0c6bf 100755 --- a/test/filters/filters.sh +++ b/test/filters/filters.sh @@ -134,3 +134,6 @@ if [[ $(uname -m) == "x86_64" ]]; then else echo "TESTING SKIP: seccomp join test implemented only for x86_64" fi + +cd ../../ +./mkgcov.sh diff --git a/test/firecfg/firecfg.sh b/test/firecfg/firecfg.sh index d5cb348fb..41c5f51fb 100755 --- a/test/firecfg/firecfg.sh +++ b/test/firecfg/firecfg.sh @@ -15,4 +15,6 @@ echo "TESTING: firecfg (test/firecfg/firecfg.exp)" ./firecfg.exp sudo rm -fr /tmp/ttt -../../mkgcov.sh + +cd ../../ +./mkgcov.sh diff --git a/test/fnetfilter/fnetfilter.sh b/test/fnetfilter/fnetfilter.sh index 24745e5d5..e0c05f237 100755 --- a/test/fnetfilter/fnetfilter.sh +++ b/test/fnetfilter/fnetfilter.sh @@ -29,3 +29,6 @@ echo "TESTING: fnetfilter template (test/fnetfilter/template.exp)" ./template.exp rm -f outfile + +cd ../../ +./mkgcov.sh diff --git a/test/fnettrace/fnettrace.sh b/test/fnettrace/fnettrace.sh index 6ea6e695c..b67129f21 100755 --- a/test/fnettrace/fnettrace.sh +++ b/test/fnettrace/fnettrace.sh @@ -57,3 +57,5 @@ echo "TESTING: fnettrace-check-root (test/nettrace/fnettrace-check-root.exp)" #rm -f /tmp/output #echo "all done" +cd ../../ +./mkgcov.sh diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 7af1b01a3..3fa3e1404 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -162,3 +162,6 @@ echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)" #cleanup rm -fr ~/_firejail_test* + +cd ../../ +./mkgcov.sh diff --git a/test/network/network.sh b/test/network/network.sh index f6dfe5ce2..0098b88ec 100755 --- a/test/network/network.sh +++ b/test/network/network.sh @@ -62,3 +62,6 @@ echo "TESTING: netfilter-template (netfilter-template.exp)" sudo ip link set br0 down sudo brctl delbr br0 + +cd ../../ +./mkgcov.sh diff --git a/test/private-etc/private-etc.sh b/test/private-etc/private-etc.sh index 7cebe3dfa..ae657ab7f 100755 --- a/test/private-etc/private-etc.sh +++ b/test/private-etc/private-etc.sh @@ -21,3 +21,6 @@ echo "TESTING: etc-cleanup (test/private-etc/etc-cleanup.exp)" echo "TESTING: hostname (test/private-etc/hostname.exp)" ./hostname.exp + +cd ../../ +./mkgcov.sh diff --git a/test/profiles/profiles.sh b/test/profiles/profiles.sh index cdc2871f6..c695f5d17 100755 --- a/test/profiles/profiles.sh +++ b/test/profiles/profiles.sh @@ -58,4 +58,5 @@ do ./test-profile.exp "$profile" done -../../mkgcov.sh +cd ../../ +./mkgcov.sh diff --git a/test/seccomp-extra/seccomp-extra.sh b/test/seccomp-extra/seccomp-extra.sh index a1b3a8361..d0050a416 100755 --- a/test/seccomp-extra/seccomp-extra.sh +++ b/test/seccomp-extra/seccomp-extra.sh @@ -24,3 +24,6 @@ echo "TESTING: mrwx2 (test/seccomp-extras/mrwx.exp)" echo "TESTING: block-secondary (test/seccomp-extras/block-secondary.exp)" ./block-secondary.exp + +cd ../../ +./mkgcov.sh diff --git a/test/sysutils/sysutils.sh b/test/sysutils/sysutils.sh index 20847ecf2..a732faea6 100755 --- a/test/sysutils/sysutils.sh +++ b/test/sysutils/sysutils.sh @@ -150,3 +150,6 @@ then else echo "TESTING SKIP: whois not found" fi + +cd ../../ +./mkgcov.sh diff --git a/test/utils/utils.sh b/test/utils/utils.sh index 5238fe3c8..19950b963 100755 --- a/test/utils/utils.sh +++ b/test/utils/utils.sh @@ -135,3 +135,6 @@ echo "TESTING: firemon version (test/utils/firemon-version.exp)" echo "TESTING: firemon name (test/utils/firemon-name.exp)" ./firemon-name.exp + +cd ../../ +./mkgcov.sh