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>
42 /* Since STREAMS are not supported in the standard Linux kernel and
43 there we don't advertise STREAMS as supported is no need to test
44 the STREAMS related functions. This affects
45 getmsg() getpmsg() putmsg()
48 lockf() and fcntl() are tested in tst-cancel16.
50 pthread_join() is tested in tst-join5.
52 pthread_testcancel()'s only purpose is to allow cancellation. This
53 is tested in several places.
55 sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
57 mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
58 in tst-mqueue8{,x} tests.
60 aio_suspend() is tested in tst-cancel17.
62 clock_nanosleep() is tested in tst-cancel18.
64 Linux sendmmsg and recvmmsg are checked in tst-cancel4_1.c and
65 tst-cancel4_2.c respectively.
68 #include "tst-cancel4-common.h"
85 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
86 tempfd
= fd
= mkstemp (fname
);
88 printf ("%s: mkstemp failed\n", __FUNCTION__
);
91 r
= pthread_barrier_wait (&b2
);
92 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
94 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
99 r
= pthread_barrier_wait (&b2
);
100 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
102 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
107 pthread_cleanup_push (cl
, NULL
);
110 s
= read (fd
, buf
, sizeof (buf
));
112 pthread_cleanup_pop (0);
114 printf ("%s: read returns with %zd\n", __FUNCTION__
, s
);
130 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
131 tempfd
= fd
= mkstemp (fname
);
133 printf ("%s: mkstemp failed\n", __FUNCTION__
);
136 r
= pthread_barrier_wait (&b2
);
137 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
139 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
144 r
= pthread_barrier_wait (&b2
);
145 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
147 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
152 pthread_cleanup_push (cl
, NULL
);
155 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
156 s
= readv (fd
, iov
, 1);
158 pthread_cleanup_pop (0);
160 printf ("%s: readv returns with %zd\n", __FUNCTION__
, s
);
176 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
177 tempfd
= fd
= mkstemp (fname
);
179 printf ("%s: mkstemp failed\n", __FUNCTION__
);
182 r
= pthread_barrier_wait (&b2
);
183 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
185 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
190 r
= pthread_barrier_wait (&b2
);
191 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
193 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
198 pthread_cleanup_push (cl
, NULL
);
200 char buf
[WRITE_BUFFER_SIZE
];
201 memset (buf
, '\0', sizeof (buf
));
202 s
= write (fd
, buf
, sizeof (buf
));
204 pthread_cleanup_pop (0);
206 printf ("%s: write returns with %zd\n", __FUNCTION__
, s
);
213 tf_writev (void *arg
)
222 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
223 tempfd
= fd
= mkstemp (fname
);
225 printf ("%s: mkstemp failed\n", __FUNCTION__
);
228 r
= pthread_barrier_wait (&b2
);
229 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
231 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
236 r
= pthread_barrier_wait (&b2
);
237 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
239 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
244 pthread_cleanup_push (cl
, NULL
);
246 char buf
[WRITE_BUFFER_SIZE
];
247 memset (buf
, '\0', sizeof (buf
));
248 struct iovec iov
[1] = { [0] = { .iov_base
= buf
, .iov_len
= sizeof (buf
) } };
249 s
= writev (fd
, iov
, 1);
251 pthread_cleanup_pop (0);
253 printf ("%s: writev returns with %zd\n", __FUNCTION__
, s
);
262 int r
= pthread_barrier_wait (&b2
);
263 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
265 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
271 r
= pthread_barrier_wait (&b2
);
272 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
274 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
279 pthread_cleanup_push (cl
, NULL
);
281 sleep (arg
== NULL
? 1000000 : 0);
283 pthread_cleanup_pop (0);
285 printf ("%s: sleep returns\n", __FUNCTION__
);
292 tf_usleep (void *arg
)
294 int r
= pthread_barrier_wait (&b2
);
295 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
297 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
303 r
= pthread_barrier_wait (&b2
);
304 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
306 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
311 pthread_cleanup_push (cl
, NULL
);
313 usleep (arg
== NULL
? (useconds_t
) ULONG_MAX
: 0);
315 pthread_cleanup_pop (0);
317 printf ("%s: usleep returns\n", __FUNCTION__
);
324 tf_nanosleep (void *arg
)
326 int r
= pthread_barrier_wait (&b2
);
327 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
329 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
335 r
= pthread_barrier_wait (&b2
);
336 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
338 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
343 pthread_cleanup_push (cl
, NULL
);
345 struct timespec ts
= { .tv_sec
= arg
== NULL
? 10000000 : 0, .tv_nsec
= 0 };
346 TEMP_FAILURE_RETRY (nanosleep (&ts
, &ts
));
348 pthread_cleanup_pop (0);
350 printf ("%s: nanosleep returns\n", __FUNCTION__
);
357 tf_select (void *arg
)
366 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
367 tempfd
= fd
= mkstemp (fname
);
369 printf ("%s: mkstemp failed\n", __FUNCTION__
);
372 r
= pthread_barrier_wait (&b2
);
373 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
375 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
380 r
= pthread_barrier_wait (&b2
);
381 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
383 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
392 pthread_cleanup_push (cl
, NULL
);
394 s
= select (fd
+ 1, &rfs
, NULL
, NULL
, NULL
);
396 pthread_cleanup_pop (0);
398 printf ("%s: select returns with %d (%s)\n", __FUNCTION__
, s
,
406 tf_pselect (void *arg
)
415 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
416 tempfd
= fd
= mkstemp (fname
);
418 printf ("%s: mkstemp failed\n", __FUNCTION__
);
421 r
= pthread_barrier_wait (&b2
);
422 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
424 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
429 r
= pthread_barrier_wait (&b2
);
430 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
432 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
441 pthread_cleanup_push (cl
, NULL
);
443 s
= pselect (fd
+ 1, &rfs
, NULL
, NULL
, NULL
, NULL
);
445 pthread_cleanup_pop (0);
447 printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__
, s
,
464 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
465 tempfd
= fd
= mkstemp (fname
);
467 printf ("%s: mkstemp failed\n", __FUNCTION__
);
470 r
= pthread_barrier_wait (&b2
);
471 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
473 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
478 r
= pthread_barrier_wait (&b2
);
479 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
481 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
485 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
488 pthread_cleanup_push (cl
, NULL
);
490 s
= poll (rfs
, 1, -1);
492 pthread_cleanup_pop (0);
494 printf ("%s: poll returns with %d (%s)\n", __FUNCTION__
, s
,
511 char fname
[] = "/tmp/tst-cancel4-fd-XXXXXX";
512 tempfd
= fd
= mkstemp (fname
);
514 printf ("%s: mkstemp failed\n", __FUNCTION__
);
517 r
= pthread_barrier_wait (&b2
);
518 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
520 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
525 r
= pthread_barrier_wait (&b2
);
526 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
528 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
532 struct pollfd rfs
[1] = { [0] = { .fd
= fd
, .events
= POLLIN
} };
535 pthread_cleanup_push (cl
, NULL
);
537 s
= ppoll (rfs
, 1, NULL
, NULL
);
539 pthread_cleanup_pop (0);
541 printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__
, s
,
554 puts ("fork failed");
560 /* Make the program disappear after a while. */
569 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
570 while (nanosleep (&ts
, &ts
) != 0)
573 r
= pthread_barrier_wait (&b2
);
574 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
576 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
581 r
= pthread_barrier_wait (&b2
);
582 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
584 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
589 pthread_cleanup_push (cl
, NULL
);
593 pthread_cleanup_pop (0);
595 printf ("%s: wait returns with %d (%s)\n", __FUNCTION__
, s
,
603 tf_waitpid (void *arg
)
609 puts ("fork failed");
615 /* Make the program disappear after a while. */
624 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
625 while (nanosleep (&ts
, &ts
) != 0)
628 r
= pthread_barrier_wait (&b2
);
629 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
631 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
636 r
= pthread_barrier_wait (&b2
);
637 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
639 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
644 pthread_cleanup_push (cl
, NULL
);
646 s
= waitpid (-1, NULL
, 0);
648 pthread_cleanup_pop (0);
650 printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__
, s
,
658 tf_waitid (void *arg
)
663 puts ("fork failed");
669 /* Make the program disappear after a while. */
678 struct timespec ts
= { .tv_sec
= 0, .tv_nsec
= 100000000 };
679 while (nanosleep (&ts
, &ts
) != 0)
682 r
= pthread_barrier_wait (&b2
);
683 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
685 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
690 r
= pthread_barrier_wait (&b2
);
691 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
693 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
698 pthread_cleanup_push (cl
, NULL
);
704 s
= waitid (P_PID
, pid
, &si
, WEXITED
);
706 pthread_cleanup_pop (0);
708 printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__
, s
,
716 tf_sigpause (void *arg
)
718 int r
= pthread_barrier_wait (&b2
);
719 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
721 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
727 r
= pthread_barrier_wait (&b2
);
728 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
730 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
735 pthread_cleanup_push (cl
, NULL
);
738 /* Just for fun block the cancellation signal. We need to use
739 __xpg_sigpause since otherwise we will get the BSD version. */
740 __xpg_sigpause (SIGCANCEL
);
745 pthread_cleanup_pop (0);
747 printf ("%s: sigpause returned\n", __FUNCTION__
);
754 tf_sigsuspend (void *arg
)
756 int r
= pthread_barrier_wait (&b2
);
757 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
759 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
765 r
= pthread_barrier_wait (&b2
);
766 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
768 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
773 pthread_cleanup_push (cl
, NULL
);
775 /* Just for fun block all signals. */
780 pthread_cleanup_pop (0);
782 printf ("%s: sigsuspend returned\n", __FUNCTION__
);
789 tf_sigwait (void *arg
)
791 int r
= pthread_barrier_wait (&b2
);
792 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
794 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
800 r
= pthread_barrier_wait (&b2
);
801 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
803 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
811 sigaddset (&mask
, SIGUSR1
);
812 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
814 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
819 pthread_cleanup_push (cl
, NULL
);
821 /* Wait for SIGUSR1. */
822 sigwait (&mask
, &sig
);
824 pthread_cleanup_pop (0);
826 printf ("%s: sigwait returned with signal %d\n", __FUNCTION__
, sig
);
833 tf_sigwaitinfo (void *arg
)
835 int r
= pthread_barrier_wait (&b2
);
836 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
838 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
844 r
= pthread_barrier_wait (&b2
);
845 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
847 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
855 sigaddset (&mask
, SIGUSR1
);
856 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
858 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
863 pthread_cleanup_push (cl
, NULL
);
865 /* Wait for SIGUSR1. */
866 sigwaitinfo (&mask
, &info
);
868 pthread_cleanup_pop (0);
870 printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__
,
878 tf_sigtimedwait (void *arg
)
880 int r
= pthread_barrier_wait (&b2
);
881 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
883 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
889 r
= pthread_barrier_wait (&b2
);
890 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
892 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
900 sigaddset (&mask
, SIGUSR1
);
901 if (pthread_sigmask (SIG_BLOCK
, &mask
, NULL
) != 0)
903 printf ("%s: pthread_sigmask failed\n", __FUNCTION__
);
907 /* Wait for SIGUSR1. */
909 struct timespec ts
= { .tv_sec
= 60, .tv_nsec
= 0 };
910 pthread_cleanup_push (cl
, NULL
);
912 sigtimedwait (&mask
, &info
, &ts
);
914 pthread_cleanup_pop (0);
916 printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__
,
926 int r
= pthread_barrier_wait (&b2
);
927 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
929 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
935 r
= pthread_barrier_wait (&b2
);
936 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
938 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
943 pthread_cleanup_push (cl
, NULL
);
947 pthread_cleanup_pop (0);
949 printf ("%s: pause returned\n", __FUNCTION__
);
956 tf_accept (void *arg
)
958 struct sockaddr_un sun
;
959 /* To test a non-blocking accept call we make the call file by using
960 a datagrame socket. */
961 int pf
= arg
== NULL
? SOCK_STREAM
: SOCK_DGRAM
;
963 tempfd
= socket (AF_UNIX
, pf
, 0);
966 printf ("%s: socket call failed\n", __FUNCTION__
);
975 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
978 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-1-XXXXXX");
979 if (mktemp (sun
.sun_path
) == NULL
)
981 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
985 sun
.sun_family
= AF_UNIX
;
987 while (bind (tempfd
, (struct sockaddr
*) &sun
,
988 offsetof (struct sockaddr_un
, sun_path
)
989 + strlen (sun
.sun_path
) + 1) != 0);
991 unlink (sun
.sun_path
);
995 socklen_t len
= sizeof (sun
);
997 int r
= pthread_barrier_wait (&b2
);
998 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1000 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1006 r
= pthread_barrier_wait (&b2
);
1007 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1009 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1014 pthread_cleanup_push (cl
, NULL
);
1016 accept (tempfd
, (struct sockaddr
*) &sun
, &len
);
1018 pthread_cleanup_pop (0);
1020 printf ("%s: accept returned\n", __FUNCTION__
);
1029 struct sockaddr_un sun
;
1031 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1034 printf ("%s: first socket call failed\n", __FUNCTION__
);
1043 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1046 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-2-XXXXXX");
1047 if (mktemp (sun
.sun_path
) == NULL
)
1049 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1053 sun
.sun_family
= AF_UNIX
;
1055 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1056 offsetof (struct sockaddr_un
, sun_path
)
1057 + strlen (sun
.sun_path
) + 1) != 0);
1061 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1064 printf ("%s: second socket call failed\n", __FUNCTION__
);
1068 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1070 printf ("%s: connect failed\n", __FUNCTION__
);
1074 unlink (sun
.sun_path
);
1076 int r
= pthread_barrier_wait (&b2
);
1077 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1079 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1085 r
= pthread_barrier_wait (&b2
);
1086 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1088 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1093 pthread_cleanup_push (cl
, NULL
);
1095 /* Very large block, so that the send call blocks. */
1098 send (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 1, 0);
1100 pthread_cleanup_pop (0);
1102 printf ("%s: send returned\n", __FUNCTION__
);
1111 struct sockaddr_un sun
;
1113 tempfd
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1116 printf ("%s: first socket call failed\n", __FUNCTION__
);
1125 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1128 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-3-XXXXXX");
1129 if (mktemp (sun
.sun_path
) == NULL
)
1131 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1135 sun
.sun_family
= AF_UNIX
;
1137 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1138 offsetof (struct sockaddr_un
, sun_path
)
1139 + strlen (sun
.sun_path
) + 1) != 0);
1143 tempfd2
= socket (AF_UNIX
, SOCK_STREAM
, 0);
1146 printf ("%s: second socket call failed\n", __FUNCTION__
);
1150 if (connect (tempfd2
, (struct sockaddr
*) &sun
, sizeof (sun
)) != 0)
1152 printf ("%s: connect failed\n", __FUNCTION__
);
1156 unlink (sun
.sun_path
);
1158 int r
= pthread_barrier_wait (&b2
);
1159 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1161 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1167 r
= pthread_barrier_wait (&b2
);
1168 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1170 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1175 pthread_cleanup_push (cl
, NULL
);
1179 recv (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0);
1181 pthread_cleanup_pop (0);
1183 printf ("%s: recv returned\n", __FUNCTION__
);
1190 tf_recvfrom (void *arg
)
1192 struct sockaddr_un sun
;
1194 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1197 printf ("%s: first socket call failed\n", __FUNCTION__
);
1206 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1209 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-4-XXXXXX");
1210 if (mktemp (sun
.sun_path
) == NULL
)
1212 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1216 sun
.sun_family
= AF_UNIX
;
1218 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1219 offsetof (struct sockaddr_un
, sun_path
)
1220 + strlen (sun
.sun_path
) + 1) != 0);
1222 tempfname
= strdup (sun
.sun_path
);
1224 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1227 printf ("%s: second socket call failed\n", __FUNCTION__
);
1231 int r
= pthread_barrier_wait (&b2
);
1232 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1234 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1240 r
= pthread_barrier_wait (&b2
);
1241 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1243 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1248 pthread_cleanup_push (cl
, NULL
);
1251 socklen_t len
= sizeof (sun
);
1253 recvfrom (tempfd2
, mem
, arg
== NULL
? sizeof (mem
) : 0, 0,
1254 (struct sockaddr
*) &sun
, &len
);
1256 pthread_cleanup_pop (0);
1258 printf ("%s: recvfrom returned\n", __FUNCTION__
);
1265 tf_recvmsg (void *arg
)
1267 struct sockaddr_un sun
;
1269 tempfd
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1272 printf ("%s: first socket call failed\n", __FUNCTION__
);
1281 printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__
);
1284 strcpy (sun
.sun_path
, "/tmp/tst-cancel4-socket-5-XXXXXX");
1285 if (mktemp (sun
.sun_path
) == NULL
)
1287 printf ("%s: cannot generate temp file name\n", __FUNCTION__
);
1291 sun
.sun_family
= AF_UNIX
;
1293 while (bind (tempfd
, (struct sockaddr
*) &sun
,
1294 offsetof (struct sockaddr_un
, sun_path
)
1295 + strlen (sun
.sun_path
) + 1) != 0);
1297 tempfname
= strdup (sun
.sun_path
);
1299 tempfd2
= socket (AF_UNIX
, SOCK_DGRAM
, 0);
1302 printf ("%s: second socket call failed\n", __FUNCTION__
);
1306 int r
= pthread_barrier_wait (&b2
);
1307 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1309 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1315 r
= pthread_barrier_wait (&b2
);
1316 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1318 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1323 pthread_cleanup_push (cl
, NULL
);
1326 struct iovec iov
[1];
1327 iov
[0].iov_base
= mem
;
1328 iov
[0].iov_len
= arg
== NULL
? sizeof (mem
) : 0;
1332 m
.msg_namelen
= sizeof (sun
);
1335 m
.msg_control
= NULL
;
1336 m
.msg_controllen
= 0;
1338 recvmsg (tempfd2
, &m
, 0);
1340 pthread_cleanup_pop (0);
1342 printf ("%s: recvmsg returned\n", __FUNCTION__
);
1351 // XXX If somebody can provide a portable test case in which open()
1352 // blocks we can enable this test to run in both rounds.
1355 int r
= pthread_barrier_wait (&b2
);
1356 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1358 printf ("%s: barrier_wait failed\n", __FUNCTION__
);
1362 r
= pthread_barrier_wait (&b2
);
1363 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
1365 printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__
);
1369 pthread_cleanup_push (cl
, NULL
);
1371 open ("Makefile", 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"