From: Bart Van Assche Date: Sat, 11 Oct 2008 18:04:52 +0000 (+0000) Subject: Added omp_printf regression test. X-Git-Tag: svn/VALGRIND_3_4_0~233 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=688a7ee6568947392ce4f847bb68684a1ca20483;p=thirdparty%2Fvalgrind.git Added omp_printf regression test. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8655 --- diff --git a/drd/tests/Makefile.am b/drd/tests/Makefile.am index 2757fc9215..82c129f26b 100644 --- a/drd/tests/Makefile.am +++ b/drd/tests/Makefile.am @@ -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 index 0000000000..3066a44bcb --- /dev/null +++ b/drd/tests/omp_printf.c @@ -0,0 +1,50 @@ +/* Simple OpenMP test program that calls printf() from a parallel section. */ + +#include +#include +#include // getopt() + +static void usage(const char* const exe) +{ + printf("Usage: %s [-h] [-q] [-r] [-t] \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 index 0000000000..f711c765c9 --- /dev/null +++ b/drd/tests/omp_printf.stderr.exp @@ -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 index 0000000000..a2901075ac --- /dev/null +++ b/drd/tests/omp_printf.vgtest @@ -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