source: LMDZ6/branches/Amaury_dev/tools/fcm/test/compare_results_fcm2 @ 5095

Last change on this file since 5095 was 5095, checked in by abarral, 5 months ago

Revert cosp*/ from the trunk, as it's external code
Add missing bits from FCM2 source

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1#!/bin/ksh
2
3TEST_NAME=$1
4BASE_DIR=$PWD
5DIFF=${DIFF:-diff}
6
7if [[ ! -f control/$TEST_NAME/.tests.complete ]]; then
8  echo "WARNING: Control tests did not complete, skipping comparisons"
9  exit
10fi
11
12DIFF_OUTPUT=$BASE_DIR/$TEST_NAME.diff
13
14# Compare directory contents
15for DIR in extract build/etc .fcm-make/cache
16do
17  if [[ -d test/$TEST_NAME/$DIR ]]; then
18    if [[ $DEBUG == true ]]; then
19      echo "Comparing $DIR directory contents ..."
20    fi
21    $DIFF -r --exclude=hello_sub2.F90 control/$TEST_NAME/$DIR test/$TEST_NAME/$DIR >$DIFF_OUTPUT
22    if [[ $? != 0 ]]; then
23      echo "FAILED: $TEST_NAME - $DIR directory contents differ from control"
24      exit 1
25    fi
26  fi
27done
28
29# Compare file listings from directories
30for DIR in build/bin build/o build/include
31do
32  if [[ -d test/$TEST_NAME/$DIR ]]; then
33    if [[ $DEBUG == true ]]; then
34      echo "Comparing $DIR directory listings ..."
35    fi
36    cd $BASE_DIR/control/$TEST_NAME
37    ls -R -1 $DIR >$BASE_DIR/$TEST_NAME.control_files
38    cd $BASE_DIR/test/$TEST_NAME
39    ls -R -1 $DIR >$BASE_DIR/$TEST_NAME.test_files
40    cd $BASE_DIR
41    $DIFF $TEST_NAME.control_files $TEST_NAME.test_files >$DIFF_OUTPUT
42    if [[ $? != 0 ]]; then
43      echo "FAILED: $TEST_NAME - $DIR file listing differs from control"
44      exit 1
45    fi
46    rm $TEST_NAME.control_files $TEST_NAME.test_files
47  fi
48done
49
50# Compare file listings from directories (non-recursive)
51for DIR in . extract build preprocess
52do
53  if [[ -d test/$TEST_NAME/$DIR ]]; then
54    if [[ $DEBUG == true ]]; then
55      echo "Comparing $DIR directory listings ..."
56    fi
57    cd $BASE_DIR/control/$TEST_NAME
58    ls -1 $DIR >$BASE_DIR/$TEST_NAME.control_files
59    cd $BASE_DIR/test/$TEST_NAME
60    ls -1 $DIR >$BASE_DIR/$TEST_NAME.test_files
61    cd $BASE_DIR/
62    $DIFF $TEST_NAME.control_files $TEST_NAME.test_files >$DIFF_OUTPUT
63    if [[ $? != 0 ]]; then
64      echo "FAILED: $TEST_NAME - $DIR file listing differs from control"
65      exit 1
66    fi
67    rm $TEST_NAME.control_files $TEST_NAME.test_files
68  fi
69done
70
71# Compare files in build/include directory (except *.mod)
72if [[ -d test/$TEST_NAME/build/include ]]; then
73  if [[ $DEBUG == true ]]; then
74    echo "Comparing build/include directory contents ..."
75  fi
76  cd test/$TEST_NAME/build/include
77  for FILE in $(ls -1 | grep -v "\.mod$")
78  do
79    $DIFF $BASE_DIR/control/$TEST_NAME/build/include/$FILE $FILE >$DIFF_OUTPUT
80    if [[ $? != 0 ]]; then
81      echo "FAILED: $TEST_NAME - $FILE contents differ from control"
82      exit 1
83    fi
84  done
85fi
86cd $BASE_DIR
87
88# Compare files in preprocess directory (ignoring RUN_DIR in *.c & *.cpp files)
89if [[ -d test/$TEST_NAME/preprocess ]]; then
90  if [[ $DEBUG == true ]]; then
91    echo "Comparing preprocess directory contents ..."
92  fi
93  cd test/$TEST_NAME
94  FILES=$(find preprocess -type f)
95  cd $BASE_DIR
96  for FILE in $FILES
97  do
98    if [[ $FILE == ${FILE%.c} && $FILE == ${FILE%.cpp} ]]; then
99      $DIFF control/$TEST_NAME/$FILE test/$TEST_NAME/$FILE >$DIFF_OUTPUT
100    else
101      sed "s#/.*/fcm_test_suite/control/##g" control/$TEST_NAME/$FILE >$TEST_NAME.control_file
102      sed "s#/.*/fcm_test_suite/test/##g" test/$TEST_NAME/$FILE >$TEST_NAME.test_file
103      $DIFF $TEST_NAME.control_file $TEST_NAME.test_file >$DIFF_OUTPUT
104    fi
105    if [[ $? != 0 ]]; then
106      echo "FAILED: $TEST_NAME - $FILE contents differ from control"
107      exit 1
108    fi
109    rm -f $TEST_NAME.control_file $TEST_NAME.test_file
110  done
111fi
112
113# Compare build command files
114cd test
115unset TEST_FILES CONTROL_FILES
116if [[ -f $TEST_NAME.build.commands.1 ]]; then
117  TEST_FILES=$(ls -1 $TEST_NAME.build.commands.*)
118fi
119cd $BASE_DIR/control
120if [[ -f $TEST_NAME.build.commands.1 ]]; then
121  CONTROL_FILES=$(ls -1 $TEST_NAME.build.commands.*)
122fi
123if [[ $TEST_FILES != $CONTROL_FILES ]]; then
124  echo "FAILED: $TEST_NAME - number of build command files differs from control"
125  exit 1
126fi
127cd $BASE_DIR
128for FILE in $TEST_FILES
129do
130  if [[ $DEBUG == true ]]; then
131    echo "Comparing $FILE contents ..."
132  fi
133  if [[ $NPROC = 1 ]]; then
134    $DIFF control/$FILE test/$FILE >$DIFF_OUTPUT
135  else
136    sort control/$FILE >$TEST_NAME.control_file
137    sort test/$FILE >$TEST_NAME.test_file
138    $DIFF $TEST_NAME.control_file $TEST_NAME.test_file >$DIFF_OUTPUT
139  fi
140  if [[ $? != 0 ]]; then
141    echo "FAILED: $TEST_NAME - $FILE contents differ from control"
142    exit 1
143  fi
144  rm -f $TEST_NAME.control_file $TEST_NAME.test_file
145done
146
147# Compare run output files
148cd test
149unset TEST_FILES CONTROL_FILES
150if [[ -f $TEST_NAME.exe.stdout.1 ]]; then
151  TEST_FILES="$TEST_FILES $(ls -1 $TEST_NAME.exe.stdout.*)"
152fi
153cd $BASE_DIR/control
154if [[ -f $TEST_NAME.exe.stdout.1 ]]; then
155  CONTROL_FILES="$CONTROL_FILES $(ls -1 $TEST_NAME.exe.stdout.*)"
156fi
157if [[ $TEST_FILES != $CONTROL_FILES ]]; then
158  echo "FAILED: $TEST_NAME - number of run output files differs from control"
159  exit 1
160fi
161cd $BASE_DIR
162for FILE in $TEST_FILES
163do
164  if [[ $DEBUG == true ]]; then
165    echo "Comparing $FILE contents ..."
166  fi
167  $DIFF control/$FILE test/$FILE >$DIFF_OUTPUT
168  if [[ $? != 0 ]]; then
169    echo "FAILED: $TEST_NAME - $FILE contents differ from control"
170    exit 1
171  fi
172done
173
174# Compare file contents ignoring RUN_DIR
175for FILE in .fcm-make/config-as-parsed.cfg .fcm-make/config-on-success.cfg
176do
177  if [[ -f test/$TEST_NAME/$FILE ]]; then
178    if [[ $DEBUG == true ]]; then
179      echo "Comparing $FILE contents ..."
180    fi
181    cat control/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/control/##g" >$TEST_NAME.control_file
182    cat test/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/test/##g" >$TEST_NAME.test_file
183    $DIFF $TEST_NAME.control_file $TEST_NAME.test_file >$DIFF_OUTPUT
184    if [[ $? != 0 ]]; then
185      echo "FAILED: $TEST_NAME - $FILE file contents differ from control"
186      exit 1
187    fi
188    rm $TEST_NAME.control_file $TEST_NAME.test_file
189  fi
190done
191
192if [[ $COMPARE_TIMES == true ]]; then
193  cd control
194  for FILE in $(ls -1 $TEST_NAME.make.stdout.*)
195  do
196    echo "Make times:"
197    grep -e '\[done\]' -e '\[FAIL\]' $FILE >$TEST_NAME.control_make_times
198    grep -e '\[done\]' -e '\[FAIL\]' $BASE_DIR/test/$FILE >$TEST_NAME.test_make_times
199    $DIFF --side-by-side $TEST_NAME.control_make_times $TEST_NAME.test_make_times
200    rm $TEST_NAME.control_make_times $TEST_NAME.test_make_times
201  done
202fi
203
204rm -f $DIFF_OUTPUT
205exit 0
Note: See TracBrowser for help on using the repository browser.