about summary refs log tree commit diff
path: root/nptl/tst-cancel4-common.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-06-14 12:18:32 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2016-07-05 10:49:37 -0300
commit2918b0d0ecbf781400577d63aed7eaa4498dad91 (patch)
treed1921e8fa42044585bf7f7e0ca17f77c6129b8b6 /nptl/tst-cancel4-common.h
parent87523e9c3605037cee54bbc6bd7a040a15979cc1 (diff)
downloadglibc-2918b0d0ecbf781400577d63aed7eaa4498dad91.tar.gz
glibc-2918b0d0ecbf781400577d63aed7eaa4498dad91.tar.xz
glibc-2918b0d0ecbf781400577d63aed7eaa4498dad91.zip
nptl: Add more coverage in tst-cancel4
This patch adds early cancel test for open syscall through a FIFO
(thus makign subsequent call to open block until the other end is
also opened).

It also cleanup the sigpause tests by using sigpause along with
SIGINT instead of __xpg_sigpause and SIGCANCEL.  Since the idea
is just to test the cancellation handling there is no need to expose
internal glibc implementation details to the test through pthreadP.h
inclusion.

Tested x86_64.

	* nptl/tst-cancel4-common.c (do_test): Add temporary fifo creation.
	* nptl/tst-cancel4-common.h (fifoname): New variable.
	(fifofd): Likewise.
	(cl_fifo): New function.
	* nptl/tst-cancel4.c (tf_sigpause): Replace SIGCANCEL usage by
	SIGINT.
	(tf_open): Add early cancel test.
Diffstat (limited to 'nptl/tst-cancel4-common.h')
-rw-r--r--nptl/tst-cancel4-common.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/nptl/tst-cancel4-common.h b/nptl/tst-cancel4-common.h
index e1683c435b..06ed0dc1ba 100644
--- a/nptl/tst-cancel4-common.h
+++ b/nptl/tst-cancel4-common.h
@@ -67,6 +67,22 @@ cl (void *arg)
   ++cl_called;
 }
 
+/* Named pipe used to check for blocking open.  It should be closed
+   after the cancellation handling.  */
+static char fifoname[] = "/tmp/tst-cancel4-fifo-XXXXXX";
+static int fifofd;
+
+static void
+__attribute__ ((used))
+cl_fifo (void *arg)
+{
+  ++cl_called;
+
+  unlink (fifoname);
+  close (fifofd);
+  fifofd = -1;
+}
+
 struct cancel_tests
 {
   const char *name;