#!/bin/sh # $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/jmc_script/Attic/do_test_2+2,v 1.1 2007/11/25 21:14:57 jmc Exp $ # $Name: $ usage() { echo "Usage: `basename $0` [OPTIONS]" echo " -> perform test 2+2=4 for several experiments" echo "" echo "where possible OPTIONS are:" echo " -help : print usage" echo " -t LIST_EXP : only check experiments in LIST_EXP" echo " -skd LIST_EXP : skip experiments in LIST_EXP" echo " -clean : clean output & reset" exit } CLEAN=0 TESTDIRS= SKIPDIRS= SCRIPT='tst_2+2' here=`pwd` yy= for xx do if test -n "$yy"; then eval "$yy=\$xx" yy= else case $xx in -help ) usage ;; -clean) CLEAN=1 ;; -t ) yy=TESTDIRS ;; -skd ) yy=SKIPDIRS ;; *) echo "Error: unrecognized option: "$xx ; usage ; exit ;; esac fi done #------------------------ if test "x$TESTDIRS" = x then TESTDIRS=`ls ` #TESTDIRS=`ls | grep -v 'fizhi-cs' | grep -v 'tutorial_cfc_offline'` fi LIST="" for xx in $TESTDIRS do yy=`echo $SKIPDIRS | grep -c $xx` if test $yy = 0 ; then if test -f $xx/results/output.txt then LIST=${LIST}" "$xx # else # echo ""; echo -n " -- skip \"$xx\" (not a directory !)" fi # else # echo ""; echo -n " -- skip \"$xx\" (excluded)" fi done if test -x $SCRIPT ; then echo "run script '$SCRIPT' for experiment in:" echo " $LIST" yy=`echo $SCRIPT | grep -c '^\/'` if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi else echo "ERROR: script '$SCRIPT' not found or not executable" exit fi echo "" #------------------------ if test $CLEAN = 1 ; then for xx in $LIST do listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` for yy in $listD do if test -r $xx/$yy/data.tst then echo "clean dir:" $xx/$yy cd $xx/$yy echo ' ' >> outp.tst_2+2.log echo $SCRIPT 4 >> outp.tst_2+2.log $SCRIPT 4 >> outp.tst_2+2.log 2>&1 cd $here fi done done exit fi #------------------------ if test -f tst_2+2_out.txt ; then mv -f tst_2+2_out.txt tst_2+2_out.old ; fi date > tst_2+2_out.txt echo 'test 2+2=4 summary :' >> tst_2+2_out.txt for xx in $LIST do echo ============================================================================== listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` for yy in $listD do if test -f $xx/$yy/output.txt then if test $yy = 'run' ; then nam=$xx else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi echo -n "Entering $xx/$yy :" cd $xx/$yy echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log $SCRIPT All >> outp.tst_2+2.log 2>&1 out=$? if test $out = '0' then echo " pass <- $nam" >> ../../tst_2+2_out.txt echo ' pass test 2+2=4' else echo "FAIL ($out) - $nam" >> ../../tst_2+2_out.txt echo " test 2+2=4 FAIL (exit $out)" echo " " tail -5 outp.tst_2+2.log echo " " fi cd $here fi done done date >> tst_2+2_out.txt