summary refs log tree commit diff
path: root/rt
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-01-06 09:23:26 +0000
committerJakub Jelinek <jakub@redhat.com>2006-01-06 09:23:26 +0000
commitdd486f53ee367e1667c61ec1fffdb59f9a8130e9 (patch)
tree6e85e00b5a067e5717c98dcadbcc6303118ffad7 /rt
parent04c414477bd220f2c842453314a6dbb928e3c9e6 (diff)
downloadglibc-dd486f53ee367e1667c61ec1fffdb59f9a8130e9.tar.gz
glibc-dd486f53ee367e1667c61ec1fffdb59f9a8130e9.tar.xz
glibc-dd486f53ee367e1667c61ec1fffdb59f9a8130e9.zip
Updated to fedora-glibc-20060106T0916 cvs/fedora-glibc-2_3_90-28
Diffstat (limited to 'rt')
-rw-r--r--rt/Makefile5
-rw-r--r--rt/tst-aio10.c119
-rw-r--r--rt/tst-aio3.c22
-rw-r--r--rt/tst-aio8.c39
-rw-r--r--rt/tst-aio9.c124
5 files changed, 302 insertions, 7 deletions
diff --git a/rt/Makefile b/rt/Makefile
index cc01cb95c9..f8487975dd 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1997-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1997-2004, 2006 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
@@ -43,7 +43,8 @@ librt-routines = $(aio-routines) \
 
 tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \
 	 tst-aio tst-aio64 tst-aio2 tst-aio3 tst-aio4 tst-aio5 tst-aio6 \
-	 tst-aio7 tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \
+	 tst-aio7 tst-aio8 tst-aio9 tst-aio10 \
+	 tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \
 	 tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \
 	 tst-timer3 tst-timer4 tst-timer5 \
 	 tst-cpuclock1 tst-cpuclock2 \
diff --git a/rt/tst-aio10.c b/rt/tst-aio10.c
new file mode 100644
index 0000000000..6e8f7b78c0
--- /dev/null
+++ b/rt/tst-aio10.c
@@ -0,0 +1,119 @@
+#include <aio.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+
+static pthread_barrier_t b;
+static pthread_t main_thread;
+static int flag;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  /* There is unfortunately no other way to try to make sure the other
+     thread reached the aio_suspend call.  This test could fail on
+     highly loaded machines.  */
+  sleep (2);
+
+  pthread_kill (main_thread, SIGUSR1);
+
+  while (1)
+    sleep (1000);
+
+  return NULL;
+}
+
+
+static void
+sh (int sig)
+{
+  flag = 1;
+}
+
+
+static int
+do_test (void)
+{
+  main_thread = pthread_self ();
+
+  struct sigaction sa;
+
+  sa.sa_handler = sh;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  if (sigaction (SIGUSR1, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init");
+      return 1;
+    }
+
+  int fds[2];
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  char buf[42];
+  struct aiocb req;
+  req.aio_fildes = fds[0];
+  req.aio_lio_opcode = LIO_READ;
+  req.aio_reqprio = 0;
+  req.aio_offset = 0;
+  req.aio_buf = buf;
+  req.aio_nbytes = sizeof (buf);
+  req.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+  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 ("parent: barrier_wait failed");
+      exit (1);
+    }
+
+  struct aiocb *list[1];
+  list[0] = &req;
+
+  e = lio_listio (LIO_WAIT, list, 1, NULL);
+  if (e != -1)
+    {
+      puts ("lio_listio succeeded");
+      return 1;
+    }
+  if (errno != EINTR)
+    {
+      printf ("lio_listio did not return EINTR: %d (%d = %m)\n", e, errno);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include "../test-skeleton.c"
diff --git a/rt/tst-aio3.c b/rt/tst-aio3.c
index 0c0ced4501..95da4c1325 100644
--- a/rt/tst-aio3.c
+++ b/rt/tst-aio3.c
@@ -1,5 +1,5 @@
 /* Test for notification mechanism in lio_listio.
-   Copyright (C) 2000,02 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2006 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
@@ -24,13 +24,18 @@
 #include <unistd.h>
 #include <errno.h>
 
-int flag;
+static pthread_barrier_t b;
 
 
 static void
 thrfct (sigval_t arg)
 {
-  flag = 1;
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
 }
 
 
@@ -52,6 +57,12 @@ do_test (int argc, char *argv[])
 
   unlink (name);
 
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
   arr[0] = &cb;
 
   cb.aio_fildes = fd;
@@ -82,9 +93,10 @@ do_test (int argc, char *argv[])
       return 1;
     }
 
-  if (flag != 0)
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
     {
-      puts ("thread created, should not have happened");
+      puts ("parent: barrier_wait failed");
       return 1;
     }
 
diff --git a/rt/tst-aio8.c b/rt/tst-aio8.c
new file mode 100644
index 0000000000..b03639dabd
--- /dev/null
+++ b/rt/tst-aio8.c
@@ -0,0 +1,39 @@
+#include <aio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+  int fd = open ("/dev/full", O_RDWR);
+  if (fd == -1)
+    {
+      puts ("could not open /dev/full");
+      return 0;
+    }
+
+  struct aiocb req;
+  req.aio_fildes = fd;
+  req.aio_lio_opcode = LIO_WRITE;
+  req.aio_reqprio = 0;
+  req.aio_buf = (void *) "hello";
+  req.aio_nbytes = 5;
+  req.aio_offset = 0;
+  req.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+  struct aiocb *list[1];
+  list[0] = &req;
+
+  int r = lio_listio (LIO_WAIT, list, 1, NULL);
+  int e = errno;
+
+  printf ("r = %d, e = %d (%s)\n", r, e, strerror (e));
+
+  return r != -1 || e != EIO;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/rt/tst-aio9.c b/rt/tst-aio9.c
new file mode 100644
index 0000000000..eab4f6859a
--- /dev/null
+++ b/rt/tst-aio9.c
@@ -0,0 +1,124 @@
+#include <aio.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+
+static pthread_barrier_t b;
+static pthread_t main_thread;
+static int flag;
+
+
+static void *
+tf (void *arg)
+{
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
+
+  /* There is unfortunately no other way to try to make sure the other
+     thread reached the aio_suspend call.  This test could fail on
+     highly loaded machines.  */
+  sleep (2);
+
+  pthread_kill (main_thread, SIGUSR1);
+
+  while (1)
+    sleep (1000);
+
+  return NULL;
+}
+
+
+static void
+sh (int sig)
+{
+  flag = 1;
+}
+
+
+static int
+do_test (void)
+{
+  main_thread = pthread_self ();
+
+  struct sigaction sa;
+
+  sa.sa_handler = sh;
+  sa.sa_flags = 0;
+  sigemptyset (&sa.sa_mask);
+
+  if (sigaction (SIGUSR1, &sa, NULL) != 0)
+    {
+      puts ("sigaction failed");
+      return 1;
+    }
+
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init");
+      return 1;
+    }
+
+  int fds[2];
+  if (pipe (fds) != 0)
+    {
+      puts ("pipe failed");
+      return 1;
+    }
+
+  char buf[42];
+  struct aiocb req;
+  req.aio_fildes = fds[0];
+  req.aio_reqprio = 0;
+  req.aio_offset = 0;
+  req.aio_buf = buf;
+  req.aio_nbytes = sizeof (buf);
+  req.aio_sigevent.sigev_notify = SIGEV_NONE;
+
+  if (aio_read (&req) != 0)
+    {
+      puts ("aio_read failed");
+      return 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 ("parent: barrier_wait failed");
+      exit (1);
+    }
+
+  const struct aiocb *list[1];
+  list[0] = &req;
+
+  e = aio_suspend (list, 1, NULL);
+  if (e != -1)
+    {
+      puts ("aio_suspend succeeded");
+      return 1;
+    }
+  if (errno != EINTR)
+    {
+      puts ("aio_suspend did not return EINTR");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include "../test-skeleton.c"