sys-libs/libnih: Fix 1/2 broken tests
authorAndreas Sturmlechner <asturm@gentoo.org>
Wed, 20 May 2020 16:55:29 +0000 (18:55 +0200)
committerAndreas Sturmlechner <asturm@gentoo.org>
Wed, 20 May 2020 17:42:48 +0000 (19:42 +0200)
Bug: https://bugs.gentoo.org/623930
Package-Manager: Portage-2.3.99, Repoman-2.3.22
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
sys-libs/libnih/files/libnih-1.0.3-expat-2.2.5.patch [new file with mode: 0644]
sys-libs/libnih/files/libnih-1.0.3-glibc-2.24.patch [new file with mode: 0644]
sys-libs/libnih/libnih-1.0.3-r4.ebuild

diff --git a/sys-libs/libnih/files/libnih-1.0.3-expat-2.2.5.patch b/sys-libs/libnih/files/libnih-1.0.3-expat-2.2.5.patch
new file mode 100644 (file)
index 0000000..02b5e4c
--- /dev/null
@@ -0,0 +1,15 @@
+Description: Adapt test suite to expat 2.2.5
+Author: Axel Beckert <abe@debian.org>
+Bug-Debian: https://bugs.debian.org/886416
+
+--- a/nih-dbus-tool/tests/test_parse.c
++++ b/nih-dbus-tool/tests/test_parse.c
+@@ -7950,7 +7950,7 @@
+               TEST_EQ_P (node, NULL);
+-              TEST_FILE_EQ (output, ("test:foo:2:0: "
++              TEST_FILE_EQ (output, ("test:foo:1:36: "
+                                      "Invalid object path in <node> name attribute\n"));
+               TEST_FILE_END (output);
+               TEST_FILE_RESET (output);
diff --git a/sys-libs/libnih/files/libnih-1.0.3-glibc-2.24.patch b/sys-libs/libnih/files/libnih-1.0.3-glibc-2.24.patch
new file mode 100644 (file)
index 0000000..9b90f35
--- /dev/null
@@ -0,0 +1,57 @@
+With glibc >= 2.24, raise() temporarily blocks signals to make this
+function async-signal-safe. This has the consequence that the SIGCONT
+signal send by the call to PTRACE_CONT is delivered slightly later. In
+turn it means the next ptrace event received is the SIGCONT signal
+instead of the expected one.
+
+Unfortunately the libnih testsuite has very precise expectations, and
+do not expect such an event. Fix that by catching it and waiting for the
+following event.
+
+--- libnih-1.0.3.orig/nih/tests/test_child.c
++++ libnih-1.0.3/nih/tests/test_child.c
+@@ -360,6 +360,14 @@ test_poll (void)
+       waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      /* ptrace might catch the SIGCONT emitted with PTRACE_CONT, catch it 
++         and wait for the next event.
++       */
++      if (siginfo.si_code == CLD_TRAPPED && siginfo.si_status == SIGCONT) {
++              assert0 (ptrace (PTRACE_CONT, pid, NULL, NULL));
++              waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      }
++
+       watch = nih_child_add_watch (NULL, pid, NIH_CHILD_TRAPPED,
+                                    my_handler, &watch);
+@@ -420,6 +428,14 @@ test_poll (void)
+       /* Wait for ptrace to stop the parent (signalling the fork) */
+       waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      /* ptrace might catch the SIGCONT emitted with PTRACE_CONT, catch it
++         and wait for the next event.
++       */
++      if (siginfo.si_code == CLD_TRAPPED && siginfo.si_status == SIGCONT) {
++              assert0 (ptrace (PTRACE_CONT, pid, NULL, NULL));
++              waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      }
++
+       /* Will be able to get the child pid now, we have to do it here
+        * because we want to wait on it to ensure the test is synchronous;
+        * otherwise nih_child_poll() could actually eat the child event
+@@ -489,6 +505,14 @@ test_poll (void)
+       waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      /* ptrace might catch the SIGCONT emitted with PTRACE_CONT, catch it
++         and wait for the next event.
++       */
++      if (siginfo.si_code == CLD_TRAPPED && siginfo.si_status == SIGCONT) {
++              assert0 (ptrace (PTRACE_CONT, pid, NULL, NULL));
++              waitid (P_PID, pid, &siginfo, WSTOPPED | WNOWAIT);
++      }
++
+       watch = nih_child_add_watch (NULL, pid, NIH_CHILD_PTRACE,
+                                    my_handler, &watch);
index fae185404cc480fab5118ff472c6ac51940e6e3b..e66de55d937977b8c50d11422208f5dd8005bdfd 100644 (file)
@@ -23,10 +23,12 @@ DEPEND="${RDEPEND}
        sys-devel/gettext
        virtual/pkgconfig"
 PATCHES=(
-       "${FILESDIR}"/${PN}-1.0.3-optional-dbus.patch
-       "${FILESDIR}"/${PN}-1.0.3-pkg-config.patch
-       "${FILESDIR}"/${PN}-1.0.3-signal-race.patch
-       "${FILESDIR}"/${PN}-1.0.3-fno-common.patch
+       "${FILESDIR}"/${P}-optional-dbus.patch
+       "${FILESDIR}"/${P}-pkg-config.patch
+       "${FILESDIR}"/${P}-signal-race.patch
+       "${FILESDIR}"/${P}-fno-common.patch
+       "${FILESDIR}"/${P}-expat-2.2.5.patch
+       "${FILESDIR}"/${P}-glibc-2.24.patch
 )
 
 src_prepare() {