summary refs log tree commit diff
path: root/nptl/tst-attr1.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-17 06:44:07 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-17 06:44:07 +0000
commit179ff175dff6afdb1f2a12f8c18fa48b29bbee6a (patch)
tree7891689a20263ab369bc539d24acc38f1b170a8c /nptl/tst-attr1.c
parente4335f9a238ff4016b28b8c8d8a3ff376bf5d1c4 (diff)
downloadglibc-179ff175dff6afdb1f2a12f8c18fa48b29bbee6a.tar.gz
glibc-179ff175dff6afdb1f2a12f8c18fa48b29bbee6a.tar.xz
glibc-179ff175dff6afdb1f2a12f8c18fa48b29bbee6a.zip
Update.
	* tst-attr1.c (do_test): Add tests for pthread_setcanceltype,
	pthread_setcancelstate, and pthread_rwlock_setpshared.
Diffstat (limited to 'nptl/tst-attr1.c')
-rw-r--r--nptl/tst-attr1.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/nptl/tst-attr1.c b/nptl/tst-attr1.c
index c5870beb5b..13b62a69de 100644
--- a/nptl/tst-attr1.c
+++ b/nptl/tst-attr1.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -43,6 +44,14 @@ do_test (void)
       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);
@@ -61,6 +70,11 @@ do_test (void)
 	      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)
@@ -86,6 +100,11 @@ detach state changed to %d by invalid setdetachstate call\n", s);
 	      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)
@@ -111,6 +130,11 @@ inheritsched changed to %d by invalid setinheritsched call\n", s);
 	      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)
@@ -136,6 +160,11 @@ schedpolicy changed to %d by invalid setschedpolicy call\n", s);
 	      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)
@@ -161,6 +190,11 @@ contentionscope changed to %d by invalid setscope call\n", s);
 	      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)
@@ -175,6 +209,92 @@ contentionscope changed to %d by invalid setscope call\n", s);
 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);
+	    }
 	}
     }