]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
DRD: Added a regression test.
authorBart Van Assche <bvanassche@acm.org>
Wed, 9 Mar 2011 17:50:34 +0000 (17:50 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 9 Mar 2011 17:50:34 +0000 (17:50 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11613

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

index adbc39dc9020315ccd7740f1b3c845b54ad51bf1..b6f40f8ab8502cefef97410343862225112966dc 100644 (file)
@@ -146,6 +146,8 @@ EXTRA_DIST =                                        \
        pth_detached2.stderr.exp                    \
        pth_detached2.stdout.exp                    \
        pth_detached2.vgtest                        \
+       pth_detached3.stderr.exp                    \
+       pth_detached3.vgtest                        \
        pth_detached_sem.stderr.exp                 \
        pth_detached_sem.stdout.exp                 \
        pth_detached_sem.vgtest                     \
@@ -285,6 +287,7 @@ check_PROGRAMS =      \
   pth_create_chain    \
   pth_detached        \
   pth_detached_sem    \
+  pth_detached3       \
   pth_inconsistent_cond_wait \
   pth_mutex_reinit    \
   pth_process_shared_mutex   \
diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c
new file mode 100644 (file)
index 0000000..12a7a14
--- /dev/null
@@ -0,0 +1,29 @@
+/* Invoke pthread_detach() with an invalid thread ID. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+static void* thread_func(void* arg)
+{
+  return 0;
+}
+
+int main(int argc, char** argv)
+{
+  pthread_t thread;
+
+  pthread_create(&thread, NULL, thread_func, NULL);
+  pthread_join(thread, NULL);
+
+  /* Invoke pthread_detach() with the thread ID of a joined thread. */
+  pthread_detach(thread);
+
+  /* Invoke pthread_detach() with an invalid thread ID. */
+  pthread_detach(thread + 1);
+
+  fprintf(stderr, "Finished.\n");
+
+  return 0;
+}
diff --git a/drd/tests/pth_detached3.stderr.exp b/drd/tests/pth_detached3.stderr.exp
new file mode 100644 (file)
index 0000000..58412ec
--- /dev/null
@@ -0,0 +1,12 @@
+
+pthread_detach(): invalid thread ID 0x........
+   at 0x........: pthread_detach (drd_pthread_intercepts.c:?)
+   by 0x........: main (pth_detached3.c:21)
+
+pthread_detach(): invalid thread ID 0x........
+   at 0x........: pthread_detach (drd_pthread_intercepts.c:?)
+   by 0x........: main (pth_detached3.c:24)
+
+Finished.
+
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
diff --git a/drd/tests/pth_detached3.vgtest b/drd/tests/pth_detached3.vgtest
new file mode 100644 (file)
index 0000000..9c72be7
--- /dev/null
@@ -0,0 +1,2 @@
+prereq: ./supported_libpthread
+prog: pth_detached3