From 25486d50895fa4a30809d289b9aff4de583a9b84 Mon Sep 17 00:00:00 2001 From: Mike McGreevy Date: Wed, 8 Dec 2010 15:56:28 -0500 Subject: [svn-r19879] Purpose: Improve portability of flushrefresh test. Description: The flush/refresh API test was hanging on linew because Solaris's 'date' tool does not recognize the "+%s" option, which returns time since the epoch on other UNIXes. There doesn't seem to be a good way to unify the tools, however, Perl can be easily used for this function. I've modified configure to always check for the existence of Perl (previously it only did so if GNU compilers were being used), and the flush/refresh test script now uses perl to perform this timestamping functionality rather than date, by default. (if Perl is not detected by configure, the script will use date as it did prior to this modification). Fixed a few other compatibility issues w/ Solaris in passing: - fixed 'head' and 'tail' parameters to be more portable - avoid passing NULL to an fprintf call in flushrefresh.c Tested: - Tested testflushrefresh.sh on jam, linew, heiwa, liberty, duty, ember, and abe. --- configure | 7 ++----- configure.in | 9 ++------- src/Makefile.in | 8 ++++---- test/flushrefresh.c | 19 +++++++++++++++++-- test/testflushrefresh.sh.in | 32 ++++++++++++++++++++++++++------ 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 92df1c4..399efba 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 19714 2010-11-02 19:00:56Z mamcgree . +# From configure.in Id: configure.in 19715 2010-11-02 20:14:08Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.67 for HDF5 1.9.79-FA_a5. # @@ -7072,9 +7072,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - PERL="" -if test "X$GCC" = "Xyes"; then - for ac_prog in perl +for ac_prog in perl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -7116,7 +7114,6 @@ fi test -n "$PERL" && break done -fi if test -z "$AR"; then diff --git a/configure.in b/configure.in index 558793a..1b639c1 100644 --- a/configure.in +++ b/configure.in @@ -610,13 +610,8 @@ dnl Change back to the C language AC_LANG_POP(C++) dnl ---------------------------------------------------------------------- -dnl Check if they have Perl installed on their system. We only need Perl -dnl if they're using a GNU compiler. -dnl -AC_SUBST([PERL]) PERL="" -if test "X$GCC" = "Xyes"; then - AC_CHECK_PROGS([PERL], [perl],, [$PATH]) -fi +dnl Check if they have Perl installed on their system. +AC_CHECK_PROGS([PERL], [perl],, [$PATH]) dnl ---------------------------------------------------------------------- diff --git a/src/Makefile.in b/src/Makefile.in index 1c757d3..5e9040c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -103,8 +103,8 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Dbtree.lo H5Dbtree2.lo H5Dchunk.lo H5Dcompact.lo \ H5Dcontig.lo H5Ddbg.lo H5Ddeprec.lo H5Dearray.lo H5Defl.lo \ H5Dfarray.lo H5Dfill.lo H5Dint.lo H5Dio.lo H5Dlayout.lo \ - H5Dmpio.lo H5Doh.lo H5Dproxy.lo H5Dscatgath.lo H5Dselect.lo \ - H5Dtest.lo H5Dnone.lo H5E.lo H5Edeprec.lo H5Eint.lo H5EA.lo \ + H5Dmpio.lo H5Dnone.lo H5Doh.lo H5Dproxy.lo H5Dscatgath.lo \ + H5Dselect.lo H5Dtest.lo H5E.lo H5Edeprec.lo H5Eint.lo H5EA.lo \ H5EAcache.lo H5EAdbg.lo H5EAdblkpage.lo H5EAdblock.lo \ H5EAhdr.lo H5EAiblock.lo H5EAint.lo H5EAsblock.lo H5EAstat.lo \ H5EAtest.lo H5F.lo H5Faccum.lo H5Fdbg.lo H5Fdeprec.lo \ @@ -481,8 +481,8 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5C.c H5CS.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c H5Dint.c \ - H5Dio.c H5Dlayout.c H5Dmpio.c H5Doh.c H5Dproxy.c H5Dscatgath.c \ - H5Dselect.c H5Dtest.c H5Dnone.c \ + H5Dio.c H5Dlayout.c H5Dmpio.c H5Dnone.c H5Doh.c H5Dproxy.c H5Dscatgath.c \ + H5Dselect.c H5Dtest.c \ H5E.c H5Edeprec.c H5Eint.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \ diff --git a/test/flushrefresh.c b/test/flushrefresh.c index c79b445..223cf8d 100755 --- a/test/flushrefresh.c +++ b/test/flushrefresh.c @@ -1174,11 +1174,26 @@ error: */ void send_signal(const char * send, const char * arg1, const char * arg2) { - FILE *signalfile; + + FILE *signalfile = NULL; /* Create signal file (which will send signal to some other process) */ signalfile = fopen(send, "w+"); - HDfprintf(signalfile, "%s\n%s\n", arg1, arg2); + + /* Write messages to signal file, if provided */ + if (arg2 != NULL) { + HDassert(arg1); + HDfprintf(signalfile, "%s\n%s\n", arg1, arg2); + } /* end if */ + else if (arg1 != NULL) { + HDassert(arg2 == NULL); + HDfprintf(signalfile, "%s\n", arg1); + } /* end if */ + else { + HDassert(arg1 == NULL); + HDassert(arg2 == NULL); + }/* end else */ + HDfflush(signalfile); HDfclose(signalfile); diff --git a/test/testflushrefresh.sh.in b/test/testflushrefresh.sh.in index 2d8da8c..732f32b 100755 --- a/test/testflushrefresh.sh.in +++ b/test/testflushrefresh.sh.in @@ -33,8 +33,28 @@ ## test variables ############################################################################### +# Number of errors encountered during test run. nerrors=0 +# Set up a function to check the current time since the epoch - ideally, we'd +# like to use Perl. If it wasn't detected by configure, then use date, though +# this is less portable and might cause problems on machines that don't +# recognize the +%s option (like Solaris). +PERL=@PERL@ +if test -n "$PERL"; then + TimeStamp() + { + time=`${PERL} -e 'print int(time)'` + echo "$time" + } +else + TimeStamp() + { + time=`date +%s` + echo "$time" + } +fi + ############################################################################### ## Main ############################################################################### @@ -65,9 +85,9 @@ verification_done=0 until [ $verification_done -eq 1 ]; do # Wait for signal from test program that verification routine can run. - before=`date +%s` + before=`TimeStamp` until [ -s $startsignal ]; do - after=`date +%s` + after=`TimeStamp` timediff=`expr $after - $before` if [ $timediff -gt $timeout_length ]; then nerrors=`expr $nerrors + 1` @@ -83,8 +103,8 @@ until [ $verification_done -eq 1 ]; do fi # Read in test routine parameters from signal file, then delete signal file. - param1=`head -n 1 $startsignal` - param2=`tail -n 1 $startsignal` + param1=`head -1 $startsignal` + param2=`tail -1 $startsignal` rm $startsignal # Check if we're done with verifications, otherwise run the specified verification. @@ -105,9 +125,9 @@ if [ $timedout -eq 0 ]; then until [ $verification_done -eq 2 ]; do # Wait for signal from test program that verification routine can run. - before=`date +%s` + before=`TimeStamp` until [ -s $startsignal ]; do - after=`date +%s` + after=`TimeStamp` timediff=`expr $after - $before` if [ $timediff -gt $timeout_length ]; then nerrors=`expr $nerrors + 1` -- cgit v0.12