]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added test for LinuxThreads detection.
authorBart Van Assche <bvanassche@acm.org>
Sun, 9 Mar 2008 16:16:06 +0000 (16:16 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 9 Mar 2008 16:16:06 +0000 (16:16 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7616

exp-drd/tests/Makefile.am
exp-drd/tests/linuxthreads_det.c [new file with mode: 0644]
exp-drd/tests/linuxthreads_det.stderr.exp [new file with mode: 0644]
exp-drd/tests/linuxthreads_det.stdout.exp [new file with mode: 0644]
exp-drd/tests/linuxthreads_det.vgtest [new file with mode: 0644]

index 2761e13bf48c9f58788f610f19db0a207a19db0b..02f9405d64a2fcdfb1d8a152ae9409ec425e3f79 100644 (file)
@@ -42,11 +42,14 @@ EXTRA_DIST =                                        \
        hg06_readshared.stderr.exp                  \
        hg06_readshared.stderr.exp-linuxthreads     \
        hg06_readshared.vgtest                      \
+       linuxthreads_det.stderr.exp                 \
+       linuxthreads_det.stderr.exp-linuxthreads    \
+       linuxthreads_det.stdout.exp                 \
+       linuxthreads_det.stdout.exp-linuxthreads    \
        matinv.stderr.exp                           \
        matinv.stderr.exp-linuxthreads              \
        matinv.stdout.exp                           \
        matinv.stdout.exp-linuxthreads              \
-       matinv.stdout.exp-linuxthreads              \
        matinv.vgtest                               \
        pth_barrier.stderr.exp                      \
        pth_barrier.stderr.exp-linuxthreads         \
@@ -194,6 +197,7 @@ check_PROGRAMS_COMMON = \
   hg04_race           \
   hg05_race2          \
   hg06_readshared     \
+  linuxthreads_det    \
   matinv              \
   pth_barrier         \
   pth_broadcast       \
@@ -261,13 +265,16 @@ hg05_race2_LDADD            = -lpthread
 hg06_readshared_SOURCES     = ../../helgrind/tests/hg06_readshared.c
 hg06_readshared_LDADD       = -lpthread
 
+linuxthreads_det_SOURCES    = linuxthreads_det.c
+linuxthreads_det_LDADD      = -lpthread
+
 matinv_SOURCES              = matinv.c
 matinv_LDADD                = -lpthread -lm
 
 if HAVE_GCC_FOPENMP
 matinv_openmp_SOURCES       = matinv_openmp.c
 matinv_openmp_CFLAGS        = -fopenmp
-matinv_openmp_LDADD         = -lpthread -lm
+matinv_openmp_LDADD         = -lm
 endif
 
 pth_barrier_SOURCES         = pth_barrier.c
diff --git a/exp-drd/tests/linuxthreads_det.c b/exp-drd/tests/linuxthreads_det.c
new file mode 100644 (file)
index 0000000..8d8f663
--- /dev/null
@@ -0,0 +1,41 @@
+/** Test whether DRD recognizes LinuxThreads as LinuxThreads and NPTL as
+ *  NPTL.
+ */
+
+
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static sem_t s_sem;
+static pid_t s_main_thread_pid;
+
+
+void* thread_func(void* arg)
+{
+  if (s_main_thread_pid == getpid())
+  {
+    printf("NPTL or non-Linux POSIX threads implemenentation detected.\n");
+  }
+  else
+  {
+    printf("Detected LinuxThreads as POSIX threads implemenentation.\n");
+  }
+  sem_post(&s_sem);
+  return 0;
+}
+
+int main(int argc, char** argv)
+{
+  pthread_t threadid;
+
+  s_main_thread_pid = getpid();
+  sem_init(&s_sem, 0, 0);
+  pthread_create(&threadid, 0, thread_func, 0);
+  sem_wait(&s_sem);
+  pthread_join(threadid, 0);
+  sem_destroy(&s_sem);
+  return 0;
+}
diff --git a/exp-drd/tests/linuxthreads_det.stderr.exp b/exp-drd/tests/linuxthreads_det.stderr.exp
new file mode 100644 (file)
index 0000000..d18786f
--- /dev/null
@@ -0,0 +1,3 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
diff --git a/exp-drd/tests/linuxthreads_det.stdout.exp b/exp-drd/tests/linuxthreads_det.stdout.exp
new file mode 100644 (file)
index 0000000..3406754
--- /dev/null
@@ -0,0 +1 @@
+NPTL or non-Linux POSIX threads implemenentation detected.
diff --git a/exp-drd/tests/linuxthreads_det.vgtest b/exp-drd/tests/linuxthreads_det.vgtest
new file mode 100644 (file)
index 0000000..fc5bb67
--- /dev/null
@@ -0,0 +1 @@
+prog: linuxthreads_det