diff options
| author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-05 04:25:50 +0000 |
|---|---|---|
| committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2006-02-05 04:25:50 +0000 |
| commit | db453bfe89774049a1122fdd8724506f37d8c2f9 (patch) | |
| tree | df2d1b0fe23fa944af4efc458336b076a53d77e6 | |
| parent | 947a002844d9bfd3b535dc8f30789138cab85e64 (diff) | |
| download | uClibc-alpine-db453bfe89774049a1122fdd8724506f37d8c2f9.tar.bz2 uClibc-alpine-db453bfe89774049a1122fdd8724506f37d8c2f9.tar.xz | |
Clean up failing and passing tests.
| -rw-r--r-- | test/nptl/tst-cleanup0.c | 76 | ||||
| -rw-r--r-- | test/nptl/tst-cleanup4aux.c | 121 | ||||
| -rw-r--r-- | test/nptl/tst-exec2.c | 154 | ||||
| -rw-r--r-- | test/nptl/tst-exec3.c | 152 | ||||
| -rw-r--r-- | test/nptl/tst-exec4.c | 116 |
5 files changed, 197 insertions, 422 deletions
diff --git a/test/nptl/tst-cleanup0.c b/test/nptl/tst-cleanup0.c new file mode 100644 index 000000000..6fc2209cc --- /dev/null +++ b/test/nptl/tst-cleanup0.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + + +static int global; + + +static void +ch (void *arg) +{ + int val = (long int) arg; + + printf ("ch (%d)\n", val); + + global *= val; + global += val; +} + + +static void +endfct (void) +{ + /* We force exit right here. */ + _exit (global); +} + + +static int +do_test (void) +{ + atexit (endfct); + + pthread_cancel (pthread_self ()); + + pthread_cleanup_push (ch, (void *) 1l); + + pthread_cleanup_push (ch, (void *) 2l); + + pthread_cleanup_push (ch, (void *) 3l); + +// pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + + pthread_cleanup_pop (1); + + pthread_cleanup_pop (1); + + pthread_cleanup_pop (1); + + return 100; +} + + +#define EXPECTED_STATUS 9 +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/nptl/tst-cleanup4aux.c b/test/nptl/tst-cleanup4aux.c new file mode 100644 index 000000000..cd1a89ac1 --- /dev/null +++ b/test/nptl/tst-cleanup4aux.c @@ -0,0 +1,121 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer, + void (*__routine) (void *), + void *__arg); +extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer, + int __execute); + +extern void clh (void *arg); +extern void fn0 (void); +extern void fn1 (void); +extern void fn5 (void); +extern void fn7 (void); +extern void fn9 (void); + + +static __attribute__((noinline)) void +fn3 (void) +{ + /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */ + struct _pthread_cleanup_buffer b; + _pthread_cleanup_push (&b, clh, (void *) 4l); + + fn0 (); + + _pthread_cleanup_pop (&b, 1); +} + + +static __attribute__((noinline)) void +fn4 (void) +{ + pthread_cleanup_push (clh, (void *) 5l); + + fn3 (); + + pthread_cleanup_pop (1); +} + + +void +fn5 (void) +{ + /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */ + struct _pthread_cleanup_buffer b; + _pthread_cleanup_push (&b, clh, (void *) 6l); + + fn4 (); + + _pthread_cleanup_pop (&b, 1); +} + + +static __attribute__((noinline)) void +fn6 (void) +{ + pthread_cleanup_push (clh, (void *) 7l); + + fn0 (); + + pthread_cleanup_pop (1); +} + + +void +fn7 (void) +{ + /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */ + struct _pthread_cleanup_buffer b; + _pthread_cleanup_push (&b, clh, (void *) 8l); + + fn6 (); + + _pthread_cleanup_pop (&b, 1); +} + + +static __attribute__((noinline)) void +fn8 (void) +{ + pthread_cleanup_push (clh, (void *) 9l); + + fn1 (); + + pthread_cleanup_pop (1); +} + + +void +fn9 (void) +{ + /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */ + struct _pthread_cleanup_buffer b; + _pthread_cleanup_push (&b, clh, (void *) 10l); + + fn8 (); + + _pthread_cleanup_pop (&b, 1); +} diff --git a/test/nptl/tst-exec2.c b/test/nptl/tst-exec2.c deleted file mode 100644 index 432da32ef..000000000 --- a/test/nptl/tst-exec2.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Thread with running thread calls exec. - Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. - - 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, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <errno.h> -#include <paths.h> -#include <pthread.h> -#include <signal.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/wait.h> - - -static void * -tf (void *arg) -{ - pthread_t th = (pthread_t) arg; - - if (pthread_join (th, NULL) == 0) - { - puts ("thread in parent joined!?"); - exit (1); - } - - puts ("join in thread in parent returned!?"); - exit (1); -} - - -static int -do_test (void) -{ - int fd[2]; - if (pipe (fd) != 0) - { - puts ("pipe failed"); - exit (1); - } - - /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("sigignore failed"); - exit (1); - } - - pid_t pid = fork (); - if (pid == -1) - { - puts ("fork failed"); - exit (1); - } - - if (pid == 0) - { - /* Use the fd for stdout. This is kind of ugly because it - substitutes the fd of stdout but we know what we are doing - here... */ - if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO) - { - puts ("dup2 failed"); - exit (1); - } - - close (fd[0]); - - pthread_t th; - if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0) - { - puts ("create failed"); - exit (1); - } - - execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL); - - puts ("execl failed"); - exit (1); - } - - close (fd[1]); - - char buf[200]; - ssize_t n; - bool seen_pid = false; - while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0) - { - /* We only expect to read the PID. */ - char *endp; - long int rpid = strtol (buf, &endp, 10); - - if (*endp != '\n') - { - printf ("didn't parse whole line: \"%s\"\n", buf); - exit (1); - } - if (endp == buf) - { - puts ("read empty line"); - exit (1); - } - - if (rpid != pid) - { - printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid); - exit (1); - } - - if (seen_pid) - { - puts ("found more than one PID line"); - exit (1); - } - seen_pid = true; - } - - close (fd[0]); - - int status; - int err = waitpid (pid, &status, 0); - if (err != pid) - { - puts ("waitpid failed"); - exit (1); - } - - if (!seen_pid) - { - puts ("didn't get PID"); - exit (1); - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/nptl/tst-exec3.c b/test/nptl/tst-exec3.c deleted file mode 100644 index be49b048c..000000000 --- a/test/nptl/tst-exec3.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Thread calls exec. - Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. - - 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, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <errno.h> -#include <paths.h> -#include <pthread.h> -#include <signal.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/wait.h> - - -static void * -tf (void *arg) -{ - execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL); - - puts ("execl failed"); - exit (1); -} - - -static int -do_test (void) -{ - int fd[2]; - if (pipe (fd) != 0) - { - puts ("pipe failed"); - exit (1); - } - - /* Not interested in knowing when the pipe is closed. */ - if (sigignore (SIGPIPE) != 0) - { - puts ("sigignore failed"); - exit (1); - } - - pid_t pid = fork (); - if (pid == -1) - { - puts ("fork failed"); - exit (1); - } - - if (pid == 0) - { - /* Use the fd for stdout. This is kind of ugly because it - substitutes the fd of stdout but we know what we are doing - here... */ - if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO) - { - puts ("dup2 failed"); - exit (1); - } - - close (fd[0]); - - pthread_t th; - if (pthread_create (&th, NULL, tf, NULL) != 0) - { - puts ("create failed"); - exit (1); - } - - if (pthread_join (th, NULL) == 0) - { - puts ("join succeeded!?"); - exit (1); - } - - puts ("join returned!?"); - exit (1); - } - - close (fd[1]); - - char buf[200]; - ssize_t n; - bool seen_pid = false; - while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0) - { - /* We only expect to read the PID. */ - char *endp; - long int rpid = strtol (buf, &endp, 10); - - if (*endp != '\n') - { - printf ("didn't parse whole line: \"%s\"\n", buf); - exit (1); - } - if (endp == buf) - { - puts ("read empty line"); - exit (1); - } - - if (rpid != pid) - { - printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid); - exit (1); - } - - if (seen_pid) - { - puts ("found more than one PID line"); - exit (1); - } - seen_pid = true; - } - - close (fd[0]); - - int status; - int err = waitpid (pid, &status, 0); - if (err != pid) - { - puts ("waitpid failed"); - exit (1); - } - - if (!seen_pid) - { - puts ("didn't get PID"); - exit (1); - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/nptl/tst-exec4.c b/test/nptl/tst-exec4.c deleted file mode 100644 index b3920a030..000000000 --- a/test/nptl/tst-exec4.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Signal handler and mask set in thread which calls exec. - Copyright (C) 2003 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, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <pthread.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - - -static void * -tf (void *arg) -{ - /* Ignore SIGUSR1 and block SIGUSR2. */ - if (sigignore (SIGUSR1) != 0) - { - puts ("sigignore failed"); - exit (1); - } - - sigset_t ss; - sigemptyset (&ss); - sigaddset (&ss, SIGUSR2); - if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0) - { - puts ("1st run: sigmask failed"); - exit (1); - } - - char **oldargv = (char **) arg; - size_t n = 1; - while (oldargv[n] != NULL) - ++n; - - char **argv = (char **) alloca ((n + 1) * sizeof (char *)); - for (n = 0; oldargv[n + 1] != NULL; ++n) - argv[n] = oldargv[n + 1]; - argv[n++] = (char *) "--direct"; - argv[n] = NULL; - - execv (argv[0], argv); - - puts ("execv failed"); - - exit (1); -} - - -static int -do_test (int argc, char *argv[]) -{ - if (argc == 1) - { - /* This is the second call. Perform the test. */ - struct sigaction sa; - - if (sigaction (SIGUSR1, NULL, &sa) != 0) - { - puts ("2nd run: sigaction failed"); - return 1; - } - if (sa.sa_handler != SIG_IGN) - { - puts ("SIGUSR1 not ignored"); - return 1; - } - - sigset_t ss; - if (pthread_sigmask (SIG_SETMASK, NULL, &ss) != 0) - { - puts ("2nd run: sigmask failed"); - return 1; - } - if (! sigismember (&ss, SIGUSR2)) - { - puts ("SIGUSR2 not blocked"); - return 1; - } - - return 0; - } - - pthread_t th; - if (pthread_create (&th, NULL, tf, argv) != 0) - { - puts ("create failed"); - exit (1); - } - - /* This call should never return. */ - pthread_join (th, NULL); - - puts ("join returned"); - - return 1; -} - -#define TEST_FUNCTION do_test (argc, argv) -#include "../test-skeleton.c" |
