]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added omp_printf regression test.
authorBart Van Assche <bvanassche@acm.org>
Sat, 11 Oct 2008 18:04:52 +0000 (18:04 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 11 Oct 2008 18:04:52 +0000 (18:04 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8655

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

index 2757fc921540b857a7a2a05de8fa55d093edb1d1..82c129f26b8a9c5b0bbbec1c0f1683d2624fa673 100644 (file)
@@ -66,6 +66,8 @@ EXTRA_DIST =                                        \
        omp_matinv_racy.vgtest                      \
        omp_prime_racy.stderr.exp                   \
        omp_prime_racy.vgtest                       \
+       omp_printf.stderr.exp                       \
+       omp_printf.vgtest                           \
        pth_barrier.stderr.exp                      \
        pth_barrier.vgtest                          \
        pth_barrier2.stderr.exp                     \
@@ -250,7 +252,7 @@ check_PROGRAMS += qt4_mutex qt4_rwlock qt4_semaphore
 endif
 
 if HAVE_OPENMP
-check_PROGRAMS += omp_matinv omp_prime
+check_PROGRAMS += omp_matinv omp_prime omp_printf
 endif
 
 
@@ -440,4 +442,9 @@ omp_prime_SOURCES           = omp_prime.c
 omp_prime_CFLAGS            = $(AM_CFLAGS) -fopenmp
 omp_prime_LDFLAGS           = -fopenmp
 omp_prime_LDADD             = -lm
+
+omp_printf_SOURCES          = omp_printf.c
+omp_printf_CFLAGS           = $(AM_CFLAGS) -fopenmp
+omp_printf_LDFLAGS          = -fopenmp
+omp_printf_LDADD            = -lm
 endif
diff --git a/drd/tests/omp_printf.c b/drd/tests/omp_printf.c
new file mode 100644 (file)
index 0000000..3066a44
--- /dev/null
@@ -0,0 +1,50 @@
+/* Simple OpenMP test program that calls printf() from a parallel section. */
+
+#include <omp.h>
+#include <stdio.h>
+#include <unistd.h>  // getopt()
+
+static void usage(const char* const exe)
+{
+  printf("Usage: %s [-h] [-q] [-r] [-t<n>] <m>\n"
+         "-h: display this information.\n"
+         "-q: quiet mode -- do not print computed error.\n",
+         exe);
+}
+
+int main(int argc, char** argv)
+{
+  int i;
+  int optchar;
+  int silent = 0;
+  int tid;
+
+  while ((optchar = getopt(argc, argv, "hq")) != EOF)
+  {
+    switch (optchar)
+    {
+    case 'h': usage(argv[0]); return 1;
+    case 'q': silent = 1; break;
+    default:
+      return 1;
+    }
+  }
+
+#pragma omp parallel private(tid)
+  for (i = 0; i < 2; i++)
+  {
+    tid = omp_get_thread_num();
+    if (! silent)
+    {
+      printf("omp_get_thread_num() = %d/%d\n", tid, omp_get_num_threads());
+    }
+    else
+    {
+      printf("%s", "");
+    }
+  }
+
+  fprintf(stderr, "Finished.\n");
+
+  return 0;
+}
diff --git a/drd/tests/omp_printf.stderr.exp b/drd/tests/omp_printf.stderr.exp
new file mode 100644 (file)
index 0000000..f711c76
--- /dev/null
@@ -0,0 +1 @@
+ERROR SUMMARY: 8 errors from 8 contexts
diff --git a/drd/tests/omp_printf.vgtest b/drd/tests/omp_printf.vgtest
new file mode 100644 (file)
index 0000000..a290107
--- /dev/null
@@ -0,0 +1,5 @@
+prereq: ./run_openmp_test ./omp_printf
+prog: omp_printf
+vgopts: --check-stack-var=yes --var-info=yes
+args: -q
+stderr_filter: filter_error_summary