From a44c00576d2cf6141c24774848b56a8d4e71b7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Rossillol=E2=80=91=E2=80=91Laruelle?= Date: Sun, 18 Aug 2024 15:40:13 +0200 Subject: [PATCH] dev-util/kcov: fix test failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These changes do not affect the installed program. Closes: https://bugs.gentoo.org/937314 Closes: https://bugs.gentoo.org/937315 Signed-off-by: Mattéo Rossillol‑‑Laruelle Closes: https://github.com/gentoo/gentoo/pull/38185 Signed-off-by: Sam James --- ...ailing-test-conflicting-with-sandbox.patch | 51 +++++++++++++++++++ dev-util/kcov/kcov-43.ebuild | 18 ++++--- dev-util/kcov/kcov-9999.ebuild | 18 ++++--- 3 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch diff --git a/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch b/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch new file mode 100644 index 0000000000000..8229d30be52ee --- /dev/null +++ b/dev-util/kcov/files/kcov-remove-failing-test-conflicting-with-sandbox.patch @@ -0,0 +1,51 @@ +From c3c89cfca876b9c56586afc374ea92a7b25998c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Matt=C3=A9o=20Rossillol=E2=80=91=E2=80=91Laruelle?= + +Date: Sun, 18 Aug 2024 15:18:19 +0200 +Subject: [PATCH] remove failing test conflicting with sandbox +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +sys-apps/sandbox is based on `LD_PRELOAD`; however, +`--bash-handle-sh-invocation` uses it too. This option seems to conflict with +the sandbox environment and the associated test fails fails. + +Indeed, according to the Kcov man page, this option handles "invocations of +/bin/sh scripts via using a LD_PRELOADed library that replaces execve (i.e., +/bin/sh is executed as /bin/bash)". + +Signed-off-by: Mattéo Rossillol‑‑Laruelle +--- + tests/tools/test_bash_linux_only.py | 15 --------------- + 1 file changed, 15 deletions(-) + +diff --git a/tests/tools/test_bash_linux_only.py b/tests/tools/test_bash_linux_only.py +index d0a46bb..87022e0 100644 +--- a/tests/tools/test_bash_linux_only.py ++++ b/tests/tools/test_bash_linux_only.py +@@ -2,21 +2,6 @@ import libkcov + from libkcov import cobertura + + +-class bash_sh_shebang(libkcov.TestCase): +- def runTest(self): +- rv, o = self.do( +- self.kcov +- + " --bash-handle-sh-invocation " +- + self.outbase +- + "/kcov " +- + self.sources +- + "/tests/bash/shell-main" +- ) +- +- dom = cobertura.parseFile(self.outbase + "/kcov/shell-main/cobertura.xml") +- assert cobertura.hitsPerLine(dom, "sh-shebang.sh", 4) == 1 +- +- + class bash_exit_before_child(libkcov.TestCase): + def runTest(self): + # kcovKcov shouldn't wait for the background process, so call it with kcovKcov = False +-- +2.44.2 + diff --git a/dev-util/kcov/kcov-43.ebuild b/dev-util/kcov/kcov-43.ebuild index 2c1f929f9a7a9..32f6b0358b923 100644 --- a/dev-util/kcov/kcov-43.ebuild +++ b/dev-util/kcov/kcov-43.ebuild @@ -39,6 +39,10 @@ DEPEND=" BDEPEND="test? ( ${PYTHON_DEPS} )" RDEPEND="${DEPEND}" +PATCHES=( + "${FILESDIR}/${PN}-remove-failing-test-conflicting-with-sandbox.patch" +) + DOCS=( doc/ CONTRIBUTING.md @@ -51,24 +55,26 @@ pkg_setup() { } src_prepare() { - cmake_src_prepare - if use test; then sed -Ei "/skip_python2/ s/= .+/= True/" tests/tools/test_python.py \ - || die + || die "Cannot disable Python 2 tests" - echo "add_subdirectory (tests)" >> CMakeLists.txt || die + cat <<- EOF >> CMakeLists.txt || die "Cannot enable test building" + add_compile_options (-g) + add_subdirectory (tests) + EOF fi + + cmake_src_prepare } src_configure() { local mycmakeargs=( -DKCOV_INSTALL_DOCDIR:PATH="share/doc/${PF}" ) - cmake_src_configure } src_test() { - PYTHONPATH="${S}/tests/tools" edo python3 -m libkcov \ + PYTHONPATH="${S}/tests/tools" edo "${PYTHON}" -m libkcov \ -v \ "${BUILD_DIR}/src/kcov" \ "${T}" \ diff --git a/dev-util/kcov/kcov-9999.ebuild b/dev-util/kcov/kcov-9999.ebuild index 2c1f929f9a7a9..32f6b0358b923 100644 --- a/dev-util/kcov/kcov-9999.ebuild +++ b/dev-util/kcov/kcov-9999.ebuild @@ -39,6 +39,10 @@ DEPEND=" BDEPEND="test? ( ${PYTHON_DEPS} )" RDEPEND="${DEPEND}" +PATCHES=( + "${FILESDIR}/${PN}-remove-failing-test-conflicting-with-sandbox.patch" +) + DOCS=( doc/ CONTRIBUTING.md @@ -51,24 +55,26 @@ pkg_setup() { } src_prepare() { - cmake_src_prepare - if use test; then sed -Ei "/skip_python2/ s/= .+/= True/" tests/tools/test_python.py \ - || die + || die "Cannot disable Python 2 tests" - echo "add_subdirectory (tests)" >> CMakeLists.txt || die + cat <<- EOF >> CMakeLists.txt || die "Cannot enable test building" + add_compile_options (-g) + add_subdirectory (tests) + EOF fi + + cmake_src_prepare } src_configure() { local mycmakeargs=( -DKCOV_INSTALL_DOCDIR:PATH="share/doc/${PF}" ) - cmake_src_configure } src_test() { - PYTHONPATH="${S}/tests/tools" edo python3 -m libkcov \ + PYTHONPATH="${S}/tests/tools" edo "${PYTHON}" -m libkcov \ -v \ "${BUILD_DIR}/src/kcov" \ "${T}" \