1 /* Copyright (C) 2002-2017 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. */
26 #include <sys/types.h>
27 #include <sys/socket.h>
43 /* Since STREAMS are not supported in the standard Linux kernel and
44 there we don't advertise STREAMS as supported is no need to test
45 the STREAMS related functions. This affects
46 getmsg() getpmsg() putmsg()
49 lockf() and fcntl() are tested in tst-cancel16.
51 pthread_join() is tested in tst-join5.
53 pthread_testcancel()'s only purpose is to allow cancellation. This
54 is tested in several places.
56 sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
58 mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
59 in tst-mqueue8{,x} tests.
61 aio_suspend() is tested in tst-cancel17.
63 clock_nanosleep() is tested in tst-cancel18.
65 Linux sendmmsg and recvmmsg are checked in tst-cancel4_1.c and
66 tst-cancel4_2.c respectively.
69 #include "tst-cancel4-common.h"
87 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
88 tempfd
= fd
= mkstemp (fname
);
90 printf ("%s: mkstemp failed\n", __FUNCTION__
);
93 r
= pthread_barrier_wait (&b2
);
94 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
96 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
101 r
= pthread_barrier_wait (&b2
);
102 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
104 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
109 pthread_cleanup_push (cl
, NULL
);
112 s
= read (fd
, buf
, sizeof (buf
));
114 pthread_cleanup_pop (0);
116 printf ("%s: read returns with %zd\n", __FUNCTION__
, s
);
132 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
133 tempfd
= fd
= mkstemp (fname
);
135 printf ("%s: mkstemp failed\n", __FUNCTION__
);
138 r
= pthread_barrier_wait (&b2
);
139 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
141 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
146 r
= pthread_barrier_wait (&b2
);
147 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
149 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
154 pthread_cleanup_push (cl
, NULL
);
157 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
158 s
= readv (fd
, iov
, 1);
160 pthread_cleanup_pop (0);
162 printf ("%s: readv returns with %zd\n", __FUNCTION__
, s
);
178 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
179 tempfd
= fd
= mkstemp (fname
);
181 printf ("%s: mkstemp failed\n", __FUNCTION__
);
184 r
= pthread_barrier_wait (&b2
);
185 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
187 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
192 r
= pthread_barrier_wait (&b2
);
193 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
195 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
200 pthread_cleanup_push (cl
, NULL
);
202 char buf
[WRITE_BUFFER_SIZE
];
203 memset (buf
, '\0', sizeof (buf
));
204 s
= write (fd
, buf
, sizeof (buf
));
206 pthread_cleanup_pop (0);
208 printf ("%s: write returns with %zd\n", __FUNCTION__
, s
);
215 tf_writev (void *arg
)
224 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
225 tempfd
= fd
= mkstemp (fname
);
227 printf ("%s: mkstemp failed\n", __FUNCTION__
);
230 r
= pthread_barrier_wait (&b2
);
231 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
233 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
238 r
= pthread_barrier_wait (&b2
);
239 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
241 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
246 pthread_cleanup_push (cl
, NULL
);
248 char buf
[WRITE_BUFFER_SIZE
];
249 memset (buf
, '\0', sizeof (buf
));
250 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
251 s
= writev (fd
, iov
, 1);
253 pthread_cleanup_pop (0);
255 printf ("%s: writev returns with %zd\n", __FUNCTION__
, s
);
264 int r
= pthread_barrier_wait (&b2
);
265 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
267 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
273 r
= pthread_barrier_wait (&b2
);
274 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
276 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
281 pthread_cleanup_push (cl
, NULL
);
283 sleep (arg
== NULL
? 1000000 : 0);
285 pthread_cleanup_pop (0);
287 printf ("%s: sleep returns\n", __FUNCTION__
);
294 tf_usleep (void *arg
)
296 int r
= pthread_barrier_wait (&b2
);
297 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
299 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
305 r
= pthread_barrier_wait (&b2
);
306 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
308 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
313 pthread_cleanup_push (cl
, NULL
);
315 usleep (arg
== NULL
? (useconds_t
) ULONG_MAX
: 0);
317 pthread_cleanup_pop (0);
319 printf ("%s: usleep returns\n", __FUNCTION__
);
326 tf_nanosleep (void *arg
)
328 int r
= pthread_barrier_wait (&b2
);
329 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
331 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
337 r
= pthread_barrier_wait (&b2
);
338 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
340 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
345 pthread_cleanup_push (cl
, NULL
);
347 struct timespec ts
= { .tv_sec
= arg
== NULL
? 10000000 : 0, .tv_nsec
= 0 };
348 TEMP_FAILURE_RETRY (nanosleep (&ts
, &ts
));
350 pthread_cleanup_pop (0);
352 printf ("%s: nanosleep returns\n", __FUNCTION__
);
359 tf_select (void *arg
)
368 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
369 tempfd
= fd
= mkstemp (fname
);
371 printf ("%s: mkstemp failed\n", __FUNCTION__
);
374 r
= pthread_barrier_wait (&b2
);
375 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
377 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
382 r
= pthread_barrier_wait (&b2
);
383 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
385 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
394 pthread_cleanup_push (cl
, NULL
);
396 s
= select (fd
+ 1, &rfs
, NULL
, NULL
, NULL
);
398 pthread_cleanup_pop (0);
400 printf ("%s: select returns with %d (%s)\n", __FUNCTION__
, s
,
408 tf_pselect (void *arg
)
417 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
418 tempfd
= fd
= mkstemp (fname
);
420 printf ("%s: mkstemp failed\n", __FUNCTION__
);
423 r
= pthread_barrier_wait (&b2
);
424 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
426 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
431 r
= pthread_barrier_wait (&b2
);
432 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
434 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
443 pthread_cleanup_push (cl
, NULL
);
445 s
= pselect (fd
+ 1, &rfs
, NULL
, NULL
, NULL
, NULL
);
447 pthread_cleanup_pop (0);
449 printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__
, s
,
466 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
467 tempfd
= fd
= mkstemp (fname
);
469 printf ("%s: mkstemp failed\n", __FUNCTION__
);
472 r
= pthread_barrier_wait (&b2
);
473 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
475 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
480 r
= pthread_barrier_wait (&b2
);
481 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
483 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
487 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
490 pthread_cleanup_push (cl
, NULL
);
492 s
= poll (rfs
, 1, -1);
494 pthread_cleanup_pop (0);
496 printf ("%s: poll returns with %d (%s)\n", __FUNCTION__
, s
,
513 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
514 tempfd
= fd
= mkstemp (fname
);
516 printf ("%s: mkstemp failed\n", __FUNCTION__
);
519 r
= pthread_barrier_wait (&b2
);
520 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
522 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
527 r
= pthread_barrier_wait (&b2
);
528 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
530 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
534 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
537 pthread_cleanup_push (cl
, NULL
);
539 s
= ppoll (rfs
, 1, NULL
, NULL
);
541 pthread_cleanup_pop (0);
543 printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__
, s
,
556 puts ("fork failed");
562 /* Make the program disappear after a while. */
571 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
572 while (nanosleep (&ts
, &ts
) != 0)
575 r
= pthread_barrier_wait (&b2
);
576 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
578 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
583 r
= pthread_barrier_wait (&b2
);
584 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
586 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
591 pthread_cleanup_push (cl
, NULL
);
595 pthread_cleanup_pop (0);
597 printf ("%s: wait returns with %d (%s)\n", __FUNCTION__
, s
,
605 tf_waitpid (void *arg
)
611 puts ("fork failed");
617 /* Make the program disappear after a while. */
626 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
627 while (nanosleep (&ts
, &ts
) != 0)
630 r
= pthread_barrier_wait (&b2
);
631 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
633 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
638 r
= pthread_barrier_wait (&b2
);
639 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
641 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
646 pthread_cleanup_push (cl
, NULL
);
648 s
= waitpid (-1, NULL
, 0);
650 pthread_cleanup_pop (0);
652 printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__
, s
,
660 tf_waitid (void *arg
)
665 puts ("fork failed");
671 /* Make the program disappear after a while. */
680 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
681 while (nanosleep (&ts
, &ts
) != 0)
684 r
= pthread_barrier_wait (&b2
);
685 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
687 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
692 r
= pthread_barrier_wait (&b2
);
693 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
695 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
700 pthread_cleanup_push (cl
, NULL
);
706 s
= waitid (P_PID
, pid
, &si
, WEXITED
);
708 pthread_cleanup_pop (0);
710 printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__
, s
,
718 tf_sigpause (void *arg
)
720 int r
= pthread_barrier_wait (&b2
);
721 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
723 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
729 r
= pthread_barrier_wait (&b2
);
730 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
732 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
737 pthread_cleanup_push (cl
, NULL
);
739 sigpause (sigmask (SIGINT
));
741 pthread_cleanup_pop (0);
743 printf ("%s: sigpause returned\n", __FUNCTION__
);
750 tf_sigsuspend (void *arg
)
752 int r
= pthread_barrier_wait (&b2
);
753 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
755 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
761 r
= pthread_barrier_wait (&b2
);
762 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
764 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
769 pthread_cleanup_push (cl
, NULL
);
771 /* Just for fun block all signals. */
776 pthread_cleanup_pop (0);
778 printf ("%s: sigsuspend returned\n", __FUNCTION__
);
785 tf_sigwait (void *arg
)
787 int r
= pthread_barrier_wait (&b2
);
788 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
790 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
796 r
= pthread_barrier_wait (&b2
);
797 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
799 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
807 sigaddset (&mask
, SIGUSR1
);
808 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
810 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
815 pthread_cleanup_push (cl
, NULL
);
817 /* Wait for SIGUSR1. */
818 sigwait (&mask
, &sig
);
820 pthread_cleanup_pop (0);
822 printf ("%s: sigwait returned with signal %d\n", __FUNCTION__
, sig
);
829 tf_sigwaitinfo (void *arg
)
831 int r
= pthread_barrier_wait (&b2
);
832 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
834 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
840 r
= pthread_barrier_wait (&b2
);
841 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
843 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
851 sigaddset (&mask
, SIGUSR1
);
852 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
854 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
859 pthread_cleanup_push (cl
, NULL
);
861 /* Wait for SIGUSR1. */
862 sigwaitinfo (&mask
, &info
);
864 pthread_cleanup_pop (0);
866 printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__
,
874 tf_sigtimedwait (void *arg
)
876 int r
= pthread_barrier_wait (&b2
);
877 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
879 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
885 r
= pthread_barrier_wait (&b2
);
886 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
888 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
896 sigaddset (&mask
, SIGUSR1
);
897 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
899 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
903 /* Wait for SIGUSR1. */
905 struct timespec ts
= { .tv_sec
= 60, .tv_nsec
= 0 };
906 pthread_cleanup_push (cl
, NULL
);
908 sigtimedwait (&mask
, &info
, &ts
);
910 pthread_cleanup_pop (0);
912 printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__
,
922 int r
= pthread_barrier_wait (&b2
);
923 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
925 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
931 r
= pthread_barrier_wait (&b2
);
932 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
934 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
939 pthread_cleanup_push (cl
, NULL
);
943 pthread_cleanup_pop (0);
945 printf ("%s: pause returned\n", __FUNCTION__
);
952 tf_accept (void *arg
)
954 struct sockaddr_un sun
;
955 /* To test a non-blocking accept call we make the call file by using
956 a datagrame socket. */
957 int pf
= arg
== NULL
? SOCK_STREAM
: SOCK_DGRAM
;
959 tempfd
= socket (AF_UNIX
, pf
, 0);
962 printf ("%s: socket call failed\n", __FUNCTION__
);
971 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
974 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-1-XXXXXX");
975 if (mktemp (sun
.sun_path
) == NULL
)
977 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
981 sun
.sun_family
= AF_UNIX
;
983 while (bind (tempfd
, (struct sockaddr
*) &sun
,
984 offsetof (struct sockaddr_un
, sun_path
)
985 + strlen (sun
.sun_path
) + 1) != 0);
987 unlink (sun
.sun_path
);
991 socklen_t len
= sizeof (sun
);
993 int r
= pthread_barrier_wait (&b2
);
994 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
996 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1002 r
= pthread_barrier_wait (&b2
);
1003 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1005 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1010 pthread_cleanup_push (cl
, NULL
);
1012 accept (tempfd
, (struct sockaddr
*) &sun
, &len
);
1014 pthread_cleanup_pop (0);
1016 printf ("%s: accept returned\n", __FUNCTION__
);
1025 struct sockaddr_un sun
;
1027 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1030 printf ("%s: first socket call failed\n", __FUNCTION__
);
1039 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1042 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-2-XXXXXX");
1043 if (mktemp (sun
.sun_path
) == NULL
)
1045 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1049 sun
.sun_family
= AF_UNIX
;
1051 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1052 offsetof (struct sockaddr_un
, sun_path
)
1053 + strlen (sun
.sun_path
) + 1) != 0);
1057 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1060 printf ("%s: second socket call failed\n", __FUNCTION__
);
1064 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1066 printf ("%s: connect failed\n", __FUNCTION__
);
1070 unlink (sun
.sun_path
);
1072 int r
= pthread_barrier_wait (&b2
);
1073 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1075 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1081 r
= pthread_barrier_wait (&b2
);
1082 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1084 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1089 pthread_cleanup_push (cl
, NULL
);
1091 /* Very large block, so that the send call blocks. */
1094 send (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 1, 0);
1096 pthread_cleanup_pop (0);
1098 printf ("%s: send returned\n", __FUNCTION__
);
1107 struct sockaddr_un sun
;
1109 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1112 printf ("%s: first socket call failed\n", __FUNCTION__
);
1121 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1124 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-3-XXXXXX");
1125 if (mktemp (sun
.sun_path
) == NULL
)
1127 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1131 sun
.sun_family
= AF_UNIX
;
1133 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1134 offsetof (struct sockaddr_un
, sun_path
)
1135 + strlen (sun
.sun_path
) + 1) != 0);
1139 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1142 printf ("%s: second socket call failed\n", __FUNCTION__
);
1146 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1148 printf ("%s: connect failed\n", __FUNCTION__
);
1152 unlink (sun
.sun_path
);
1154 int r
= pthread_barrier_wait (&b2
);
1155 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1157 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1163 r
= pthread_barrier_wait (&b2
);
1164 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1166 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1171 pthread_cleanup_push (cl
, NULL
);
1175 recv (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0);
1177 pthread_cleanup_pop (0);
1179 printf ("%s: recv returned\n", __FUNCTION__
);
1186 tf_recvfrom (void *arg
)
1188 struct sockaddr_un sun
;
1190 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1193 printf ("%s: first socket call failed\n", __FUNCTION__
);
1202 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1205 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-4-XXXXXX");
1206 if (mktemp (sun
.sun_path
) == NULL
)
1208 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1212 sun
.sun_family
= AF_UNIX
;
1214 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1215 offsetof (struct sockaddr_un
, sun_path
)
1216 + strlen (sun
.sun_path
) + 1) != 0);
1218 tempfname
= strdup (sun
.sun_path
);
1220 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1223 printf ("%s: second socket call failed\n", __FUNCTION__
);
1227 int r
= pthread_barrier_wait (&b2
);
1228 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1230 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1236 r
= pthread_barrier_wait (&b2
);
1237 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1239 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1244 pthread_cleanup_push (cl
, NULL
);
1247 socklen_t len
= sizeof (sun
);
1249 recvfrom (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0,
1250 (struct sockaddr
*) &sun
, &len
);
1252 pthread_cleanup_pop (0);
1254 printf ("%s: recvfrom returned\n", __FUNCTION__
);
1261 tf_recvmsg (void *arg
)
1263 struct sockaddr_un sun
;
1265 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1268 printf ("%s: first socket call failed\n", __FUNCTION__
);
1277 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1280 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-5-XXXXXX");
1281 if (mktemp (sun
.sun_path
) == NULL
)
1283 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1287 sun
.sun_family
= AF_UNIX
;
1289 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1290 offsetof (struct sockaddr_un
, sun_path
)
1291 + strlen (sun
.sun_path
) + 1) != 0);
1293 tempfname
= strdup (sun
.sun_path
);
1295 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1298 printf ("%s: second socket call failed\n", __FUNCTION__
);
1302 int r
= pthread_barrier_wait (&b2
);
1303 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1305 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1311 r
= pthread_barrier_wait (&b2
);
1312 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1314 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1319 pthread_cleanup_push (cl
, NULL
);
1322 struct iovec iov
[1];
1323 iov
[0].iov_base
= mem
;
1324 iov
[0].iov_len
= arg
== NULL
? sizeof (mem
) : 0;
1328 m
.msg_namelen
= sizeof (sun
);
1331 m
.msg_control
= NULL
;
1332 m
.msg_controllen
= 0;
1334 recvmsg (tempfd2
, &m
, 0);
1336 pthread_cleanup_pop (0);
1338 printf ("%s: recvmsg returned\n", __FUNCTION__
);
1348 fifofd
= mkfifo (fifoname
, S_IWUSR
| S_IRUSR
);
1351 printf ("%s: mkfifo failed: %m\n", __func__
);
1357 int r
= pthread_barrier_wait (&b2
);
1358 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1360 printf ("%s: barrier_wait failed: %m\n", __func__
);
1365 int r
= pthread_barrier_wait (&b2
);
1366 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1368 printf ("%s: 2nd barrier_wait failed: %m\n", __func__
);
1372 pthread_cleanup_push (cl_fifo
, NULL
);
1374 open (arg
? "Makefile" : fifoname
, O_RDONLY
);
1376 pthread_cleanup_pop (0);
1378 printf ("%s: open returned\n", __FUNCTION__
);
1385 tf_close (void *arg
)
1388 // XXX If somebody can provide a portable test case in which close()
1389 // blocks we can enable this test to run in both rounds.
1392 char fname
[] = "/tmp/tst-cancel-fd-XXXXXX";
1393 tempfd
= mkstemp (fname
);
1396 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1401 int r
= pthread_barrier_wait (&b2
);
1402 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1404 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1408 r
= pthread_barrier_wait (&b2
);
1409 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1411 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1415 pthread_cleanup_push (cl
, NULL
);
1419 pthread_cleanup_pop (0);
1421 printf ("%s: close returned\n", __FUNCTION__
);
1428 tf_pread (void *arg
)
1431 // XXX If somebody can provide a portable test case in which pread()
1432 // blocks we can enable this test to run in both rounds.
1435 tempfd
= open ("Makefile", O_RDONLY
);
1438 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1442 int r
= pthread_barrier_wait (&b2
);
1443 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1445 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1449 r
= pthread_barrier_wait (&b2
);
1450 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1452 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1456 pthread_cleanup_push (cl
, NULL
);
1459 pread (tempfd
, mem
, sizeof (mem
), 0);
1461 pthread_cleanup_pop (0);
1463 printf ("%s: pread returned\n", __FUNCTION__
);
1470 tf_pwrite (void *arg
)
1473 // XXX If somebody can provide a portable test case in which pwrite()
1474 // blocks we can enable this test to run in both rounds.
1477 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1478 tempfd
= mkstemp (fname
);
1481 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1486 int r
= pthread_barrier_wait (&b2
);
1487 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1489 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1493 r
= pthread_barrier_wait (&b2
);
1494 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1496 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1500 pthread_cleanup_push (cl
, NULL
);
1503 pwrite (tempfd
, mem
, sizeof (mem
), 0);
1505 pthread_cleanup_pop (0);
1507 printf ("%s: pwrite returned\n", __FUNCTION__
);
1513 tf_preadv (void *arg
)
1519 /* XXX If somebody can provide a portable test case in which preadv
1520 blocks we can enable this test to run in both rounds. */
1523 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1524 tempfd
= fd
= mkstemp (fname
);
1526 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1529 r
= pthread_barrier_wait (&b2
);
1530 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1532 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1536 r
= pthread_barrier_wait (&b2
);
1537 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1539 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1544 pthread_cleanup_push (cl
, NULL
);
1547 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
1548 s
= preadv (fd
, iov
, 1, 0);
1550 pthread_cleanup_pop (0);
1552 printf ("%s: preadv returns with %zd\n", __FUNCTION__
, s
);
1558 tf_pwritev (void *arg
)
1564 /* XXX If somebody can provide a portable test case in which pwritev
1565 blocks we can enable this test to run in both rounds. */
1568 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
1569 tempfd
= fd
= mkstemp (fname
);
1571 printf ("%s: mkstemp failed\n", __FUNCTION__
);
1574 r
= pthread_barrier_wait (&b2
);
1575 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1577 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1581 r
= pthread_barrier_wait (&b2
);
1582 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1584 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1589 pthread_cleanup_push (cl
, NULL
);
1591 char buf
[WRITE_BUFFER_SIZE
];
1592 memset (buf
, '\0', sizeof (buf
));
1593 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
1594 s
= pwritev (fd
, iov
, 1, 0);
1596 pthread_cleanup_pop (0);
1598 printf ("%s: pwritev returns with %zd\n", __FUNCTION__
, s
);
1604 tf_fsync (void *arg
)
1607 // XXX If somebody can provide a portable test case in which fsync()
1608 // blocks we can enable this test to run in both rounds.
1611 tempfd
= open ("Makefile", O_RDONLY
);
1614 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1618 int r
= pthread_barrier_wait (&b2
);
1619 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1621 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1625 r
= pthread_barrier_wait (&b2
);
1626 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1628 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1632 pthread_cleanup_push (cl
, NULL
);
1636 pthread_cleanup_pop (0);
1638 printf ("%s: fsync returned\n", __FUNCTION__
);
1645 tf_fdatasync (void *arg
)
1648 // XXX If somebody can provide a portable test case in which fdatasync()
1649 // blocks we can enable this test to run in both rounds.
1652 tempfd
= open ("Makefile", O_RDONLY
);
1655 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1659 int r
= pthread_barrier_wait (&b2
);
1660 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1662 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1666 r
= pthread_barrier_wait (&b2
);
1667 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1669 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1673 pthread_cleanup_push (cl
, NULL
);
1677 pthread_cleanup_pop (0);
1679 printf ("%s: fdatasync returned\n", __FUNCTION__
);
1686 tf_msync (void *arg
)
1689 // XXX If somebody can provide a portable test case in which msync()
1690 // blocks we can enable this test to run in both rounds.
1693 tempfd
= open ("Makefile", O_RDONLY
);
1696 printf ("%s: cannot open Makefile\n", __FUNCTION__
);
1699 void *p
= mmap (NULL
, 10, PROT_READ
, MAP_SHARED
, tempfd
, 0);
1700 if (p
== MAP_FAILED
)
1702 printf ("%s: mmap failed\n", __FUNCTION__
);
1706 int r
= pthread_barrier_wait (&b2
);
1707 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1709 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1713 r
= pthread_barrier_wait (&b2
);
1714 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1716 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1720 pthread_cleanup_push (cl
, NULL
);
1724 pthread_cleanup_pop (0);
1726 printf ("%s: msync returned\n", __FUNCTION__
);
1733 tf_sendto (void *arg
)
1736 // XXX If somebody can provide a portable test case in which sendto()
1737 // blocks we can enable this test to run in both rounds.
1740 struct sockaddr_un sun
;
1742 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1745 printf ("%s: first socket call failed\n", __FUNCTION__
);
1754 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1757 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-6-XXXXXX");
1758 if (mktemp (sun
.sun_path
) == NULL
)
1760 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1764 sun
.sun_family
= AF_UNIX
;
1766 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1767 offsetof (struct sockaddr_un
, sun_path
)
1768 + strlen (sun
.sun_path
) + 1) != 0);
1769 tempfname
= strdup (sun
.sun_path
);
1771 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1774 printf ("%s: second socket call failed\n", __FUNCTION__
);
1778 int r
= pthread_barrier_wait (&b2
);
1779 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1781 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1785 r
= pthread_barrier_wait (&b2
);
1786 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1788 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1792 pthread_cleanup_push (cl
, NULL
);
1796 sendto (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 1, 0,
1797 (struct sockaddr
*) &sun
,
1798 offsetof (struct sockaddr_un
, sun_path
) + strlen (sun
.sun_path
) + 1);
1800 pthread_cleanup_pop (0);
1802 printf ("%s: sendto returned\n", __FUNCTION__
);
1809 tf_sendmsg (void *arg
)
1812 // XXX If somebody can provide a portable test case in which sendmsg()
1813 // blocks we can enable this test to run in both rounds.
1816 struct sockaddr_un sun
;
1818 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1821 printf ("%s: first socket call failed\n", __FUNCTION__
);
1830 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1833 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-7-XXXXXX");
1834 if (mktemp (sun
.sun_path
) == NULL
)
1836 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1840 sun
.sun_family
= AF_UNIX
;
1842 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1843 offsetof (struct sockaddr_un
, sun_path
)
1844 + strlen (sun
.sun_path
) + 1) != 0);
1845 tempfname
= strdup (sun
.sun_path
);
1847 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1850 printf ("%s: second socket call failed\n", __FUNCTION__
);
1854 int r
= pthread_barrier_wait (&b2
);
1855 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1857 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1861 r
= pthread_barrier_wait (&b2
);
1862 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1864 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1868 pthread_cleanup_push (cl
, NULL
);
1871 struct iovec iov
[1];
1872 iov
[0].iov_base
= mem
;
1877 m
.msg_namelen
= (offsetof (struct sockaddr_un
, sun_path
)
1878 + strlen (sun
.sun_path
) + 1);
1881 m
.msg_control
= NULL
;
1882 m
.msg_controllen
= 0;
1884 sendmsg (tempfd2
, &m
, 0);
1886 pthread_cleanup_pop (0);
1888 printf ("%s: sendmsg returned\n", __FUNCTION__
);
1895 tf_creat (void *arg
)
1898 // XXX If somebody can provide a portable test case in which sendmsg()
1899 // blocks we can enable this test to run in both rounds.
1902 int r
= pthread_barrier_wait (&b2
);
1903 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1905 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1909 r
= pthread_barrier_wait (&b2
);
1910 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1912 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1916 pthread_cleanup_push (cl
, NULL
);
1918 creat ("tmp/tst-cancel-4-should-not-exist", 0666);
1920 pthread_cleanup_pop (0);
1922 printf ("%s: creat returned\n", __FUNCTION__
);
1929 tf_connect (void *arg
)
1932 // XXX If somebody can provide a portable test case in which connect()
1933 // blocks we can enable this test to run in both rounds.
1936 struct sockaddr_un sun
;
1938 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1941 printf ("%s: first socket call failed\n", __FUNCTION__
);
1950 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1953 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-2-XXXXXX");
1954 if (mktemp (sun
.sun_path
) == NULL
)
1956 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1960 sun
.sun_family
= AF_UNIX
;
1962 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1963 offsetof (struct sockaddr_un
, sun_path
)
1964 + strlen (sun
.sun_path
) + 1) != 0);
1965 tempfname
= strdup (sun
.sun_path
);
1969 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1972 printf ("%s: second socket call failed\n", __FUNCTION__
);
1976 int r
= pthread_barrier_wait (&b2
);
1977 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1979 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1985 r
= pthread_barrier_wait (&b2
);
1986 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1988 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1993 pthread_cleanup_push (cl
, NULL
);
1995 connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
));
1997 pthread_cleanup_pop (0);
1999 printf ("%s: connect returned\n", __FUNCTION__
);
2006 tf_tcdrain (void *arg
)
2009 // XXX If somebody can provide a portable test case in which tcdrain()
2010 // blocks we can enable this test to run in both rounds.
2013 int r
= pthread_barrier_wait (&b2
);
2014 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2016 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2022 r
= pthread_barrier_wait (&b2
);
2023 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2025 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2030 pthread_cleanup_push (cl
, NULL
);
2032 /* Regardless of stderr being a terminal, the tcdrain call should be
2034 tcdrain (STDERR_FILENO
);
2036 pthread_cleanup_pop (0);
2038 printf ("%s: tcdrain returned\n", __FUNCTION__
);
2045 tf_msgrcv (void *arg
)
2047 tempmsg
= msgget (IPC_PRIVATE
, 0666 | IPC_CREAT
);
2050 printf ("%s: msgget failed: %s\n", __FUNCTION__
, strerror (errno
));
2054 int r
= pthread_barrier_wait (&b2
);
2055 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2057 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2063 r
= pthread_barrier_wait (&b2
);
2064 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2066 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2073 pthread_cleanup_push (cl
, NULL
);
2081 /* We need a positive random number. */
2083 randnr
= random () % 64000;
2084 while (randnr
<= 0);
2088 s
= msgrcv (tempmsg
, (struct msgbuf
*) &m
, 10, randnr
, 0);
2090 while (errno
== EIDRM
|| errno
== EINTR
);
2092 pthread_cleanup_pop (0);
2094 printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__
, s
);
2096 msgctl (tempmsg
, IPC_RMID
, NULL
);
2103 tf_msgsnd (void *arg
)
2106 // XXX If somebody can provide a portable test case in which msgsnd()
2107 // blocks we can enable this test to run in both rounds.
2110 tempmsg
= msgget (IPC_PRIVATE
, 0666 | IPC_CREAT
);
2113 printf ("%s: msgget failed: %s\n", __FUNCTION__
, strerror (errno
));
2117 int r
= pthread_barrier_wait (&b2
);
2118 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2120 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
2124 r
= pthread_barrier_wait (&b2
);
2125 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
2127 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
2131 pthread_cleanup_push (cl
, NULL
);
2138 /* We need a positive random number. */
2140 m
.type
= random () % 64000;
2141 while (m
.type
<= 0);
2142 msgsnd (tempmsg
, (struct msgbuf
*) &m
, sizeof (m
.mem
), 0);
2144 pthread_cleanup_pop (0);
2146 printf ("%s: msgsnd returned\n", __FUNCTION__
);
2148 msgctl (tempmsg
, IPC_RMID
, NULL
);
2154 struct cancel_tests tests
[] =
2156 ADD_TEST (read
, 2, 0),
2157 ADD_TEST (readv
, 2, 0),
2158 ADD_TEST (select
, 2, 0),
2159 ADD_TEST (pselect
, 2, 0),
2160 ADD_TEST (poll
, 2, 0),
2161 ADD_TEST (ppoll
, 2, 0),
2162 ADD_TEST (write
, 2, 0),
2163 ADD_TEST (writev
, 2, 0),
2164 ADD_TEST (sleep
, 2, 0),
2165 ADD_TEST (usleep
, 2, 0),
2166 ADD_TEST (nanosleep
, 2, 0),
2167 ADD_TEST (wait
, 2, 0),
2168 ADD_TEST (waitid
, 2, 0),
2169 ADD_TEST (waitpid
, 2, 0),
2170 ADD_TEST (sigpause
, 2, 0),
2171 ADD_TEST (sigsuspend
, 2, 0),
2172 ADD_TEST (sigwait
, 2, 0),
2173 ADD_TEST (sigwaitinfo
, 2, 0),
2174 ADD_TEST (sigtimedwait
, 2, 0),
2175 ADD_TEST (pause
, 2, 0),
2176 ADD_TEST (accept
, 2, 0),
2177 ADD_TEST (send
, 2, 0),
2178 ADD_TEST (recv
, 2, 0),
2179 ADD_TEST (recvfrom
, 2, 0),
2180 ADD_TEST (recvmsg
, 2, 0),
2181 ADD_TEST (preadv
, 2, 1),
2182 ADD_TEST (pwritev
, 2, 1),
2183 ADD_TEST (open
, 2, 1),
2184 ADD_TEST (close
, 2, 1),
2185 ADD_TEST (pread
, 2, 1),
2186 ADD_TEST (pwrite
, 2, 1),
2187 ADD_TEST (fsync
, 2, 1),
2188 ADD_TEST (fdatasync
, 2, 1),
2189 ADD_TEST (msync
, 2, 1),
2190 ADD_TEST (sendto
, 2, 1),
2191 ADD_TEST (sendmsg
, 2, 1),
2192 ADD_TEST (creat
, 2, 1),
2193 ADD_TEST (connect
, 2, 1),
2194 ADD_TEST (tcdrain
, 2, 1),
2195 ADD_TEST (msgrcv
, 2, 0),
2196 ADD_TEST (msgsnd
, 2, 1),
2198 #define ntest_tf (sizeof (tests) / sizeof (tests[0]))
2200 #include "tst-cancel4-common.c"