From: Frantisek Sumsal Date: Thu, 21 Oct 2021 15:34:43 +0000 (+0200) Subject: test: loosen certain sandbox restrictions when collecting coverage X-Git-Tag: v250-rc1~454^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c9efba67715cd1ced170ac46c04d47934ad276a;p=thirdparty%2Fsystemd.git test: loosen certain sandbox restrictions when collecting coverage With `ProtectSystem=strict` gcov is unable to write the *.gcda files with collected coverage. Let's add a yet another switch to make such restriction less strict to make gcov happy. This addresses following errors: ``` ... systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/binfmt-util.c.gcda:Cannot open systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/base-filesystem.c.gcda:Cannot open systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/barrier.c.gcda:Cannot open systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/ask-password-api.c.gcda:Cannot open systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/apparmor-util.c.gcda:Cannot open systemd-networkd[272469]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-249.a.p/acpi-fpdt.c.gcda:Cannot open ... ``` --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 4a358edcd27..aa810170724 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -43,6 +43,7 @@ env = {} asan_options=None lsan_options=None ubsan_options=None +with_coverage=False running_units = [] @@ -305,6 +306,8 @@ def setUpModule(): drop_in += ['SystemCallFilter='] if use_valgrind or asan_options or lsan_options or ubsan_options: drop_in += ['MemoryDenyWriteExecute=no'] + if with_coverage: + drop_in += ['ProtectSystem=no'] os.makedirs('/run/systemd/system/systemd-networkd.service.d', exist_ok=True) with open('/run/systemd/system/systemd-networkd.service.d/00-override.conf', mode='w') as f: @@ -331,6 +334,8 @@ def setUpModule(): drop_in += ['SystemCallFilter='] if use_valgrind or asan_options or lsan_options or ubsan_options: drop_in += ['MemoryDenyWriteExecute=no'] + if with_coverage: + drop_in += ['ProtectSystem=no'] os.makedirs('/run/systemd/system/systemd-resolved.service.d', exist_ok=True) with open('/run/systemd/system/systemd-resolved.service.d/00-override.conf', mode='w') as f: @@ -5037,6 +5042,7 @@ if __name__ == '__main__': parser.add_argument('--asan-options', help='ASAN options', dest='asan_options') parser.add_argument('--lsan-options', help='LSAN options', dest='lsan_options') parser.add_argument('--ubsan-options', help='UBSAN options', dest='ubsan_options') + parser.add_argument('--with-coverage', help='Loosen certain sandbox restrictions to make gcov happy', dest='with_coverage', type=bool, nargs='?', const=True, default=with_coverage) ns, args = parser.parse_known_args(namespace=unittest) if ns.build_dir: @@ -5070,6 +5076,7 @@ if __name__ == '__main__': asan_options = ns.asan_options lsan_options = ns.lsan_options ubsan_options = ns.ubsan_options + with_coverage = ns.with_coverage if use_valgrind: networkctl_cmd = ['valgrind', '--track-origins=yes', '--leak-check=full', '--show-leak-kinds=all', networkctl_bin]