]> git.ipfire.org Git - thirdparty/glibc.git/blob - nptl/tst-cancel4.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / nptl / tst-cancel4.c
1 /* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
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.
9
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.
14
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 <https://www.gnu.org/licenses/>. */
18
19 /* NOTE: this tests functionality beyond POSIX. POSIX does not allow
20 exit to be called more than once. */
21
22 #include <stddef.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/un.h>
29 #include <sys/ipc.h>
30 #include <sys/msg.h>
31 #include <unistd.h>
32 #include <errno.h>
33 #include <limits.h>
34 #include <pthread.h>
35 #include <fcntl.h>
36 #include <termios.h>
37 #include <sys/mman.h>
38 #include <sys/poll.h>
39 #include <sys/wait.h>
40 #include <sys/stat.h>
41 #include <sys/uio.h>
42
43
44 /* Since STREAMS are not supported in the standard Linux kernel and
45 there we don't advertise STREAMS as supported is no need to test
46 the STREAMS related functions. This affects
47 getmsg() getpmsg() putmsg()
48 putpmsg()
49
50 lockf() and fcntl() are tested in tst-cancel16.
51
52 pthread_join() is tested in tst-join5.
53
54 pthread_testcancel()'s only purpose is to allow cancellation. This
55 is tested in several places.
56
57 sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
58
59 mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
60 in tst-mqueue8{,x} tests.
61
62 aio_suspend() is tested in tst-cancel17.
63
64 clock_nanosleep() is tested in tst-cancel18.
65
66 Linux sendmmsg and recvmmsg are checked in tst-cancel4_1.c and
67 tst-cancel4_2.c respectively.
68 */
69
70 #include "tst-cancel4-common.h"
71
72
73 #ifndef IPC_ADDVAL
74 # define IPC_ADDVAL 0
75 #endif
76
77
78 static void *
79 tf_read (void *arg)
80 {
81 int fd;
82
83 if (arg == NULL)
84 fd = fds[0];
85 else
86 {
87 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
88 tempfd = fd = mkstemp (fname);
89 if (fd == -1)
90 FAIL_EXIT1 ("mkstemp failed: %m");
91 unlink (fname);
92
93 xpthread_barrier_wait (&b2);
94 }
95
96 xpthread_barrier_wait (&b2);
97
98 ssize_t s;
99 pthread_cleanup_push (cl, NULL);
100
101 char buf[100];
102 s = read (fd, buf, sizeof (buf));
103
104 pthread_cleanup_pop (0);
105
106 FAIL_EXIT1 ("read returns with %zd", s);
107 }
108
109
110 static void *
111 tf_readv (void *arg)
112 {
113 int fd;
114
115 if (arg == NULL)
116 fd = fds[0];
117 else
118 {
119 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
120 tempfd = fd = mkstemp (fname);
121 if (fd == -1)
122 FAIL_EXIT1 ("mkstemp failed: %m");
123 unlink (fname);
124
125 xpthread_barrier_wait (&b2);
126 }
127
128 xpthread_barrier_wait (&b2);
129
130 ssize_t s;
131 pthread_cleanup_push (cl, NULL);
132
133 char buf[100];
134 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
135 s = readv (fd, iov, 1);
136
137 pthread_cleanup_pop (0);
138
139 FAIL_EXIT1 ("readv returns with %zd", s);
140 }
141
142
143 static void *
144 tf_write (void *arg)
145 {
146 int fd;
147
148 if (arg == NULL)
149 fd = fds[1];
150 else
151 {
152 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
153 tempfd = fd = mkstemp (fname);
154 if (fd == -1)
155 FAIL_EXIT1 ("mkstemp failed: %m");
156 unlink (fname);
157
158 xpthread_barrier_wait (&b2);
159 }
160
161 xpthread_barrier_wait (&b2);
162
163 ssize_t s;
164 pthread_cleanup_push (cl, NULL);
165
166 char buf[WRITE_BUFFER_SIZE];
167 memset (buf, '\0', sizeof (buf));
168 s = write (fd, buf, sizeof (buf));
169 /* The write can return a value higher than 0 (meaning partial write)
170 due to the SIGCANCEL, but the thread may still be pending
171 cancellation. */
172 pthread_testcancel ();
173
174 pthread_cleanup_pop (0);
175
176 FAIL_EXIT1 ("write returns with %zd", s);
177 }
178
179
180 static void *
181 tf_writev (void *arg)
182 {
183 int fd;
184
185 if (arg == NULL)
186 fd = fds[1];
187 else
188 {
189 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
190 tempfd = fd = mkstemp (fname);
191 if (fd == -1)
192 FAIL_EXIT1 ("mkstemp failed: %m");
193 unlink (fname);
194
195 xpthread_barrier_wait (&b2);
196 }
197
198 xpthread_barrier_wait (&b2);
199
200 ssize_t s;
201 pthread_cleanup_push (cl, NULL);
202
203 char buf[WRITE_BUFFER_SIZE];
204 memset (buf, '\0', sizeof (buf));
205 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
206 s = writev (fd, iov, 1);
207
208 pthread_cleanup_pop (0);
209
210 FAIL_EXIT1 ("writev returns with %zd", s);
211 }
212
213
214 static void *
215 tf_sleep (void *arg)
216 {
217 xpthread_barrier_wait (&b2);
218
219 if (arg != NULL)
220 xpthread_barrier_wait (&b2);
221
222 pthread_cleanup_push (cl, NULL);
223
224 sleep (arg == NULL ? 1000000 : 0);
225
226 pthread_cleanup_pop (0);
227
228 FAIL_EXIT1 ("sleep returns");
229 }
230
231
232 static void *
233 tf_usleep (void *arg)
234 {
235 xpthread_barrier_wait (&b2);
236
237 if (arg != NULL)
238 xpthread_barrier_wait (&b2);
239
240 pthread_cleanup_push (cl, NULL);
241
242 usleep (arg == NULL ? (useconds_t) ULONG_MAX : 0);
243
244 pthread_cleanup_pop (0);
245
246 FAIL_EXIT1 ("usleep returns");
247 }
248
249
250 static void *
251 tf_nanosleep (void *arg)
252 {
253 xpthread_barrier_wait (&b2);
254
255 if (arg != NULL)
256 xpthread_barrier_wait (&b2);
257
258 pthread_cleanup_push (cl, NULL);
259
260 struct timespec ts = { .tv_sec = arg == NULL ? 10000000 : 0, .tv_nsec = 0 };
261 TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
262
263 pthread_cleanup_pop (0);
264
265 FAIL_EXIT1 ("nanosleep returns");
266 }
267
268
269 static void *
270 tf_select (void *arg)
271 {
272 int fd;
273
274 if (arg == NULL)
275 fd = fds[0];
276 else
277 {
278 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
279 tempfd = fd = mkstemp (fname);
280 if (fd == -1)
281 FAIL_EXIT1 ("mkstemp failed: %m");
282 unlink (fname);
283
284 xpthread_barrier_wait (&b2);
285 }
286
287 xpthread_barrier_wait (&b2);
288
289 fd_set rfs;
290 FD_ZERO (&rfs);
291 FD_SET (fd, &rfs);
292
293 int s;
294 pthread_cleanup_push (cl, NULL);
295
296 s = select (fd + 1, &rfs, NULL, NULL, NULL);
297
298 pthread_cleanup_pop (0);
299
300 FAIL_EXIT1 ("select returns with %d: %m", s);
301 }
302
303
304 static void *
305 tf_pselect (void *arg)
306 {
307 int fd;
308
309 if (arg == NULL)
310 fd = fds[0];
311 else
312 {
313 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
314 tempfd = fd = mkstemp (fname);
315 if (fd == -1)
316 FAIL_EXIT1 ("mkstemp failed: %m");
317 unlink (fname);
318
319 xpthread_barrier_wait (&b2);
320 }
321
322 xpthread_barrier_wait (&b2);
323
324 fd_set rfs;
325 FD_ZERO (&rfs);
326 FD_SET (fd, &rfs);
327
328 int s;
329 pthread_cleanup_push (cl, NULL);
330
331 s = pselect (fd + 1, &rfs, NULL, NULL, NULL, NULL);
332
333 pthread_cleanup_pop (0);
334
335 FAIL_EXIT1 ("pselect returns with %d: %m", s);
336 }
337
338
339 static void *
340 tf_poll (void *arg)
341 {
342 int fd;
343
344 if (arg == NULL)
345 fd = fds[0];
346 else
347 {
348 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
349 tempfd = fd = mkstemp (fname);
350 if (fd == -1)
351 FAIL_EXIT1 ("mkstemp failed: %m");
352 unlink (fname);
353
354 xpthread_barrier_wait (&b2);
355 }
356
357 xpthread_barrier_wait (&b2);
358
359 struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
360
361 int s;
362 pthread_cleanup_push (cl, NULL);
363
364 s = poll (rfs, 1, -1);
365
366 pthread_cleanup_pop (0);
367
368 FAIL_EXIT1 ("poll returns with %d: %m", s);
369 }
370
371
372 static void *
373 tf_ppoll (void *arg)
374 {
375 int fd;
376
377 if (arg == NULL)
378 fd = fds[0];
379 else
380 {
381 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
382 tempfd = fd = mkstemp (fname);
383 if (fd == -1)
384 FAIL_EXIT1 ("mkstemp failed: %m");
385 unlink (fname);
386
387 xpthread_barrier_wait (&b2);
388 }
389
390 xpthread_barrier_wait (&b2);
391
392 struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
393
394 int s;
395 pthread_cleanup_push (cl, NULL);
396
397 s = ppoll (rfs, 1, NULL, NULL);
398
399 pthread_cleanup_pop (0);
400
401 FAIL_EXIT1 ("ppoll returns with %d: %m", s);
402 }
403
404
405 static void *
406 tf_wait (void *arg)
407 {
408 pid_t pid = fork ();
409 if (pid == -1)
410 FAIL_EXIT1 ("fork: %m");
411
412 if (pid == 0)
413 {
414 /* Make the program disappear after a while. */
415 if (arg == NULL)
416 sleep (10);
417 exit (0);
418 }
419
420 if (arg != NULL)
421 {
422 struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
423 while (nanosleep (&ts, &ts) != 0)
424 continue;
425
426 xpthread_barrier_wait (&b2);
427 }
428
429 xpthread_barrier_wait (&b2);
430
431 int s;
432 pthread_cleanup_push (cl, NULL);
433
434 s = wait (NULL);
435
436 pthread_cleanup_pop (0);
437
438 FAIL_EXIT1 ("wait returns with %d: %m", s);
439 }
440
441
442 static void *
443 tf_waitpid (void *arg)
444 {
445 pid_t pid = fork ();
446 if (pid == -1)
447 FAIL_EXIT1 ("fork: %m");
448
449 if (pid == 0)
450 {
451 /* Make the program disappear after a while. */
452 if (arg == NULL)
453 sleep (10);
454 exit (0);
455 }
456
457 if (arg != NULL)
458 {
459 struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
460 while (nanosleep (&ts, &ts) != 0)
461 continue;
462
463 xpthread_barrier_wait (&b2);
464 }
465
466 xpthread_barrier_wait (&b2);
467
468 int s;
469 pthread_cleanup_push (cl, NULL);
470
471 s = waitpid (-1, NULL, 0);
472
473 pthread_cleanup_pop (0);
474
475 FAIL_EXIT1 ("waitpid returns with %d: %m", s);
476 }
477
478
479 static void *
480 tf_waitid (void *arg)
481 {
482 pid_t pid = fork ();
483 if (pid == -1)
484 FAIL_EXIT1 ("fork: %m");
485
486 if (pid == 0)
487 {
488 /* Make the program disappear after a while. */
489 if (arg == NULL)
490 sleep (10);
491 exit (0);
492 }
493
494 if (arg != NULL)
495 {
496 struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
497 while (nanosleep (&ts, &ts) != 0)
498 continue;
499
500 xpthread_barrier_wait (&b2);
501 }
502
503 xpthread_barrier_wait (&b2);
504
505 int s;
506 pthread_cleanup_push (cl, NULL);
507
508 #ifndef WEXITED
509 # define WEXITED 0
510 #endif
511 siginfo_t si;
512 s = waitid (P_PID, pid, &si, WEXITED);
513
514 pthread_cleanup_pop (0);
515
516 FAIL_EXIT1 ("waitid returns with %d: %m", s);
517 }
518
519
520 static void *
521 tf_sigpause (void *arg)
522 {
523 xpthread_barrier_wait (&b2);
524
525 if (arg != NULL)
526 xpthread_barrier_wait (&b2);
527
528 pthread_cleanup_push (cl, NULL);
529
530 sigpause (sigmask (SIGINT));
531
532 pthread_cleanup_pop (0);
533
534 FAIL_EXIT1 ("sigpause returned");
535 }
536
537
538 static void *
539 tf_sigsuspend (void *arg)
540 {
541 xpthread_barrier_wait (&b2);
542
543 if (arg != NULL)
544 xpthread_barrier_wait (&b2);
545
546 pthread_cleanup_push (cl, NULL);
547
548 /* Just for fun block all signals. */
549 sigset_t mask;
550 sigfillset (&mask);
551 sigsuspend (&mask);
552
553 pthread_cleanup_pop (0);
554
555 FAIL_EXIT1 ("sigsuspend returned");
556 }
557
558
559 static void *
560 tf_sigwait (void *arg)
561 {
562 xpthread_barrier_wait (&b2);
563
564 if (arg != NULL)
565 xpthread_barrier_wait (&b2);
566
567 /* Block SIGUSR1. */
568 sigset_t mask;
569 sigemptyset (&mask);
570 sigaddset (&mask, SIGUSR1);
571 TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
572
573 int sig;
574 pthread_cleanup_push (cl, NULL);
575
576 /* Wait for SIGUSR1. */
577 sigwait (&mask, &sig);
578
579 pthread_cleanup_pop (0);
580
581 FAIL_EXIT1 ("sigwait returned with signal %d", sig);
582 }
583
584
585 static void *
586 tf_sigwaitinfo (void *arg)
587 {
588 xpthread_barrier_wait (&b2);
589
590 if (arg != NULL)
591 xpthread_barrier_wait (&b2);
592
593 /* Block SIGUSR1. */
594 sigset_t mask;
595 sigemptyset (&mask);
596 sigaddset (&mask, SIGUSR1);
597 TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
598
599 siginfo_t info;
600 pthread_cleanup_push (cl, NULL);
601
602 /* Wait for SIGUSR1. */
603 sigwaitinfo (&mask, &info);
604
605 pthread_cleanup_pop (0);
606
607 FAIL_EXIT1 ("sigwaitinfo returned with signal %d", info.si_signo);
608 }
609
610
611 static void *
612 tf_sigtimedwait (void *arg)
613 {
614 xpthread_barrier_wait (&b2);
615
616 if (arg != NULL)
617 xpthread_barrier_wait (&b2);
618
619 /* Block SIGUSR1. */
620 sigset_t mask;
621 sigemptyset (&mask);
622 sigaddset (&mask, SIGUSR1);
623 TEST_VERIFY_EXIT (pthread_sigmask (SIG_BLOCK, &mask, NULL) == 0);
624
625 /* Wait for SIGUSR1. */
626 siginfo_t info;
627 struct timespec ts = { .tv_sec = 60, .tv_nsec = 0 };
628 pthread_cleanup_push (cl, NULL);
629
630 sigtimedwait (&mask, &info, &ts);
631
632 pthread_cleanup_pop (0);
633
634 FAIL_EXIT1 ("sigtimedwait returned with signal %d", info.si_signo);
635 }
636
637
638 static void *
639 tf_pause (void *arg)
640 {
641 xpthread_barrier_wait (&b2);
642
643 if (arg != NULL)
644 xpthread_barrier_wait (&b2);
645
646 pthread_cleanup_push (cl, NULL);
647
648 pause ();
649
650 pthread_cleanup_pop (0);
651
652 FAIL_EXIT1 ("pause returned");
653 }
654
655
656 static void *
657 tf_accept (void *arg)
658 {
659 struct sockaddr_un sun;
660 /* To test a non-blocking accept call we make the call file by using
661 a datagrame socket. */
662 int pf = arg == NULL ? SOCK_STREAM : SOCK_DGRAM;
663
664 tempfd = socket (AF_UNIX, pf, 0);
665 if (tempfd == -1)
666 FAIL_EXIT1 ("socket (AF_UNIX, %s, 0): %m", arg == NULL ? "SOCK_STREAM"
667 : "SOCK_DGRAM");
668
669 int tries = 0;
670 do
671 {
672 TEST_VERIFY_EXIT (tries++ < 10);
673
674 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
675 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
676
677 sun.sun_family = AF_UNIX;
678 }
679 while (bind (tempfd, (struct sockaddr *) &sun,
680 offsetof (struct sockaddr_un, sun_path)
681 + strlen (sun.sun_path) + 1) != 0);
682
683 unlink (sun.sun_path);
684
685 listen (tempfd, 5);
686
687 socklen_t len = sizeof (sun);
688
689 xpthread_barrier_wait (&b2);
690
691 if (arg != NULL)
692 xpthread_barrier_wait (&b2);
693
694 pthread_cleanup_push (cl, NULL);
695
696 accept (tempfd, (struct sockaddr *) &sun, &len);
697
698 pthread_cleanup_pop (0);
699
700 FAIL_EXIT1 ("accept returned");
701 }
702
703
704 static void *
705 tf_send (void *arg)
706 {
707 struct sockaddr_un sun;
708
709 tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
710 if (tempfd == -1)
711 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
712
713 int tries = 0;
714 do
715 {
716 TEST_VERIFY_EXIT (tries++ < 10);
717
718 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
719 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
720
721 sun.sun_family = AF_UNIX;
722 }
723 while (bind (tempfd, (struct sockaddr *) &sun,
724 offsetof (struct sockaddr_un, sun_path)
725 + strlen (sun.sun_path) + 1) != 0);
726
727 listen (tempfd, 5);
728
729 tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
730 if (tempfd2 == -1)
731 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
732
733 set_socket_buffer (tempfd2);
734
735 if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
736 FAIL_EXIT1 ("connect: %m");
737
738 unlink (sun.sun_path);
739
740 xpthread_barrier_wait (&b2);
741
742 if (arg != NULL)
743 xpthread_barrier_wait (&b2);
744
745 pthread_cleanup_push (cl, NULL);
746
747 char mem[WRITE_BUFFER_SIZE];
748
749 send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0);
750 /* The send can return a value higher than 0 (meaning partial send)
751 due to the SIGCANCEL, but the thread may still be pending
752 cancellation. */
753 pthread_testcancel ();
754
755 pthread_cleanup_pop (0);
756
757 FAIL_EXIT1 ("send returned");
758 }
759
760
761 static void *
762 tf_recv (void *arg)
763 {
764 struct sockaddr_un sun;
765
766 tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
767 if (tempfd == -1)
768 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
769
770 int tries = 0;
771 do
772 {
773 TEST_VERIFY_EXIT (tries++ < 10);
774
775 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
776 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
777
778 sun.sun_family = AF_UNIX;
779 }
780 while (bind (tempfd, (struct sockaddr *) &sun,
781 offsetof (struct sockaddr_un, sun_path)
782 + strlen (sun.sun_path) + 1) != 0);
783
784 listen (tempfd, 5);
785
786 tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
787 if (tempfd2 == -1)
788 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
789
790 if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
791 FAIL_EXIT1 ("connect: %m");
792
793 unlink (sun.sun_path);
794
795 xpthread_barrier_wait (&b2);
796
797 if (arg != NULL)
798 xpthread_barrier_wait (&b2);
799
800 pthread_cleanup_push (cl, NULL);
801
802 char mem[70];
803
804 recv (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0);
805
806 pthread_cleanup_pop (0);
807
808 FAIL_EXIT1 ("recv returned");
809 }
810
811
812 static void *
813 tf_recvfrom (void *arg)
814 {
815 struct sockaddr_un sun;
816
817 tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
818 if (tempfd == -1)
819 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
820
821 int tries = 0;
822 do
823 {
824 TEST_VERIFY_EXIT (tries++ < 10);
825
826 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
827 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
828
829 sun.sun_family = AF_UNIX;
830 }
831 while (bind (tempfd, (struct sockaddr *) &sun,
832 offsetof (struct sockaddr_un, sun_path)
833 + strlen (sun.sun_path) + 1) != 0);
834
835 tempfname = strdup (sun.sun_path);
836
837 tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
838 if (tempfd2 == -1)
839 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
840
841 xpthread_barrier_wait (&b2);
842
843 if (arg != NULL)
844 xpthread_barrier_wait (&b2);
845
846 pthread_cleanup_push (cl, NULL);
847
848 char mem[70];
849 socklen_t len = sizeof (sun);
850
851 recvfrom (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0,
852 (struct sockaddr *) &sun, &len);
853
854 pthread_cleanup_pop (0);
855
856 FAIL_EXIT1 ("recvfrom returned");
857 }
858
859
860 static void *
861 tf_recvmsg (void *arg)
862 {
863 struct sockaddr_un sun;
864
865 tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
866 if (tempfd == -1)
867 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
868
869 int tries = 0;
870 do
871 {
872 TEST_VERIFY_EXIT (tries++ < 10);
873
874 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
875 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
876
877 sun.sun_family = AF_UNIX;
878 }
879 while (bind (tempfd, (struct sockaddr *) &sun,
880 offsetof (struct sockaddr_un, sun_path)
881 + strlen (sun.sun_path) + 1) != 0);
882
883 tempfname = strdup (sun.sun_path);
884
885 tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
886 if (tempfd2 == -1)
887 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
888
889 xpthread_barrier_wait (&b2);
890
891 if (arg != NULL)
892 xpthread_barrier_wait (&b2);
893
894 pthread_cleanup_push (cl, NULL);
895
896 char mem[70];
897 struct iovec iov[1];
898 iov[0].iov_base = mem;
899 iov[0].iov_len = arg == NULL ? sizeof (mem) : 0;
900
901 struct msghdr m;
902 m.msg_name = &sun;
903 m.msg_namelen = sizeof (sun);
904 m.msg_iov = iov;
905 m.msg_iovlen = 1;
906 m.msg_control = NULL;
907 m.msg_controllen = 0;
908
909 recvmsg (tempfd2, &m, 0);
910
911 pthread_cleanup_pop (0);
912
913 FAIL_EXIT1 ("recvmsg returned");
914 }
915
916 static void *
917 tf_open (void *arg)
918 {
919 if (arg == NULL)
920 {
921 fifofd = mkfifo (fifoname, S_IWUSR | S_IRUSR);
922 if (fifofd == -1)
923 FAIL_EXIT1 ("mkfifo: %m");
924 }
925 else
926 {
927 xpthread_barrier_wait (&b2);
928 }
929
930 xpthread_barrier_wait (&b2);
931
932 pthread_cleanup_push (cl_fifo, NULL);
933
934 open (arg ? "Makefile" : fifoname, O_RDONLY);
935
936 pthread_cleanup_pop (0);
937
938 FAIL_EXIT1 ("open returned");
939 }
940
941
942 static void *
943 tf_close (void *arg)
944 {
945 if (arg == NULL)
946 // XXX If somebody can provide a portable test case in which close()
947 // blocks we can enable this test to run in both rounds.
948 abort ();
949
950 char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
951 tempfd = mkstemp (fname);
952 if (tempfd == -1)
953 FAIL_EXIT1 ("mkstemp failed: %m");
954 unlink (fname);
955
956 xpthread_barrier_wait (&b2);
957
958 xpthread_barrier_wait (&b2);
959
960 pthread_cleanup_push (cl, NULL);
961
962 close (tempfd);
963
964 pthread_cleanup_pop (0);
965
966 FAIL_EXIT1 ("close returned");
967 }
968
969
970 static void *
971 tf_pread (void *arg)
972 {
973 if (arg == NULL)
974 // XXX If somebody can provide a portable test case in which pread()
975 // blocks we can enable this test to run in both rounds.
976 abort ();
977
978 tempfd = open ("Makefile", O_RDONLY);
979 if (tempfd == -1)
980 FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
981
982 xpthread_barrier_wait (&b2);
983
984 xpthread_barrier_wait (&b2);
985
986 pthread_cleanup_push (cl, NULL);
987
988 char mem[10];
989 pread (tempfd, mem, sizeof (mem), 0);
990
991 pthread_cleanup_pop (0);
992
993 FAIL_EXIT1 ("pread returned");
994 }
995
996
997 static void *
998 tf_pwrite (void *arg)
999 {
1000 if (arg == NULL)
1001 // XXX If somebody can provide a portable test case in which pwrite()
1002 // blocks we can enable this test to run in both rounds.
1003 abort ();
1004
1005 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
1006 tempfd = mkstemp (fname);
1007 if (tempfd == -1)
1008 FAIL_EXIT1 ("mkstemp failed: %m");
1009 unlink (fname);
1010
1011 xpthread_barrier_wait (&b2);
1012
1013 xpthread_barrier_wait (&b2);
1014
1015 pthread_cleanup_push (cl, NULL);
1016
1017 char mem[10];
1018 pwrite (tempfd, mem, sizeof (mem), 0);
1019
1020 pthread_cleanup_pop (0);
1021
1022 FAIL_EXIT1 ("pwrite returned");
1023 }
1024
1025 static void *
1026 tf_preadv (void *arg)
1027 {
1028 int fd;
1029
1030 if (arg == NULL)
1031 /* XXX If somebody can provide a portable test case in which preadv
1032 blocks we can enable this test to run in both rounds. */
1033 abort ();
1034
1035 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
1036 tempfd = fd = mkstemp (fname);
1037 if (fd == -1)
1038 FAIL_EXIT1 ("mkstemp failed: %m");
1039 unlink (fname);
1040
1041 xpthread_barrier_wait (&b2);
1042
1043 xpthread_barrier_wait (&b2);
1044
1045 ssize_t s;
1046 pthread_cleanup_push (cl, NULL);
1047
1048 char buf[100];
1049 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
1050 s = preadv (fd, iov, 1, 0);
1051
1052 pthread_cleanup_pop (0);
1053
1054 FAIL_EXIT1 ("preadv returns with %zd", s);
1055 }
1056
1057 static void *
1058 tf_pwritev (void *arg)
1059 {
1060 int fd;
1061
1062 if (arg == NULL)
1063 /* XXX If somebody can provide a portable test case in which pwritev
1064 blocks we can enable this test to run in both rounds. */
1065 abort ();
1066
1067 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
1068 tempfd = fd = mkstemp (fname);
1069 if (fd == -1)
1070 FAIL_EXIT1 ("mkstemp failed: %m");
1071 unlink (fname);
1072
1073 xpthread_barrier_wait (&b2);
1074
1075 xpthread_barrier_wait (&b2);
1076
1077 ssize_t s;
1078 pthread_cleanup_push (cl, NULL);
1079
1080 char buf[WRITE_BUFFER_SIZE];
1081 memset (buf, '\0', sizeof (buf));
1082 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
1083 s = pwritev (fd, iov, 1, 0);
1084
1085 pthread_cleanup_pop (0);
1086
1087 FAIL_EXIT1 ("pwritev returns with %zd", s);
1088 }
1089
1090 static void *
1091 tf_pwritev2 (void *arg)
1092 {
1093 int fd;
1094
1095 if (arg == NULL)
1096 /* XXX If somebody can provide a portable test case in which pwritev2
1097 blocks we can enable this test to run in both rounds. */
1098 abort ();
1099
1100 errno = 0;
1101
1102 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
1103 tempfd = fd = mkstemp (fname);
1104 if (fd == -1)
1105 FAIL_EXIT1 ("mkstemp: %m");
1106 unlink (fname);
1107
1108 xpthread_barrier_wait (&b2);
1109
1110 xpthread_barrier_wait (&b2);
1111
1112 ssize_t s;
1113 pthread_cleanup_push (cl, NULL);
1114
1115 char buf[WRITE_BUFFER_SIZE];
1116 memset (buf, '\0', sizeof (buf));
1117 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
1118 s = pwritev2 (fd, iov, 1, 0, 0);
1119
1120 pthread_cleanup_pop (0);
1121
1122 FAIL_EXIT1 ("pwritev2 returns with %zd", s);
1123 }
1124
1125 static void *
1126 tf_preadv2 (void *arg)
1127 {
1128 int fd;
1129
1130 if (arg == NULL)
1131 /* XXX If somebody can provide a portable test case in which preadv2
1132 blocks we can enable this test to run in both rounds. */
1133 abort ();
1134
1135 errno = 0;
1136
1137 char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
1138 tempfd = fd = mkstemp (fname);
1139 if (fd == -1)
1140 FAIL_EXIT1 ("mkstemp failed: %m");
1141 unlink (fname);
1142
1143 xpthread_barrier_wait (&b2);
1144
1145 xpthread_barrier_wait (&b2);
1146
1147 ssize_t s;
1148 pthread_cleanup_push (cl, NULL);
1149
1150 char buf[100];
1151 struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
1152 s = preadv2 (fd, iov, 1, 0, 0);
1153
1154 pthread_cleanup_pop (0);
1155
1156 FAIL_EXIT1 ("preadv2 returns with %zd", s);
1157 }
1158
1159 static void *
1160 tf_fsync (void *arg)
1161 {
1162 if (arg == NULL)
1163 // XXX If somebody can provide a portable test case in which fsync()
1164 // blocks we can enable this test to run in both rounds.
1165 abort ();
1166
1167 tempfd = open ("Makefile", O_RDONLY);
1168 if (tempfd == -1)
1169 FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
1170
1171 xpthread_barrier_wait (&b2);
1172
1173 xpthread_barrier_wait (&b2);
1174
1175 pthread_cleanup_push (cl, NULL);
1176
1177 fsync (tempfd);
1178
1179 pthread_cleanup_pop (0);
1180
1181 FAIL_EXIT1 ("fsync returned");
1182 }
1183
1184
1185 static void *
1186 tf_fdatasync (void *arg)
1187 {
1188 if (arg == NULL)
1189 // XXX If somebody can provide a portable test case in which fdatasync()
1190 // blocks we can enable this test to run in both rounds.
1191 abort ();
1192
1193 tempfd = open ("Makefile", O_RDONLY);
1194 if (tempfd == -1)
1195 FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
1196
1197 xpthread_barrier_wait (&b2);
1198
1199 xpthread_barrier_wait (&b2);
1200
1201 pthread_cleanup_push (cl, NULL);
1202
1203 fdatasync (tempfd);
1204
1205 pthread_cleanup_pop (0);
1206
1207 FAIL_EXIT1 ("fdatasync returned");
1208 }
1209
1210
1211 static void *
1212 tf_msync (void *arg)
1213 {
1214 if (arg == NULL)
1215 // XXX If somebody can provide a portable test case in which msync()
1216 // blocks we can enable this test to run in both rounds.
1217 abort ();
1218
1219 tempfd = open ("Makefile", O_RDONLY);
1220 if (tempfd == -1)
1221 FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
1222
1223 void *p = xmmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd);
1224
1225 xpthread_barrier_wait (&b2);
1226
1227 xpthread_barrier_wait (&b2);
1228
1229 pthread_cleanup_push (cl, NULL);
1230
1231 msync (p, 10, 0);
1232
1233 pthread_cleanup_pop (0);
1234
1235 FAIL_EXIT1 ("msync returned");
1236 }
1237
1238
1239 static void *
1240 tf_sendto (void *arg)
1241 {
1242 struct sockaddr_un sun;
1243
1244 tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
1245 if (tempfd == -1)
1246 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
1247
1248 int tries = 0;
1249 do
1250 {
1251 TEST_VERIFY_EXIT (tries++ < 10);
1252
1253 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
1254 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
1255
1256 sun.sun_family = AF_UNIX;
1257 }
1258 while (bind (tempfd, (struct sockaddr *) &sun,
1259 offsetof (struct sockaddr_un, sun_path)
1260 + strlen (sun.sun_path) + 1) != 0);
1261
1262 listen (tempfd, 5);
1263
1264 tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
1265 if (tempfd2 == -1)
1266 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
1267
1268 set_socket_buffer (tempfd2);
1269
1270 if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
1271 FAIL_EXIT1 ("connect: %m");
1272
1273 unlink (sun.sun_path);
1274
1275 xpthread_barrier_wait (&b2);
1276
1277 if (arg != NULL)
1278 xpthread_barrier_wait (&b2);
1279
1280 pthread_cleanup_push (cl, NULL);
1281
1282 char mem[WRITE_BUFFER_SIZE];
1283
1284 sendto (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0, NULL, 0);
1285
1286 pthread_cleanup_pop (0);
1287
1288 FAIL_EXIT1 ("sendto returned");
1289 }
1290
1291
1292 static void *
1293 tf_sendmsg (void *arg)
1294 {
1295 if (arg == NULL)
1296 // XXX If somebody can provide a portable test case in which sendmsg()
1297 // blocks we can enable this test to run in both rounds.
1298 abort ();
1299
1300 struct sockaddr_un sun;
1301
1302 tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
1303 if (tempfd == -1)
1304 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
1305
1306 int tries = 0;
1307 do
1308 {
1309 TEST_VERIFY_EXIT (tries++ < 10);
1310
1311 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
1312 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
1313
1314 sun.sun_family = AF_UNIX;
1315 }
1316 while (bind (tempfd, (struct sockaddr *) &sun,
1317 offsetof (struct sockaddr_un, sun_path)
1318 + strlen (sun.sun_path) + 1) != 0);
1319 tempfname = strdup (sun.sun_path);
1320
1321 tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
1322 if (tempfd2 == -1)
1323 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
1324
1325 xpthread_barrier_wait (&b2);
1326
1327 xpthread_barrier_wait (&b2);
1328
1329 pthread_cleanup_push (cl, NULL);
1330
1331 char mem[1];
1332 struct iovec iov[1];
1333 iov[0].iov_base = mem;
1334 iov[0].iov_len = 1;
1335
1336 struct msghdr m;
1337 m.msg_name = &sun;
1338 m.msg_namelen = (offsetof (struct sockaddr_un, sun_path)
1339 + strlen (sun.sun_path) + 1);
1340 m.msg_iov = iov;
1341 m.msg_iovlen = 1;
1342 m.msg_control = NULL;
1343 m.msg_controllen = 0;
1344
1345 sendmsg (tempfd2, &m, 0);
1346
1347 pthread_cleanup_pop (0);
1348
1349 FAIL_EXIT1 ("sendmsg returned");
1350 }
1351
1352
1353 static void *
1354 tf_creat (void *arg)
1355 {
1356 if (arg == NULL)
1357 // XXX If somebody can provide a portable test case in which sendmsg()
1358 // blocks we can enable this test to run in both rounds.
1359 abort ();
1360
1361 xpthread_barrier_wait (&b2);
1362
1363 xpthread_barrier_wait (&b2);
1364
1365 pthread_cleanup_push (cl, NULL);
1366
1367 creat ("tmp/tst-cancel-4-should-not-exist", 0666);
1368
1369 pthread_cleanup_pop (0);
1370
1371 FAIL_EXIT1 ("creat returned");
1372 }
1373
1374
1375 static void *
1376 tf_connect (void *arg)
1377 {
1378 if (arg == NULL)
1379 // XXX If somebody can provide a portable test case in which connect()
1380 // blocks we can enable this test to run in both rounds.
1381 abort ();
1382
1383 struct sockaddr_un sun;
1384
1385 tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
1386 if (tempfd == -1)
1387 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
1388
1389 int tries = 0;
1390 do
1391 {
1392 TEST_VERIFY_EXIT (tries++ < 10);
1393
1394 strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
1395 TEST_VERIFY_EXIT (mktemp (sun.sun_path) != NULL);
1396
1397 sun.sun_family = AF_UNIX;
1398 }
1399 while (bind (tempfd, (struct sockaddr *) &sun,
1400 offsetof (struct sockaddr_un, sun_path)
1401 + strlen (sun.sun_path) + 1) != 0);
1402 tempfname = strdup (sun.sun_path);
1403
1404 listen (tempfd, 5);
1405
1406 tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
1407 if (tempfd2 == -1)
1408 FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
1409
1410 xpthread_barrier_wait (&b2);
1411
1412 if (arg != NULL)
1413 xpthread_barrier_wait (&b2);
1414
1415 pthread_cleanup_push (cl, NULL);
1416
1417 connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun));
1418
1419 pthread_cleanup_pop (0);
1420
1421 FAIL_EXIT1 ("connect returned");
1422 }
1423
1424
1425 static void *
1426 tf_tcdrain (void *arg)
1427 {
1428 if (arg == NULL)
1429 // XXX If somebody can provide a portable test case in which tcdrain()
1430 // blocks we can enable this test to run in both rounds.
1431 abort ();
1432
1433 xpthread_barrier_wait (&b2);
1434
1435 if (arg != NULL)
1436 xpthread_barrier_wait (&b2);
1437
1438 pthread_cleanup_push (cl, NULL);
1439
1440 /* Regardless of stderr being a terminal, the tcdrain call should be
1441 canceled. */
1442 tcdrain (STDERR_FILENO);
1443
1444 pthread_cleanup_pop (0);
1445
1446 FAIL_EXIT1 ("tcdrain returned");
1447 }
1448
1449
1450 static void *
1451 tf_msgrcv (void *arg)
1452 {
1453 tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
1454 if (tempmsg == -1)
1455 FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
1456
1457 xpthread_barrier_wait (&b2);
1458
1459 if (arg != NULL)
1460 xpthread_barrier_wait (&b2);
1461
1462 ssize_t s;
1463
1464 pthread_cleanup_push (cl, NULL);
1465
1466 struct
1467 {
1468 long int type;
1469 char mem[10];
1470 } m;
1471 int randnr;
1472 /* We need a positive random number. */
1473 do
1474 randnr = random () % 64000;
1475 while (randnr <= 0);
1476 do
1477 {
1478 errno = 0;
1479 s = msgrcv (tempmsg, (struct msgbuf *) &m, 10, randnr, 0);
1480 }
1481 while (errno == EIDRM || errno == EINTR);
1482
1483 pthread_cleanup_pop (0);
1484
1485 msgctl (tempmsg, IPC_RMID, NULL);
1486
1487 FAIL_EXIT1 ("msgrcv returned %zd", s);
1488 }
1489
1490
1491 static void *
1492 tf_msgsnd (void *arg)
1493 {
1494 if (arg == NULL)
1495 // XXX If somebody can provide a portable test case in which msgsnd()
1496 // blocks we can enable this test to run in both rounds.
1497 abort ();
1498
1499 tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
1500 if (tempmsg == -1)
1501 FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
1502
1503 xpthread_barrier_wait (&b2);
1504
1505 xpthread_barrier_wait (&b2);
1506
1507 pthread_cleanup_push (cl, NULL);
1508
1509 struct
1510 {
1511 long int type;
1512 char mem[1];
1513 } m;
1514 /* We need a positive random number. */
1515 do
1516 m.type = random () % 64000;
1517 while (m.type <= 0);
1518 msgsnd (tempmsg, (struct msgbuf *) &m, sizeof (m.mem), 0);
1519
1520 pthread_cleanup_pop (0);
1521
1522 msgctl (tempmsg, IPC_RMID, NULL);
1523
1524 FAIL_EXIT1 ("msgsnd returned");
1525 }
1526
1527
1528 struct cancel_tests tests[] =
1529 {
1530 ADD_TEST (read, 2, 0),
1531 ADD_TEST (readv, 2, 0),
1532 ADD_TEST (select, 2, 0),
1533 ADD_TEST (pselect, 2, 0),
1534 ADD_TEST (poll, 2, 0),
1535 ADD_TEST (ppoll, 2, 0),
1536 ADD_TEST (write, 2, 0),
1537 ADD_TEST (writev, 2, 0),
1538 ADD_TEST (sleep, 2, 0),
1539 ADD_TEST (usleep, 2, 0),
1540 ADD_TEST (nanosleep, 2, 0),
1541 ADD_TEST (wait, 2, 0),
1542 ADD_TEST (waitid, 2, 0),
1543 ADD_TEST (waitpid, 2, 0),
1544 ADD_TEST (sigpause, 2, 0),
1545 ADD_TEST (sigsuspend, 2, 0),
1546 ADD_TEST (sigwait, 2, 0),
1547 ADD_TEST (sigwaitinfo, 2, 0),
1548 ADD_TEST (sigtimedwait, 2, 0),
1549 ADD_TEST (pause, 2, 0),
1550 ADD_TEST (accept, 2, 0),
1551 ADD_TEST (send, 2, 0),
1552 ADD_TEST (recv, 2, 0),
1553 ADD_TEST (recvfrom, 2, 0),
1554 ADD_TEST (recvmsg, 2, 0),
1555 ADD_TEST (preadv, 2, 1),
1556 ADD_TEST (preadv2, 2, 1),
1557 ADD_TEST (pwritev, 2, 1),
1558 ADD_TEST (pwritev2, 2, 1),
1559 ADD_TEST (open, 2, 1),
1560 ADD_TEST (close, 2, 1),
1561 ADD_TEST (pread, 2, 1),
1562 ADD_TEST (pwrite, 2, 1),
1563 ADD_TEST (fsync, 2, 1),
1564 ADD_TEST (fdatasync, 2, 1),
1565 ADD_TEST (msync, 2, 1),
1566 ADD_TEST (sendto, 2, 1),
1567 ADD_TEST (sendmsg, 2, 1),
1568 ADD_TEST (creat, 2, 1),
1569 ADD_TEST (connect, 2, 1),
1570 ADD_TEST (tcdrain, 2, 1),
1571 ADD_TEST (msgrcv, 2, 0),
1572 ADD_TEST (msgsnd, 2, 1),
1573 };
1574 #define ntest_tf (sizeof (tests) / sizeof (tests[0]))
1575
1576 #include "tst-cancel4-common.c"