aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-06-14 16:15:39 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-06-14 16:16:59 +0000
commit45fce058fe7c9a14800a10564a7bc1970f4c7c49 (patch)
tree73beb97bba4d931136d3d5d5d3c8f114846dd049 /nptl
parent662de0889a040e3ebeefcfdde547edc8a11f87d7 (diff)
downloadglibc-45fce058fe7c9a14800a10564a7bc1970f4c7c49.zip
glibc-45fce058fe7c9a14800a10564a7bc1970f4c7c49.tar.gz
glibc-45fce058fe7c9a14800a10564a7bc1970f4c7c49.tar.bz2
htl: Enable more cancellation tests
* nptl/tst-cancel-self-cancelstate.c, tst-cancel-self.c, tst-cancel9.c, tst-cancelx9.c: Move to... * sysdeps/pthread: ... here. * nptl/Makefile: Move corresponding references and rules to... * sysdeps/pthread/Makefile: ... here.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile3
-rw-r--r--nptl/tst-cancel-self-cancelstate.c65
-rw-r--r--nptl/tst-cancel-self.c48
-rw-r--r--nptl/tst-cancel9.c125
-rw-r--r--nptl/tst-cancelx9.c1
5 files changed, 1 insertions, 241 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index c431ead..3356f2a 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -278,9 +278,8 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
tst-sem17 \
tst-tsd3 tst-tsd4 \
tst-cancel4 tst-cancel4_1 tst-cancel4_2 tst-cancel5 \
- tst-cancel7 tst-cancel9 tst-cancel13 \
+ tst-cancel7 tst-cancel13 \
tst-cancel16 tst-cancel17 tst-cancel20 tst-cancel24 \
- tst-cancel-self tst-cancel-self-cancelstate \
tst-cleanup4 \
tst-signal3 \
tst-exec4 tst-exec5 \
diff --git a/nptl/tst-cancel-self-cancelstate.c b/nptl/tst-cancel-self-cancelstate.c
deleted file mode 100644
index d1d2b50c..0000000
--- a/nptl/tst-cancel-self-cancelstate.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "tst-cancel-self-cleanup.c"
-
-
-static int
-do_test (void)
-{
- int ret = 0;
- volatile int should_fail = 1;
-
- pthread_cleanup_push (cleanup, (void *) &should_fail);
-
- if ((ret = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL)) != 0)
- {
- printf ("setcancelstate(disable) failed: %s\n", strerror (ret));
- exit (1);
- }
-
- if ((ret = pthread_cancel (pthread_self ())) != 0)
- {
- printf ("cancel failed: %s\n", strerror (ret));
- exit (1);
- }
-
- usleep (100);
- should_fail = 0;
-
- if ((ret = pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL)) != 0)
- {
- printf ("setcancelstate(enable) failed: %s\n", strerror (ret));
- exit (1);
- }
-
- /* The write syscall within this printf should give us our cancellation
- point. */
- printf ("Could not cancel self.\n");
- pthread_cleanup_pop (0);
-
- return 1;
-}
-
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/nptl/tst-cancel-self.c b/nptl/tst-cancel-self.c
deleted file mode 100644
index 9d7316d..0000000
--- a/nptl/tst-cancel-self.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "tst-cancel-self-cleanup.c"
-
-
-static int
-do_test (void)
-{
- int ret = 0, should_fail = 0;
-
- pthread_cleanup_push (cleanup, &should_fail);
- if ((ret = pthread_cancel (pthread_self ())) != 0)
- {
- printf ("cancel failed: %s\n", strerror (ret));
- exit (1);
- }
-
- /* The write syscall within this printf should give us our cancellation
- point. */
- printf ("Could not cancel self.\n");
- pthread_cleanup_pop (0);
-
- return 1;
-}
-
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/nptl/tst-cancel9.c b/nptl/tst-cancel9.c
deleted file mode 100644
index 02d7c3a..0000000
--- a/nptl/tst-cancel9.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-
-static pthread_barrier_t b;
-
-
-static void
-cleanup (void *arg)
-{
- fputs ("in cleanup\n", stdout);
-}
-
-
-static void *
-tf (void *arg)
-{
- int fd = open ("/dev/null", O_RDWR);
- if (fd == -1)
- {
- puts ("cannot open /dev/null");
- exit (1);
- }
- FILE *fp = fdopen (fd, "w");
- if (fp == NULL)
- {
- puts ("fdopen failed");
- exit (1);
- }
-
- pthread_cleanup_push (cleanup, NULL);
-
- int e = pthread_barrier_wait (&b);
- if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
- {
- puts ("barrier_wait failed");
- exit (1);
- }
-
- while (1)
- /* fprintf() uses write() which is a cancallation point. */
- fprintf (fp, "foo");
-
- pthread_cleanup_pop (0);
-
- return NULL;
-}
-
-
-static int
-do_test (void)
-{
- if (pthread_barrier_init (&b, NULL, 2) != 0)
- {
- puts ("barrier_init failed");
- exit (1);
- }
-
- pthread_t th;
- if (pthread_create (&th, NULL, tf, NULL) != 0)
- {
- puts ("create failed");
- return 1;
- }
-
- int e = pthread_barrier_wait (&b);
- if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
- {
- puts ("barrier_wait failed");
- exit (1);
- }
-
- sleep (1);
-
- puts ("cancel now");
-
- if (pthread_cancel (th) != 0)
- {
- puts ("cancel failed");
- exit (1);
- }
-
- puts ("waiting for the child");
-
- void *r;
- if (pthread_join (th, &r) != 0)
- {
- puts ("join failed");
- exit (1);
- }
-
- if (r != PTHREAD_CANCELED)
- {
- puts ("thread wasn't canceled");
- exit (1);
- }
-
- return 0;
-}
-
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/nptl/tst-cancelx9.c b/nptl/tst-cancelx9.c
deleted file mode 100644
index 9d84663..0000000
--- a/nptl/tst-cancelx9.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "tst-cancel9.c"