]> code.ossystems Code Review - openembedded-core.git/commitdiff
ltp: Fix tgkill03 failure
authorHe Zhe <zhe.he@windriver.com>
Mon, 19 Aug 2019 13:56:33 +0000 (21:56 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 21 Aug 2019 12:21:46 +0000 (13:21 +0100)
Backport a patch to fix the followig failure.
tgkill03.c:94: FAIL: Defunct tid should have failed with ESRCH: SUCCESS

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch [new file with mode: 0644]
meta/recipes-extended/ltp/ltp_20190517.bb

diff --git a/meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch b/meta/recipes-extended/ltp/ltp/0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch
new file mode 100644 (file)
index 0000000..6ea2615
--- /dev/null
@@ -0,0 +1,75 @@
+From e747d0456adc080a1d31fb653bda9dc491795c80 Mon Sep 17 00:00:00 2001
+From: Jan Stancek <jstancek@redhat.com>
+Date: Sun, 16 Jun 2019 11:14:16 +0200
+Subject: [PATCH] syscalls/tgkill03: wait for defunct tid to get detached
+
+Case where defunct tid is used has been observed to sporadically fail:
+  tgkill03.c:96: FAIL: Defunct tid should have failed with ESRCH: SUCCESS
+
+glibc __pthread_timedjoin_ex() waits for CLONE_CHILD_CLEARTID to clear tid,
+and then resumes. Kernel clears it (glibc pd->tid) at:
+  do_exit
+    exit_mm
+      mm_release
+        put_user(0, tsk->clear_child_tid);
+
+but kernel tid is still valid, presumably until:
+  release_task
+    __exit_signal
+      __unhash_process
+        detach_pid
+
+To avoid race wait until /proc/<pid>/task/<tid> disappears.
+
+Signed-off-by: Jan Stancek <jstancek@redhat.com>
+Reviewed-by: Li Wang <liwang@redhat.com>
+Acked-by: Sumit Garg <sumit.garg@linaro.org>
+
+Upstream-Status: Backport
+[https://github.com/linux-test-project/ltp/commit/e747d0456adc080a1d31fb653bda9dc491795c80]
+
+Signed-off-by: He Zhe <zhe.he@windriver.com>
+---
+ testcases/kernel/syscalls/tgkill/tgkill03.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/testcases/kernel/syscalls/tgkill/tgkill03.c b/testcases/kernel/syscalls/tgkill/tgkill03.c
+index f5bbdc5..593a217 100644
+--- a/testcases/kernel/syscalls/tgkill/tgkill03.c
++++ b/testcases/kernel/syscalls/tgkill/tgkill03.c
+@@ -7,6 +7,7 @@
+ #include <pthread.h>
+ #include <pwd.h>
++#include <stdio.h>
+ #include <sys/types.h>
+ #include "tst_safe_pthread.h"
+@@ -42,6 +43,7 @@ static void setup(void)
+ {
+       sigset_t sigusr1;
+       pthread_t defunct_thread;
++      char defunct_tid_path[PATH_MAX];
+       sigemptyset(&sigusr1);
+       sigaddset(&sigusr1, SIGUSR1);
+@@ -55,8 +57,9 @@ static void setup(void)
+       TST_CHECKPOINT_WAIT(0);
+       SAFE_PTHREAD_CREATE(&defunct_thread, NULL, defunct_thread_func, NULL);
+-
+       SAFE_PTHREAD_JOIN(defunct_thread, NULL);
++      sprintf(defunct_tid_path, "/proc/%d/task/%d", getpid(), defunct_tid);
++      TST_RETRY_FN_EXP_BACKOFF(access(defunct_tid_path, R_OK), -1, 15);
+ }
+ static void cleanup(void)
+@@ -108,4 +111,5 @@ static struct tst_test test = {
+       .setup = setup,
+       .cleanup = cleanup,
+       .test = run,
++      .timeout = 20,
+ };
+-- 
+2.7.4
+
index c62f2618b5f56c8a5914e61a606cd7c74f42e6e7..f6c7de62dd21d03a0fc1595088498853fa93a16d 100644 (file)
@@ -43,6 +43,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \
            file://0012-getrlimit03-adjust-a-bit-of-code-to-compatiable-with.patch \
            file://0001-Add-configure-time-check-for-getdents-getdents64-API.patch \
            file://0002-check-for-RES_USE_INET6-during-configure.patch \
+           file://0001-syscalls-tgkill03-wait-for-defunct-tid-to-get-detach.patch \
            "
 
 S = "${WORKDIR}/git"