about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-02-09 17:30:30 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-02-09 17:30:30 +0000
commit44a41fc2536f86f95fa7df36a2285101bb4157a3 (patch)
tree8bdb46b949f620f6de7ca469887e1eaede470386 /nptl
parent34f168fb82b992edd3549222486704ee3dd9d1de (diff)
downloadglibc-44a41fc2536f86f95fa7df36a2285101bb4157a3.tar.gz
glibc-44a41fc2536f86f95fa7df36a2285101bb4157a3.tar.xz
glibc-44a41fc2536f86f95fa7df36a2285101bb4157a3.zip
pthread: Move some attr tests from nptl to sysdeps/pthread
So they can be checked with htl too.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/tst-attr1.c305
2 files changed, 1 insertions, 306 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index 774cf0a754..51a0be008b 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -234,7 +234,7 @@ LDLIBS-tst-thread-exit-clobber = -lstdc++
 CFLAGS-tst-minstack-throw.o = -std=gnu++11
 LDLIBS-tst-minstack-throw = -lstdc++
 
-tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
+tests = tst-attr2 tst-attr3 tst-default-attr \
 	tst-mutex5 tst-mutex7 tst-mutex9 tst-mutex11 tst-mutex5a tst-mutex7a \
 	tst-mutex7robust tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 \
 	tst-mutexpi5 tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a \
diff --git a/nptl/tst-attr1.c b/nptl/tst-attr1.c
deleted file mode 100644
index fc247eb723..0000000000
--- a/nptl/tst-attr1.c
+++ /dev/null
@@ -1,305 +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 <errno.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-
-int
-do_test (void)
-{
-  int i;
-  pthread_attr_t a;
-
-  if (pthread_attr_init (&a) != 0)
-    {
-      puts ("attr_init failed");
-      exit (1);
-    }
-
-  pthread_mutexattr_t ma;
-
-  if (pthread_mutexattr_init (&ma) != 0)
-    {
-      puts ("mutexattr_init failed");
-      exit (1);
-    }
-
-  pthread_rwlockattr_t rwa;
-
-  if (pthread_rwlockattr_init (&rwa) != 0)
-    {
-      puts ("rwlockattr_init failed");
-      exit (1);
-    }
-
-  /* XXX Remove if default value is clear.  */
-  pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
-  pthread_attr_setschedpolicy (&a, SCHED_OTHER);
-  pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM);
-
-  for (i = 0; i < 10000; ++i)
-    {
-      long int r = random ();
-
-      if (r != PTHREAD_CREATE_DETACHED && r != PTHREAD_CREATE_JOINABLE)
-	{
-	  int e = pthread_attr_setdetachstate (&a, r);
-
-	  if (e == 0)
-	    {
-	      printf ("attr_setdetachstate with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("attr_setdetachstate didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_attr_getdetachstate (&a, &s) != 0)
-	    {
-	      puts ("attr_getdetachstate failed");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_CREATE_JOINABLE)
-	    {
-	      printf ("\
-detach state changed to %d by invalid setdetachstate call\n", s);
-	      exit (1);
-	    }
-	}
-
-      if (r != PTHREAD_INHERIT_SCHED && r != PTHREAD_EXPLICIT_SCHED)
-	{
-	  int e = pthread_attr_setinheritsched (&a, r);
-
-	  if (e == 0)
-	    {
-	      printf ("attr_setinheritsched with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("attr_setinheritsched didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_attr_getinheritsched (&a, &s) != 0)
-	    {
-	      puts ("attr_getinheritsched failed");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_INHERIT_SCHED)
-	    {
-	      printf ("\
-inheritsched changed to %d by invalid setinheritsched call\n", s);
-	      exit (1);
-	    }
-	}
-
-      if (r != SCHED_OTHER && r != SCHED_RR && r != SCHED_FIFO)
-	{
-	  int e = pthread_attr_setschedpolicy (&a, r);
-
-	  if (e == 0)
-	    {
-	      printf ("attr_setschedpolicy with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("attr_setschedpolicy didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_attr_getschedpolicy (&a, &s) != 0)
-	    {
-	      puts ("attr_getschedpolicy failed");
-	      exit (1);
-	    }
-
-	  if (s != SCHED_OTHER)
-	    {
-	      printf ("\
-schedpolicy changed to %d by invalid setschedpolicy call\n", s);
-	      exit (1);
-	    }
-	}
-
-      if (r != PTHREAD_SCOPE_SYSTEM && r != PTHREAD_SCOPE_PROCESS)
-	{
-	  int e = pthread_attr_setscope (&a, r);
-
-	  if (e == 0)
-	    {
-	      printf ("attr_setscope with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("attr_setscope didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_attr_getscope (&a, &s) != 0)
-	    {
-	      puts ("attr_getscope failed");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_SCOPE_SYSTEM)
-	    {
-	      printf ("\
-contentionscope changed to %d by invalid setscope call\n", s);
-	      exit (1);
-	    }
-	}
-
-      if (r != PTHREAD_PROCESS_PRIVATE && r != PTHREAD_PROCESS_SHARED)
-	{
-	  int e = pthread_mutexattr_setpshared (&ma, r);
-
-	  if (e == 0)
-	    {
-	      printf ("mutexattr_setpshared with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("mutexattr_setpshared didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_mutexattr_getpshared (&ma, &s) != 0)
-	    {
-	      puts ("mutexattr_getpshared failed");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_PROCESS_PRIVATE)
-	    {
-	      printf ("\
-pshared changed to %d by invalid mutexattr_setpshared call\n", s);
-	      exit (1);
-	    }
-
-	  e = pthread_rwlockattr_setpshared (&rwa, r);
-
-	  if (e == 0)
-	    {
-	      printf ("rwlockattr_setpshared with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-	  if (e != EINVAL)
-	    {
-	      puts ("rwlockattr_setpshared didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  if (pthread_rwlockattr_getpshared (&rwa, &s) != 0)
-	    {
-	      puts ("rwlockattr_getpshared failed");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_PROCESS_PRIVATE)
-	    {
-	      printf ("\
-pshared changed to %d by invalid rwlockattr_setpshared call\n", s);
-	      exit (1);
-	    }
-	}
-
-      if (r != PTHREAD_CANCEL_ENABLE && r != PTHREAD_CANCEL_DISABLE)
-	{
-	  int e = pthread_setcancelstate (r, NULL);
-
-	  if (e == 0)
-	    {
-	      printf ("setcancelstate with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-
-	  if (e != EINVAL)
-	    {
-	      puts ("setcancelstate didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &s) != 0)
-	    {
-	      puts ("setcancelstate failed for PTHREAD_CANCEL_ENABLE");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_CANCEL_ENABLE)
-	    {
-	      puts ("invalid setcancelstate changed state");
-	      exit (1);
-	    }
-	}
-
-      if (r != PTHREAD_CANCEL_DEFERRED && r != PTHREAD_CANCEL_ASYNCHRONOUS)
-	{
-	  int e = pthread_setcanceltype (r, NULL);
-
-	  if (e == 0)
-	    {
-	      printf ("setcanceltype with value %ld succeeded\n", r);
-	      exit (1);
-	    }
-
-	  if (e != EINVAL)
-	    {
-	      puts ("setcanceltype didn't return EINVAL");
-	      exit (1);
-	    }
-
-	  int s;
-	  if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &s) != 0)
-	    {
-	      puts ("setcanceltype failed for PTHREAD_CANCEL_DEFERRED");
-	      exit (1);
-	    }
-
-	  if (s != PTHREAD_CANCEL_DEFERRED)
-	    {
-	      puts ("invalid setcanceltype changed state");
-	      exit (1);
-	    }
-	}
-    }
-
-  return 0;
-}
-
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"