1 /* Copyright (C) 2002-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* NOTE: this tests functionality beyond POSIX. POSIX does not allow
20 exit to be called more than once. */
25 #include <sys/types.h>
26 #include <sys/socket.h>
40 /* Since STREAMS are not supported in the standard Linux kernel and
41 there we don't advertise STREAMS as supported is no need to test
42 the STREAMS related functions. This affects
43 getmsg() getpmsg() putmsg()
46 lockf() and fcntl() are tested in tst-cancel16.
48 pthread_join() is tested in tst-join5.
50 pthread_testcancel()'s only purpose is to allow cancellation. This
51 is tested in several places.
53 sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
55 mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
56 in tst-mqueue8{,x} tests.
58 aio_suspend() is tested in tst-cancel17.
60 clock_nanosleep() is tested in tst-cancel18.
62 Linux sendmmsg and recvmmsg are checked in tst-cancel4_1.c and
63 tst-cancel4_2.c respectively.
66 #include "tst-cancel4-common.h"
84 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
85 tempfd
= fd
= mkstemp (fname
);
87 printf ("%s: mkstemp failed\n", __FUNCTION__
);
90 r
= pthread_barrier_wait (&b2
);
91 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
93 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
98 r
= pthread_barrier_wait (&b2
);
99 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
101 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
106 pthread_cleanup_push (cl
, NULL
);
109 s
= read (fd
, buf
, sizeof (buf
));
111 pthread_cleanup_pop (0);
113 printf ("%s: read returns with %zd\n", __FUNCTION__
, s
);
129 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
130 tempfd
= fd
= mkstemp (fname
);
132 printf ("%s: mkstemp failed\n", __FUNCTION__
);
135 r
= pthread_barrier_wait (&b2
);
136 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
138 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
143 r
= pthread_barrier_wait (&b2
);
144 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
146 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
151 pthread_cleanup_push (cl
, NULL
);
154 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
155 s
= readv (fd
, iov
, 1);
157 pthread_cleanup_pop (0);
159 printf ("%s: readv returns with %zd\n", __FUNCTION__
, s
);
175 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
176 tempfd
= fd
= mkstemp (fname
);
178 printf ("%s: mkstemp failed\n", __FUNCTION__
);
181 r
= pthread_barrier_wait (&b2
);
182 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
184 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
189 r
= pthread_barrier_wait (&b2
);
190 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
192 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
197 pthread_cleanup_push (cl
, NULL
);
199 char buf
[WRITE_BUFFER_SIZE
];
200 memset (buf
, '\0', sizeof (buf
));
201 s
= write (fd
, buf
, sizeof (buf
));
203 pthread_cleanup_pop (0);
205 printf ("%s: write returns with %zd\n", __FUNCTION__
, s
);
212 tf_writev (void *arg
)
221 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
222 tempfd
= fd
= mkstemp (fname
);
224 printf ("%s: mkstemp failed\n", __FUNCTION__
);
227 r
= pthread_barrier_wait (&b2
);
228 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
230 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
235 r
= pthread_barrier_wait (&b2
);
236 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
238 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
243 pthread_cleanup_push (cl
, NULL
);
245 char buf
[WRITE_BUFFER_SIZE
];
246 memset (buf
, '\0', sizeof (buf
));
247 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
248 s
= writev (fd
, iov
, 1);
250 pthread_cleanup_pop (0);
252 printf ("%s: writev returns with %zd\n", __FUNCTION__
, s
);
261 int r
= pthread_barrier_wait (&b2
);
262 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
264 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
270 r
= pthread_barrier_wait (&b2
);
271 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
273 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
278 pthread_cleanup_push (cl
, NULL
);
280 sleep (arg
== NULL
? 1000000 : 0);
282 pthread_cleanup_pop (0);
284 printf ("%s: sleep returns\n", __FUNCTION__
);
291 tf_usleep (void *arg
)
293 int r
= pthread_barrier_wait (&b2
);
294 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
296 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
302 r
= pthread_barrier_wait (&b2
);
303 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
305 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
310 pthread_cleanup_push (cl
, NULL
);
312 usleep (arg
== NULL
? (useconds_t
) ULONG_MAX
: 0);
314 pthread_cleanup_pop (0);
316 printf ("%s: usleep returns\n", __FUNCTION__
);
323 tf_nanosleep (void *arg
)
325 int r
= pthread_barrier_wait (&b2
);
326 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
328 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
334 r
= pthread_barrier_wait (&b2
);
335 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
337 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
342 pthread_cleanup_push (cl
, NULL
);
344 struct timespec ts
= { .tv_sec
= arg
== NULL
? 10000000 : 0, .tv_nsec
= 0 };
345 TEMP_FAILURE_RETRY (nanosleep (&ts
, &ts
));
347 pthread_cleanup_pop (0);
349 printf ("%s: nanosleep returns\n", __FUNCTION__
);
356 tf_select (void *arg
)
365 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
366 tempfd
= fd
= mkstemp (fname
);
368 printf ("%s: mkstemp failed\n", __FUNCTION__
);
371 r
= pthread_barrier_wait (&b2
);
372 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
374 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
379 r
= pthread_barrier_wait (&b2
);
380 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
382 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
391 pthread_cleanup_push (cl
, NULL
);
393 s
= select (fd
+ 1, &rfs
, NULL
, NULL
, NULL
);
395 pthread_cleanup_pop (0);
397 printf ("%s: select returns with %d (%s)\n", __FUNCTION__
, s
,
405 tf_pselect (void *arg
)
414 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
415 tempfd
= fd
= mkstemp (fname
);
417 printf ("%s: mkstemp failed\n", __FUNCTION__
);
420 r
= pthread_barrier_wait (&b2
);
421 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
423 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
428 r
= pthread_barrier_wait (&b2
);
429 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
431 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
440 pthread_cleanup_push (cl
, NULL
);
442 s
= pselect (fd
+ 1, &rfs
, NULL
, NULL
, NULL
, NULL
);
444 pthread_cleanup_pop (0);
446 printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__
, s
,
463 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
464 tempfd
= fd
= mkstemp (fname
);
466 printf ("%s: mkstemp failed\n", __FUNCTION__
);
469 r
= pthread_barrier_wait (&b2
);
470 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
472 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
477 r
= pthread_barrier_wait (&b2
);
478 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
480 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
484 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
487 pthread_cleanup_push (cl
, NULL
);
489 s
= poll (rfs
, 1, -1);
491 pthread_cleanup_pop (0);
493 printf ("%s: poll returns with %d (%s)\n", __FUNCTION__
, s
,
510 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
511 tempfd
= fd
= mkstemp (fname
);
513 printf ("%s: mkstemp failed\n", __FUNCTION__
);
516 r
= pthread_barrier_wait (&b2
);
517 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
519 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
524 r
= pthread_barrier_wait (&b2
);
525 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
527 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
531 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
534 pthread_cleanup_push (cl
, NULL
);
536 s
= ppoll (rfs
, 1, NULL
, NULL
);
538 pthread_cleanup_pop (0);
540 printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__
, s
,
553 puts ("fork failed");
559 /* Make the program disappear after a while. */
568 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
569 while (nanosleep (&ts
, &ts
) != 0)
572 r
= pthread_barrier_wait (&b2
);
573 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
575 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
580 r
= pthread_barrier_wait (&b2
);
581 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
583 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
588 pthread_cleanup_push (cl
, NULL
);
592 pthread_cleanup_pop (0);
594 printf ("%s: wait returns with %d (%s)\n", __FUNCTION__
, s
,
602 tf_waitpid (void *arg
)
608 puts ("fork failed");
614 /* Make the program disappear after a while. */
623 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
624 while (nanosleep (&ts
, &ts
) != 0)
627 r
= pthread_barrier_wait (&b2
);
628 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
630 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
635 r
= pthread_barrier_wait (&b2
);
636 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
638 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
643 pthread_cleanup_push (cl
, NULL
);
645 s
= waitpid (-1, NULL
, 0);
647 pthread_cleanup_pop (0);
649 printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__
, s
,
657 tf_waitid (void *arg
)
662 puts ("fork failed");
668 /* Make the program disappear after a while. */
677 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
678 while (nanosleep (&ts
, &ts
) != 0)
681 r
= pthread_barrier_wait (&b2
);
682 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
684 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
689 r
= pthread_barrier_wait (&b2
);
690 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
692 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
697 pthread_cleanup_push (cl
, NULL
);
703 s
= waitid (P_PID
, pid
, &si
, WEXITED
);
705 pthread_cleanup_pop (0);
707 printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__
, s
,
715 tf_sigpause (void *arg
)
717 int r
= pthread_barrier_wait (&b2
);
718 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
720 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
726 r
= pthread_barrier_wait (&b2
);
727 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
729 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
734 pthread_cleanup_push (cl
, NULL
);
736 sigpause (sigmask (SIGINT
));
738 pthread_cleanup_pop (0);
740 printf ("%s: sigpause returned\n", __FUNCTION__
);
747 tf_sigsuspend (void *arg
)
749 int r
= pthread_barrier_wait (&b2
);
750 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
752 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
758 r
= pthread_barrier_wait (&b2
);
759 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
761 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
766 pthread_cleanup_push (cl
, NULL
);
768 /* Just for fun block all signals. */
773 pthread_cleanup_pop (0);
775 printf ("%s: sigsuspend returned\n", __FUNCTION__
);
782 tf_sigwait (void *arg
)
784 int r
= pthread_barrier_wait (&b2
);
785 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
787 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
793 r
= pthread_barrier_wait (&b2
);
794 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
796 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
804 sigaddset (&mask
, SIGUSR1
);
805 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
807 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
812 pthread_cleanup_push (cl
, NULL
);
814 /* Wait for SIGUSR1. */
815 sigwait (&mask
, &sig
);
817 pthread_cleanup_pop (0);
819 printf ("%s: sigwait returned with signal %d\n", __FUNCTION__
, sig
);
826 tf_sigwaitinfo (void *arg
)
828 int r
= pthread_barrier_wait (&b2
);
829 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
831 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
837 r
= pthread_barrier_wait (&b2
);
838 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
840 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
848 sigaddset (&mask
, SIGUSR1
);
849 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
851 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
856 pthread_cleanup_push (cl
, NULL
);
858 /* Wait for SIGUSR1. */
859 sigwaitinfo (&mask
, &info
);
861 pthread_cleanup_pop (0);
863 printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__
,
871 tf_sigtimedwait (void *arg
)
873 int r
= pthread_barrier_wait (&b2
);
874 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
876 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
882 r
= pthread_barrier_wait (&b2
);
883 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
885 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
893 sigaddset (&mask
, SIGUSR1
);
894 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
896 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
900 /* Wait for SIGUSR1. */
902 struct timespec ts
= { .tv_sec
= 60, .tv_nsec
= 0 };
903 pthread_cleanup_push (cl
, NULL
);
905 sigtimedwait (&mask
, &info
, &ts
);
907 pthread_cleanup_pop (0);
909 printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__
,
919 int r
= pthread_barrier_wait (&b2
);
920 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
922 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
928 r
= pthread_barrier_wait (&b2
);
929 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
931 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
936 pthread_cleanup_push (cl
, NULL
);
940 pthread_cleanup_pop (0);
942 printf ("%s: pause returned\n", __FUNCTION__
);
949 tf_accept (void *arg
)
951 struct sockaddr_un sun
;
952 /* To test a non-blocking accept call we make the call file by using
953 a datagrame socket. */
954 int pf
= arg
== NULL
? SOCK_STREAM
: SOCK_DGRAM
;
956 tempfd
= socket (AF_UNIX
, pf
, 0);
959 printf ("%s: socket call failed\n", __FUNCTION__
);
968 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
971 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-1-XXXXXX");
972 if (mktemp (sun
.sun_path
) == NULL
)
974 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
978 sun
.sun_family
= AF_UNIX
;
980 while (bind (tempfd
, (struct sockaddr
*) &sun
,
981 offsetof (struct sockaddr_un
, sun_path
)
982 + strlen (sun
.sun_path
) + 1) != 0);
984 unlink (sun
.sun_path
);
988 socklen_t len
= sizeof (sun
);
990 int r
= pthread_barrier_wait (&b2
);
991 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
993 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
999 r
= pthread_barrier_wait (&b2
);
1000 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1002 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1007 pthread_cleanup_push (cl
, NULL
);
1009 accept (tempfd
, (struct sockaddr
*) &sun
, &len
);
1011 pthread_cleanup_pop (0);
1013 printf ("%s: accept returned\n", __FUNCTION__
);
1022 struct sockaddr_un sun
;
1024 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1027 printf ("%s: first socket call failed\n", __FUNCTION__
);
1036 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1039 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-2-XXXXXX");
1040 if (mktemp (sun
.sun_path
) == NULL
)
1042 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1046 sun
.sun_family
= AF_UNIX
;
1048 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1049 offsetof (struct sockaddr_un
, sun_path
)
1050 + strlen (sun
.sun_path
) + 1) != 0);
1054 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1057 printf ("%s: second socket call failed\n", __FUNCTION__
);
1061 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1063 printf ("%s: connect failed\n", __FUNCTION__
);
1067 unlink (sun
.sun_path
);
1069 int r
= pthread_barrier_wait (&b2
);
1070 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1072 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1078 r
= pthread_barrier_wait (&b2
);
1079 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1081 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1086 pthread_cleanup_push (cl
, NULL
);
1088 /* Very large block, so that the send call blocks. */
1091 send (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 1, 0);
1093 pthread_cleanup_pop (0);
1095 printf ("%s: send returned\n", __FUNCTION__
);
1104 struct sockaddr_un sun
;
1106 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1109 printf ("%s: first socket call failed\n", __FUNCTION__
);
1118 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1121 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-3-XXXXXX");
1122 if (mktemp (sun
.sun_path
) == NULL
)
1124 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1128 sun
.sun_family
= AF_UNIX
;
1130 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1131 offsetof (struct sockaddr_un
, sun_path
)
1132 + strlen (sun
.sun_path
) + 1) != 0);
1136 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1139 printf ("%s: second socket call failed\n", __FUNCTION__
);
1143 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1145 printf ("%s: connect failed\n", __FUNCTION__
);
1149 unlink (sun
.sun_path
);
1151 int r
= pthread_barrier_wait (&b2
);
1152 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1154 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1160 r
= pthread_barrier_wait (&b2
);
1161 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1163 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1168 pthread_cleanup_push (cl
, NULL
);
1172 recv (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0);
1174 pthread_cleanup_pop (0);
1176 printf ("%s: recv returned\n", __FUNCTION__
);
1183 tf_recvfrom (void *arg
)
1185 struct sockaddr_un sun
;
1187 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1190 printf ("%s: first socket call failed\n", __FUNCTION__
);
1199 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1202 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-4-XXXXXX");
1203 if (mktemp (sun
.sun_path
) == NULL
)
1205 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1209 sun
.sun_family
= AF_UNIX
;
1211 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1212 offsetof (struct sockaddr_un
, sun_path
)
1213 + strlen (sun
.sun_path
) + 1) != 0);
1215 tempfname
= strdup (sun
.sun_path
);
1217 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1220 printf ("%s: second socket call failed\n", __FUNCTION__
);
1224 int r
= pthread_barrier_wait (&b2
);
1225 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1227 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1233 r
= pthread_barrier_wait (&b2
);
1234 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1236 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1241 pthread_cleanup_push (cl
, NULL
);
1244 socklen_t len
= sizeof (sun
);
1246 recvfrom (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0,
1247 (struct sockaddr
*) &sun
, &len
);
1249 pthread_cleanup_pop (0);
1251 printf ("%s: recvfrom returned\n", __FUNCTION__
);
1258 tf_recvmsg (void *arg
)
1260 struct sockaddr_un sun
;
1262 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1265 printf ("%s: first socket call failed\n", __FUNCTION__
);
1274 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1277 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-5-XXXXXX");
1278 if (mktemp (sun
.sun_path
) == NULL
)
1280 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1284 sun
.sun_family
= AF_UNIX
;
1286 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1287 offsetof (struct sockaddr_un
, sun_path
)
1288 + strlen (sun
.sun_path
) + 1) != 0);
1290 tempfname
= strdup (sun
.sun_path
);
1292 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1295 printf ("%s: second socket call failed\n", __FUNCTION__
);
1299 int r
= pthread_barrier_wait (&b2
);
1300 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1302 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1308 r
= pthread_barrier_wait (&b2
);
1309 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1311 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1316 pthread_cleanup_push (cl
, NULL
);
1319 struct iovec iov
[1];
1320 iov
[0].iov_base
= mem
;
1321 iov
[0].iov_len
= arg
== NULL
? sizeof (mem
) : 0;
1325 m
.msg_namelen
= sizeof (sun
);
1328 m
.msg_control
= NULL
;
1329 m
.msg_controllen
= 0;
1331 recvmsg (tempfd2
, &m
, 0);
1333 pthread_cleanup_pop (0);
1335 printf ("%s: recvmsg returned\n", __FUNCTION__
);
1345 fifofd
= mkfifo (fifoname
, S_IWUSR
| S_IRUSR
);
1348 printf ("%s: mkfifo failed: %m\n", __func__
);
1354 int r
= pthread_barrier_wait (&b2
);
1355 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1357 printf ("%s: barrier_wait failed: %m\n", __func__
);
1362 int r
= pthread_barrier_wait (&b2
);
1363 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1365 printf ("%s: 2nd barrier_wait failed: %m\n", __func__
);
1369 pthread_cleanup_push (cl_fifo
, NULL
);
1371 open (arg
? "Makefile" : fifoname
, O_RDONLY
);
1373 pthread_cleanup_pop (0);
1375 printf ("%s: open returned\n", __FUNCTION__
);
1382 tf_close (void *arg
)
1385 // XXX If somebody can provide a portable test case in which close()
1386 // blocks we can enable this test to run in both rounds.
1389 char fname
[] = "/tmp/tst-cancel-fd-XXXXXX";
1390 tempfd
= mkstemp (fname
);
1393 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1398 int r
= pthread_barrier_wait (&b2
);
1399 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1401 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1405 r
= pthread_barrier_wait (&b2
);
1406 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1408 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1412 pthread_cleanup_push (cl
, NULL
);
1416 pthread_cleanup_pop (0);
1418 printf ("%s: close returned\n", __FUNCTION__
);
1425 tf_pread (void *arg
)
1428 // XXX If somebody can provide a portable test case in which pread()
1429 // blocks we can enable this test to run in both rounds.
1432 tempfd
= open ("Makefile", O_RDONLY
);
1435 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1439 int r
= pthread_barrier_wait (&b2
);
1440 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1442 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1446 r
= pthread_barrier_wait (&b2
);
1447 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1449 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1453 pthread_cleanup_push (cl
, NULL
);
1456 pread (tempfd
, mem
, sizeof (mem
), 0);
1458 pthread_cleanup_pop (0);
1460 printf ("%s: pread returned\n", __FUNCTION__
);
1467 tf_pwrite (void *arg
)
1470 // XXX If somebody can provide a portable test case in which pwrite()
1471 // blocks we can enable this test to run in both rounds.
1474 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1475 tempfd
= mkstemp (fname
);
1478 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1483 int r
= pthread_barrier_wait (&b2
);
1484 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1486 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1490 r
= pthread_barrier_wait (&b2
);
1491 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1493 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1497 pthread_cleanup_push (cl
, NULL
);
1500 pwrite (tempfd
, mem
, sizeof (mem
), 0);
1502 pthread_cleanup_pop (0);
1504 printf ("%s: pwrite returned\n", __FUNCTION__
);
1510 tf_preadv (void *arg
)
1516 /* XXX If somebody can provide a portable test case in which preadv
1517 blocks we can enable this test to run in both rounds. */
1520 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1521 tempfd
= fd
= mkstemp (fname
);
1523 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1526 r
= pthread_barrier_wait (&b2
);
1527 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1529 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1533 r
= pthread_barrier_wait (&b2
);
1534 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1536 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1541 pthread_cleanup_push (cl
, NULL
);
1544 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
1545 s
= preadv (fd
, iov
, 1, 0);
1547 pthread_cleanup_pop (0);
1549 printf ("%s: preadv returns with %zd\n", __FUNCTION__
, s
);
1555 tf_pwritev (void *arg
)
1561 /* XXX If somebody can provide a portable test case in which pwritev
1562 blocks we can enable this test to run in both rounds. */
1565 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1566 tempfd
= fd
= mkstemp (fname
);
1568 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1571 r
= pthread_barrier_wait (&b2
);
1572 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1574 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1578 r
= pthread_barrier_wait (&b2
);
1579 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1581 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1586 pthread_cleanup_push (cl
, NULL
);
1588 char buf
[WRITE_BUFFER_SIZE
];
1589 memset (buf
, '\0', sizeof (buf
));
1590 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
1591 s
= pwritev (fd
, iov
, 1, 0);
1593 pthread_cleanup_pop (0);
1595 printf ("%s: pwritev returns with %zd\n", __FUNCTION__
, s
);
1601 tf_fsync (void *arg
)
1604 // XXX If somebody can provide a portable test case in which fsync()
1605 // blocks we can enable this test to run in both rounds.
1608 tempfd
= open ("Makefile", O_RDONLY
);
1611 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1615 int r
= pthread_barrier_wait (&b2
);
1616 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1618 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1622 r
= pthread_barrier_wait (&b2
);
1623 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1625 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1629 pthread_cleanup_push (cl
, NULL
);
1633 pthread_cleanup_pop (0);
1635 printf ("%s: fsync returned\n", __FUNCTION__
);
1642 tf_fdatasync (void *arg
)
1645 // XXX If somebody can provide a portable test case in which fdatasync()
1646 // blocks we can enable this test to run in both rounds.
1649 tempfd
= open ("Makefile", O_RDONLY
);
1652 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1656 int r
= pthread_barrier_wait (&b2
);
1657 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1659 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1663 r
= pthread_barrier_wait (&b2
);
1664 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1666 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1670 pthread_cleanup_push (cl
, NULL
);
1674 pthread_cleanup_pop (0);
1676 printf ("%s: fdatasync returned\n", __FUNCTION__
);
1683 tf_msync (void *arg
)
1686 // XXX If somebody can provide a portable test case in which msync()
1687 // blocks we can enable this test to run in both rounds.
1690 tempfd
= open ("Makefile", O_RDONLY
);
1693 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1696 void *p
= mmap (NULL
, 10, PROT_READ
, MAP_SHARED
, tempfd
, 0);
1697 if (p
== MAP_FAILED
)
1699 printf ("%s: mmap failed\n", __FUNCTION__
);
1703 int r
= pthread_barrier_wait (&b2
);
1704 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1706 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1710 r
= pthread_barrier_wait (&b2
);
1711 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1713 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1717 pthread_cleanup_push (cl
, NULL
);
1721 pthread_cleanup_pop (0);
1723 printf ("%s: msync returned\n", __FUNCTION__
);
1730 tf_sendto (void *arg
)
1733 // XXX If somebody can provide a portable test case in which sendto()
1734 // blocks we can enable this test to run in both rounds.
1737 struct sockaddr_un sun
;
1739 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1742 printf ("%s: first socket call failed\n", __FUNCTION__
);
1751 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1754 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-6-XXXXXX");
1755 if (mktemp (sun
.sun_path
) == NULL
)
1757 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1761 sun
.sun_family
= AF_UNIX
;
1763 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1764 offsetof (struct sockaddr_un
, sun_path
)
1765 + strlen (sun
.sun_path
) + 1) != 0);
1766 tempfname
= strdup (sun
.sun_path
);
1768 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1771 printf ("%s: second socket call failed\n", __FUNCTION__
);
1775 int r
= pthread_barrier_wait (&b2
);
1776 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1778 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1782 r
= pthread_barrier_wait (&b2
);
1783 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1785 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1789 pthread_cleanup_push (cl
, NULL
);
1793 sendto (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 1, 0,
1794 (struct sockaddr
*) &sun
,
1795 offsetof (struct sockaddr_un
, sun_path
) + strlen (sun
.sun_path
) + 1);
1797 pthread_cleanup_pop (0);
1799 printf ("%s: sendto returned\n", __FUNCTION__
);
1806 tf_sendmsg (void *arg
)
1809 // XXX If somebody can provide a portable test case in which sendmsg()
1810 // blocks we can enable this test to run in both rounds.
1813 struct sockaddr_un sun
;
1815 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1818 printf ("%s: first socket call failed\n", __FUNCTION__
);
1827 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1830 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-7-XXXXXX");
1831 if (mktemp (sun
.sun_path
) == NULL
)
1833 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1837 sun
.sun_family
= AF_UNIX
;
1839 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1840 offsetof (struct sockaddr_un
, sun_path
)
1841 + strlen (sun
.sun_path
) + 1) != 0);
1842 tempfname
= strdup (sun
.sun_path
);
1844 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1847 printf ("%s: second socket call failed\n", __FUNCTION__
);
1851 int r
= pthread_barrier_wait (&b2
);
1852 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1854 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1858 r
= pthread_barrier_wait (&b2
);
1859 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1861 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1865 pthread_cleanup_push (cl
, NULL
);
1868 struct iovec iov
[1];
1869 iov
[0].iov_base
= mem
;
1874 m
.msg_namelen
= (offsetof (struct sockaddr_un
, sun_path
)
1875 + strlen (sun
.sun_path
) + 1);
1878 m
.msg_control
= NULL
;
1879 m
.msg_controllen
= 0;
1881 sendmsg (tempfd2
, &m
, 0);
1883 pthread_cleanup_pop (0);
1885 printf ("%s: sendmsg returned\n", __FUNCTION__
);
1892 tf_creat (void *arg
)
1895 // XXX If somebody can provide a portable test case in which sendmsg()
1896 // blocks we can enable this test to run in both rounds.
1899 int r
= pthread_barrier_wait (&b2
);
1900 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1902 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1906 r
= pthread_barrier_wait (&b2
);
1907 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1909 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1913 pthread_cleanup_push (cl
, NULL
);
1915 creat ("tmp/tst-cancel-4-should-not-exist", 0666);
1917 pthread_cleanup_pop (0);
1919 printf ("%s: creat returned\n", __FUNCTION__
);
1926 tf_connect (void *arg
)
1929 // XXX If somebody can provide a portable test case in which connect()
1930 // blocks we can enable this test to run in both rounds.
1933 struct sockaddr_un sun
;
1935 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1938 printf ("%s: first socket call failed\n", __FUNCTION__
);
1947 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1950 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-2-XXXXXX");
1951 if (mktemp (sun
.sun_path
) == NULL
)
1953 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1957 sun
.sun_family
= AF_UNIX
;
1959 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1960 offsetof (struct sockaddr_un
, sun_path
)
1961 + strlen (sun
.sun_path
) + 1) != 0);
1962 tempfname
= strdup (sun
.sun_path
);
1966 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1969 printf ("%s: second socket call failed\n", __FUNCTION__
);
1973 int r
= pthread_barrier_wait (&b2
);
1974 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1976 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1982 r
= pthread_barrier_wait (&b2
);
1983 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1985 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1990 pthread_cleanup_push (cl
, NULL
);
1992 connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
));
1994 pthread_cleanup_pop (0);
1996 printf ("%s: connect returned\n", __FUNCTION__
);
2003 tf_tcdrain (void *arg
)
2006 // XXX If somebody can provide a portable test case in which tcdrain()
2007 // blocks we can enable this test to run in both rounds.
2010 int r
= pthread_barrier_wait (&b2
);
2011 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2013 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2019 r
= pthread_barrier_wait (&b2
);
2020 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2022 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2027 pthread_cleanup_push (cl
, NULL
);
2029 /* Regardless of stderr being a terminal, the tcdrain call should be
2031 tcdrain (STDERR_FILENO
);
2033 pthread_cleanup_pop (0);
2035 printf ("%s: tcdrain returned\n", __FUNCTION__
);
2042 tf_msgrcv (void *arg
)
2044 tempmsg
= msgget (IPC_PRIVATE
, 0666 | IPC_CREAT
);
2047 printf ("%s: msgget failed: %s\n", __FUNCTION__
, strerror (errno
));
2051 int r
= pthread_barrier_wait (&b2
);
2052 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2054 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2060 r
= pthread_barrier_wait (&b2
);
2061 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2063 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2070 pthread_cleanup_push (cl
, NULL
);
2078 /* We need a positive random number. */
2080 randnr
= random () % 64000;
2081 while (randnr
<= 0);
2085 s
= msgrcv (tempmsg
, (struct msgbuf
*) &m
, 10, randnr
, 0);
2087 while (errno
== EIDRM
|| errno
== EINTR
);
2089 pthread_cleanup_pop (0);
2091 printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__
, s
);
2093 msgctl (tempmsg
, IPC_RMID
, NULL
);
2100 tf_msgsnd (void *arg
)
2103 // XXX If somebody can provide a portable test case in which msgsnd()
2104 // blocks we can enable this test to run in both rounds.
2107 tempmsg
= msgget (IPC_PRIVATE
, 0666 | IPC_CREAT
);
2110 printf ("%s: msgget failed: %s\n", __FUNCTION__
, strerror (errno
));
2114 int r
= pthread_barrier_wait (&b2
);
2115 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2117 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2121 r
= pthread_barrier_wait (&b2
);
2122 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2124 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2128 pthread_cleanup_push (cl
, NULL
);
2135 /* We need a positive random number. */
2137 m
.type
= random () % 64000;
2138 while (m
.type
<= 0);
2139 msgsnd (tempmsg
, (struct msgbuf
*) &m
, sizeof (m
.mem
), 0);
2141 pthread_cleanup_pop (0);
2143 printf ("%s: msgsnd returned\n", __FUNCTION__
);
2145 msgctl (tempmsg
, IPC_RMID
, NULL
);
2151 struct cancel_tests tests
[] =
2153 ADD_TEST (read
, 2, 0),
2154 ADD_TEST (readv
, 2, 0),
2155 ADD_TEST (select
, 2, 0),
2156 ADD_TEST (pselect
, 2, 0),
2157 ADD_TEST (poll
, 2, 0),
2158 ADD_TEST (ppoll
, 2, 0),
2159 ADD_TEST (write
, 2, 0),
2160 ADD_TEST (writev
, 2, 0),
2161 ADD_TEST (sleep
, 2, 0),
2162 ADD_TEST (usleep
, 2, 0),
2163 ADD_TEST (nanosleep
, 2, 0),
2164 ADD_TEST (wait
, 2, 0),
2165 ADD_TEST (waitid
, 2, 0),
2166 ADD_TEST (waitpid
, 2, 0),
2167 ADD_TEST (sigpause
, 2, 0),
2168 ADD_TEST (sigsuspend
, 2, 0),
2169 ADD_TEST (sigwait
, 2, 0),
2170 ADD_TEST (sigwaitinfo
, 2, 0),
2171 ADD_TEST (sigtimedwait
, 2, 0),
2172 ADD_TEST (pause
, 2, 0),
2173 ADD_TEST (accept
, 2, 0),
2174 ADD_TEST (send
, 2, 0),
2175 ADD_TEST (recv
, 2, 0),
2176 ADD_TEST (recvfrom
, 2, 0),
2177 ADD_TEST (recvmsg
, 2, 0),
2178 ADD_TEST (preadv
, 2, 1),
2179 ADD_TEST (pwritev
, 2, 1),
2180 ADD_TEST (open
, 2, 1),
2181 ADD_TEST (close
, 2, 1),
2182 ADD_TEST (pread
, 2, 1),
2183 ADD_TEST (pwrite
, 2, 1),
2184 ADD_TEST (fsync
, 2, 1),
2185 ADD_TEST (fdatasync
, 2, 1),
2186 ADD_TEST (msync
, 2, 1),
2187 ADD_TEST (sendto
, 2, 1),
2188 ADD_TEST (sendmsg
, 2, 1),
2189 ADD_TEST (creat
, 2, 1),
2190 ADD_TEST (connect
, 2, 1),
2191 ADD_TEST (tcdrain
, 2, 1),
2192 ADD_TEST (msgrcv
, 2, 0),
2193 ADD_TEST (msgsnd
, 2, 1),
2195 #define ntest_tf (sizeof (tests) / sizeof (tests[0]))
2197 #include "tst-cancel4-common.c"