New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
compare_results in vendors/fcm/current/test – NEMO

source: vendors/fcm/current/test/compare_results @ 1977

Last change on this file since 1977 was 1977, checked in by flavoni, 14 years ago

importing fcm vendor

File size: 5.7 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 done .cache/.bld etc flags src
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 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 .cache/.ext bin obj lib inc ppsrc
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 .
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 inc directory (except *.mod)
72if [[ -d test/$TEST_NAME/inc ]]; then
73  if [[ $DEBUG == true ]]; then
74    echo "Comparing inc directory contents ..."
75  fi
76  cd test/$TEST_NAME/inc
77  for FILE in $(ls -1 | grep -v "\.mod$")
78  do
79    $DIFF $BASE_DIR/control/$TEST_NAME/inc/$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 ppsrc directory (ignoring RUN_DIR in *.c files)
89if [[ -d test/$TEST_NAME/ppsrc ]]; then
90  if [[ $DEBUG == true ]]; then
91    echo "Comparing ppsrc directory contents ..."
92  fi
93  cd test/$TEST_NAME
94  FILES=$(find ppsrc -type f)
95  cd $BASE_DIR
96  for FILE in $FILES
97  do
98    if [[ $FILE == ${FILE%.c} ]]; then
99      $DIFF control/$TEST_NAME/$FILE test/$TEST_NAME/$FILE >$DIFF_OUTPUT
100    else
101      cat control/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/control/##g" >$TEST_NAME.control_file
102      cat test/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/test/##g" >$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 and run output 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
119if [[ -f $TEST_NAME.exe.stdout.1 ]]; then
120  TEST_FILES="$TEST_FILES $(ls -1 $TEST_NAME.exe.stdout.*)"
121fi
122cd $BASE_DIR/control
123if [[ -f $TEST_NAME.build.commands.1 ]]; then
124  CONTROL_FILES=$(ls -1 $TEST_NAME.build.commands.*)
125fi
126if [[ -f $TEST_NAME.exe.stdout.1 ]]; then
127  CONTROL_FILES="$CONTROL_FILES $(ls -1 $TEST_NAME.exe.stdout.*)"
128fi
129if [[ $TEST_FILES != $CONTROL_FILES ]]; then
130  echo "FAILED: $TEST_NAME - number of build command or run output files differ from control"
131  exit 1
132fi
133cd $BASE_DIR
134for FILE in $TEST_FILES
135do
136  if [[ $DEBUG == true ]]; then
137    echo "Comparing $FILE contents ..."
138  fi
139  $DIFF control/$FILE test/$FILE >$DIFF_OUTPUT
140  if [[ $? != 0 ]]; then
141    echo "FAILED: $TEST_NAME - $FILE contents differ from control"
142    exit 1
143  fi
144done
145
146# Compare file contents ignoring RUN_DIR
147for FILE in Makefile fcm_env.sh cfg/bld.cfg cfg/parsed_bld.cfg cfg/ext.cfg cfg/parsed_ext.cfg
148do
149  if [[ -f test/$TEST_NAME/$FILE ]]; then
150    if [[ $DEBUG == true ]]; then
151      echo "Comparing $FILE contents ..."
152    fi
153    cat control/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/control/##g" >$TEST_NAME.control_file
154    cat test/$TEST_NAME/$FILE | sed "s#/.*/fcm_test_suite/test/##g" >$TEST_NAME.test_file
155    $DIFF $TEST_NAME.control_file $TEST_NAME.test_file >$DIFF_OUTPUT
156    if [[ $? != 0 ]]; then
157      echo "FAILED: $TEST_NAME - $FILE file contents differ from control"
158      exit 1
159    fi
160    rm $TEST_NAME.control_file $TEST_NAME.test_file
161  fi
162done
163
164if [[ $COMPARE_TIMES == true ]]; then
165  if [[ -f control/$TEST_NAME.extract.stdout.1 ]]; then
166    echo "Extract times:"
167    cat control/$TEST_NAME.extract.stdout.1 | grep "\->.*second" > $TEST_NAME.control_extract_times
168    cat test/$TEST_NAME.extract.stdout.1 | grep "\->.*second" > $TEST_NAME.test_extract_times
169    $DIFF --side-by-side $TEST_NAME.control_extract_times $TEST_NAME.test_extract_times
170    rm $TEST_NAME.control_extract_times $TEST_NAME.test_extract_times
171  fi
172  if [[ -f control/$TEST_NAME.build.stdout.1 ]]; then
173    echo "Build times:"
174    cat control/$TEST_NAME.build.stdout.1 | grep "\->.*second" > $TEST_NAME.control_build_times
175    cat test/$TEST_NAME.build.stdout.1 | grep "\->.*second" > $TEST_NAME.test_build_times
176    $DIFF --side-by-side $TEST_NAME.control_build_times $TEST_NAME.test_build_times
177    rm $TEST_NAME.control_build_times $TEST_NAME.test_build_times
178  fi
179fi
180
181rm -f $DIFF_OUTPUT
182exit 0
Note: See TracBrowser for help on using the repository browser.