1 |
jmc |
1.1 |
#!/bin/sh |
2 |
|
|
|
3 |
jmc |
1.2 |
# $Header: /u/gcmpack/MITgcm_contrib/jmc_script/do_test_2+2,v 1.1 2007/11/25 21:14:57 jmc Exp $ |
4 |
jmc |
1.1 |
# $Name: $ |
5 |
|
|
|
6 |
|
|
usage() |
7 |
|
|
{ |
8 |
|
|
echo "Usage: `basename $0` [OPTIONS]" |
9 |
|
|
echo " -> perform test 2+2=4 for several experiments" |
10 |
|
|
echo "" |
11 |
|
|
echo "where possible OPTIONS are:" |
12 |
|
|
echo " -help : print usage" |
13 |
|
|
echo " -t LIST_EXP : only check experiments in LIST_EXP" |
14 |
|
|
echo " -skd LIST_EXP : skip experiments in LIST_EXP" |
15 |
|
|
echo " -clean : clean output & reset" |
16 |
|
|
exit |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
CLEAN=0 |
20 |
|
|
TESTDIRS= |
21 |
|
|
SKIPDIRS= |
22 |
|
|
SCRIPT='tst_2+2' |
23 |
|
|
here=`pwd` |
24 |
|
|
yy= |
25 |
|
|
for xx |
26 |
|
|
do |
27 |
|
|
if test -n "$yy"; then |
28 |
|
|
eval "$yy=\$xx" |
29 |
|
|
yy= |
30 |
|
|
else |
31 |
|
|
case $xx in |
32 |
|
|
-help ) usage ;; |
33 |
|
|
-clean) CLEAN=1 ;; |
34 |
|
|
-t ) yy=TESTDIRS ;; |
35 |
|
|
-skd ) yy=SKIPDIRS ;; |
36 |
|
|
*) echo "Error: unrecognized option: "$xx ; usage ; exit ;; |
37 |
|
|
esac |
38 |
|
|
fi |
39 |
|
|
done |
40 |
|
|
#------------------------ |
41 |
|
|
|
42 |
|
|
if test "x$TESTDIRS" = x |
43 |
|
|
then |
44 |
|
|
TESTDIRS=`ls ` |
45 |
|
|
#TESTDIRS=`ls | grep -v 'fizhi-cs' | grep -v 'tutorial_cfc_offline'` |
46 |
|
|
fi |
47 |
|
|
LIST="" |
48 |
|
|
for xx in $TESTDIRS |
49 |
|
|
do |
50 |
|
|
yy=`echo $SKIPDIRS | grep -c $xx` |
51 |
|
|
if test $yy = 0 ; then |
52 |
|
|
if test -f $xx/results/output.txt |
53 |
|
|
then |
54 |
|
|
LIST=${LIST}" "$xx |
55 |
|
|
# else |
56 |
|
|
# echo ""; echo -n " -- skip \"$xx\" (not a directory !)" |
57 |
|
|
fi |
58 |
|
|
# else |
59 |
|
|
# echo ""; echo -n " -- skip \"$xx\" (excluded)" |
60 |
|
|
fi |
61 |
|
|
done |
62 |
|
|
|
63 |
|
|
if test -x $SCRIPT ; then |
64 |
|
|
echo "run script '$SCRIPT' for experiment in:" |
65 |
|
|
echo " $LIST" |
66 |
|
|
yy=`echo $SCRIPT | grep -c '^\/'` |
67 |
|
|
if test $yy = 0 ; then SCRIPT="../../$SCRIPT" ; fi |
68 |
|
|
else |
69 |
|
|
echo "ERROR: script '$SCRIPT' not found or not executable" |
70 |
|
|
exit |
71 |
|
|
fi |
72 |
|
|
echo "" |
73 |
|
|
#------------------------ |
74 |
|
|
|
75 |
|
|
if test $CLEAN = 1 ; then |
76 |
|
|
for xx in $LIST |
77 |
|
|
do |
78 |
|
|
listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` |
79 |
|
|
for yy in $listD |
80 |
|
|
do |
81 |
|
|
if test -r $xx/$yy/data.tst |
82 |
|
|
then |
83 |
|
|
echo "clean dir:" $xx/$yy |
84 |
|
|
cd $xx/$yy |
85 |
|
|
echo ' ' >> outp.tst_2+2.log |
86 |
|
|
echo $SCRIPT 4 >> outp.tst_2+2.log |
87 |
|
|
$SCRIPT 4 >> outp.tst_2+2.log 2>&1 |
88 |
|
|
cd $here |
89 |
|
|
fi |
90 |
|
|
done |
91 |
|
|
done |
92 |
|
|
exit |
93 |
|
|
fi |
94 |
|
|
#------------------------ |
95 |
|
|
|
96 |
|
|
if test -f tst_2+2_out.txt ; then mv -f tst_2+2_out.txt tst_2+2_out.old ; fi |
97 |
|
|
date > tst_2+2_out.txt |
98 |
|
|
echo 'test 2+2=4 summary :' >> tst_2+2_out.txt |
99 |
|
|
|
100 |
|
|
for xx in $LIST |
101 |
|
|
do |
102 |
|
|
echo ============================================================================== |
103 |
|
|
listD='run '`(cd $xx/results ; ls output.*.txt 2> /dev/null | sed 's/^output\./tr_run./g' | sed 's/\.txt$//g' )` |
104 |
|
|
for yy in $listD |
105 |
|
|
do |
106 |
|
|
if test -f $xx/$yy/output.txt |
107 |
|
|
then |
108 |
|
|
if test $yy = 'run' ; then nam=$xx |
109 |
|
|
else nam=$xx`echo $yy | sed 's/tr_run//'` ; fi |
110 |
|
|
echo -n "Entering $xx/$yy :" |
111 |
|
|
cd $xx/$yy |
112 |
|
|
echo $SCRIPT All > outp.tst_2+2.log ; echo ' ' >> outp.tst_2+2.log |
113 |
|
|
$SCRIPT All >> outp.tst_2+2.log 2>&1 |
114 |
|
|
out=$? |
115 |
|
|
if test $out = '0' |
116 |
|
|
then |
117 |
|
|
echo " pass <- $nam" >> ../../tst_2+2_out.txt |
118 |
|
|
echo ' pass test 2+2=4' |
119 |
|
|
else |
120 |
|
|
echo "FAIL ($out) - $nam" >> ../../tst_2+2_out.txt |
121 |
|
|
echo " test 2+2=4 FAIL (exit $out)" |
122 |
|
|
echo " " |
123 |
|
|
tail -5 outp.tst_2+2.log |
124 |
|
|
echo " " |
125 |
|
|
fi |
126 |
|
|
cd $here |
127 |
|
|
fi |
128 |
|
|
done |
129 |
|
|
done |
130 |
|
|
date >> tst_2+2_out.txt |