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:00:39 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-02-09 17:00:44 +0000
commit71d52ac4d65435791d8fa9f52abab7107ef7f7e8 (patch)
tree3166281a996db9450cc47a1b35a2fb54bc92f988 /nptl
parent900778283ac3cfbd274abc55840b5cdae9b7745f (diff)
downloadglibc-71d52ac4d65435791d8fa9f52abab7107ef7f7e8.tar.gz
glibc-71d52ac4d65435791d8fa9f52abab7107ef7f7e8.tar.xz
glibc-71d52ac4d65435791d8fa9f52abab7107ef7f7e8.zip
pthread: Move spin tests from nptl to sysdeps/pthread
So they can be checked with htl too.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile1
-rw-r--r--nptl/tst-spin1.c56
-rw-r--r--nptl/tst-spin2.c158
-rw-r--r--nptl/tst-spin3.c53
-rw-r--r--nptl/tst-spin4.c108
5 files changed, 0 insertions, 376 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index 812d01a4e1..baa6c66778 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -240,7 +240,6 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-mutex7robust tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 \
 	tst-mutexpi5 tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a \
 	tst-mutexpi9 \
-	tst-spin1 tst-spin2 tst-spin3 tst-spin4 \
 	tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
 	tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
 	tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
diff --git a/nptl/tst-spin1.c b/nptl/tst-spin1.c
deleted file mode 100644
index 3480f407c4..0000000000
--- a/nptl/tst-spin1.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 2002-2020 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, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <pthread.h>
-#include <stdio.h>
-
-
-static int
-do_test (void)
-{
-  pthread_spinlock_t s;
-
-  if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
-    {
-      puts ("spin_init failed");
-      return 1;
-    }
-
-  if (pthread_spin_lock (&s) != 0)
-    {
-      puts ("spin_lock failed");
-      return 1;
-    }
-
-  if (pthread_spin_unlock (&s) != 0)
-    {
-      puts ("spin_unlock failed");
-      return 1;
-    }
-
-  if (pthread_spin_destroy (&s) != 0)
-    {
-      puts ("spin_destroy failed");
-      return 1;
-    }
-
-  return 0;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/nptl/tst-spin2.c b/nptl/tst-spin2.c
deleted file mode 100644
index 135228a958..0000000000
--- a/nptl/tst-spin2.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Copyright (C) 2002-2020 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, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-
-
-static int
-do_test (void)
-{
-  size_t ps = sysconf (_SC_PAGESIZE);
-  char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
-  char data[ps];
-  void *mem;
-  int fd;
-  pthread_spinlock_t *s;
-  pid_t pid;
-  char *p;
-  int err;
-
-  fd = mkstemp (tmpfname);
-  if (fd == -1)
-    {
-      printf ("cannot open temporary file: %m\n");
-      return 1;
-    }
-
-  /* Make sure it is always removed.  */
-  unlink (tmpfname);
-
-  /* Create one page of data.  */
-  memset (data, '\0', ps);
-
-  /* Write the data to the file.  */
-  if (write (fd, data, ps) != (ssize_t) ps)
-    {
-      puts ("short write");
-      return 1;
-    }
-
-  mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-  if (mem == MAP_FAILED)
-    {
-      printf ("mmap failed: %m\n");
-      return 1;
-    }
-
-  s = (pthread_spinlock_t *) (((uintptr_t) mem
-			       + __alignof (pthread_spinlock_t))
-			      & ~(__alignof (pthread_spinlock_t) - 1));
-  p = (char *) (s + 1);
-
-  if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
-    {
-      puts ("spin_init failed");
-      return 1;
-    }
-
-  if (pthread_spin_lock (s) != 0)
-    {
-      puts ("spin_lock failed");
-      return 1;
-    }
-
-  err = pthread_spin_trylock (s);
-  if (err == 0)
-    {
-      puts ("1st spin_trylock succeeded");
-      return 1;
-    }
-  else if (err != EBUSY)
-    {
-      puts ("1st spin_trylock didn't return EBUSY");
-      return 1;
-    }
-
-  err = pthread_spin_unlock (s);
-  if (err != 0)
-    {
-      puts ("parent: spin_unlock failed");
-      return 1;
-    }
-
-  err = pthread_spin_trylock (s);
-  if (err != 0)
-    {
-      puts ("2nd spin_trylock failed");
-      return 1;
-    }
-
-  *p = 0;
-
-  puts ("going to fork now");
-  pid = fork ();
-  if (pid == -1)
-    {
-      puts ("fork failed");
-      return 1;
-    }
-  else if (pid == 0)
-    {
-      /* Play some lock ping-pong.  It's our turn to unlock first.  */
-      if ((*p)++ != 0)
-	{
-	  puts ("child: *p != 0");
-	  return 1;
-	}
-
-      if (pthread_spin_unlock (s) != 0)
-	{
-	  puts ("child: 1st spin_unlock failed");
-	  return 1;
-	}
-
-      puts ("child done");
-    }
-  else
-    {
-      if (pthread_spin_lock (s) != 0)
-	{
-	  puts ("parent: 2nd spin_lock failed");
-	  return 1;
-	}
-
-      puts ("waiting for child");
-
-      waitpid (pid, NULL, 0);
-
-      puts ("parent done");
-    }
-
-  return 0;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
diff --git a/nptl/tst-spin3.c b/nptl/tst-spin3.c
deleted file mode 100644
index d64dab4443..0000000000
--- a/nptl/tst-spin3.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2002-2020 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, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-
-static int do_test (void);
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
-
-static int
-do_test (void)
-{
-  pthread_spinlock_t s;
-
-  if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
-    {
-      puts ("spin_init failed");
-      return 1;
-    }
-
-  if (pthread_spin_lock (&s) != 0)
-    {
-      puts ("1st spin_lock failed");
-      return 1;
-    }
-
-  delayed_exit (1);
-
-  /* This call should never return.  */
-  xpthread_spin_lock (&s);
-
-  puts ("2nd spin_lock returned");
-  return 1;
-}
diff --git a/nptl/tst-spin4.c b/nptl/tst-spin4.c
deleted file mode 100644
index 99fe7aa6aa..0000000000
--- a/nptl/tst-spin4.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-
-static int count = 0;
-
-static void *
-thread_add_one (void *arg)
-{
-  int tmp;
-  pthread_spinlock_t *lock = (pthread_spinlock_t *) arg;
-
-  /* When do_test holds the lock for 1 sec, the two thread will be
-     in contention for the lock. */
-  if (pthread_spin_lock (lock) != 0)
-    {
-      puts ("thread_add_one(): spin_lock failed");
-      pthread_exit ((void *) 1l);
-    }
-
-  /* sleep 1s before modifying count */
-  tmp = count;
-  sleep (1);
-  count = tmp + 1;
-
-  if (pthread_spin_unlock (lock) != 0)
-    {
-      puts ("thread_add_one(): spin_unlock failed");
-      pthread_exit ((void *) 1l);
-    }
-
-  return NULL;
-}
-
-static int
-do_test (void)
-{
-  pthread_t thr1, thr2;
-  pthread_spinlock_t lock;
-  int tmp;
-
-  if (pthread_spin_init (&lock, PTHREAD_PROCESS_PRIVATE) != 0)
-    {
-      puts ("spin_init failed");
-      return 1;
-    }
-
-  if (pthread_spin_lock (&lock) != 0)
-    {
-      puts ("1st spin_lock failed");
-      return 1;
-    }
-
-  if (pthread_create (&thr1, NULL, thread_add_one, (void *) &lock) != 0)
-    {
-      puts ("1st pthread_create failed");
-      return 1;
-    }
-
-  if (pthread_create (&thr2, NULL, thread_add_one, (void *) &lock) != 0)
-    {
-      puts ("2nd pthread_create failed");
-      return 1;
-    }
-
-  /* sleep 1s before modifying count */
-  tmp = count;
-  sleep (1);
-  count = tmp + 1;
-
-  if (pthread_spin_unlock (&lock) != 0)
-    {
-      puts ("1st spin_unlock failed");
-      return 1;
-    }
-
-  void *status;
-  if (pthread_join (thr1, &status) != 0)
-    {
-      puts ("1st pthread_join failed");
-      return 1;
-    }
-  if (status != NULL)
-    {
-      puts ("failure in the 1st thread");
-      return 1;
-    }
-  if (pthread_join (thr2, &status) != 0)
-    {
-      puts ("2nd pthread_join failed");
-      return 1;
-    }
-  if (status != NULL)
-    {
-      puts ("failure in the 2nd thread");
-      return 1;
-    }
-
-  if (count != 3)
-    {
-      printf ("count is %d, should be 3\n", count);
-      return 1;
-    }
-  return 0;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"