1 | #!/bin/ksh |
---|
2 | |
---|
3 | TEST_NAME=$1 |
---|
4 | BASE_DIR=$PWD |
---|
5 | DIFF=${DIFF:-diff} |
---|
6 | |
---|
7 | if [[ ! -f control/$TEST_NAME/.tests.complete ]]; then |
---|
8 | echo "WARNING: Control tests did not complete, skipping comparisons" |
---|
9 | exit |
---|
10 | fi |
---|
11 | |
---|
12 | DIFF_OUTPUT=$BASE_DIR/$TEST_NAME.diff |
---|
13 | |
---|
14 | # Compare directory contents |
---|
15 | for DIR in extract build/etc .fcm-make/cache |
---|
16 | do |
---|
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 |
---|
27 | done |
---|
28 | |
---|
29 | # Compare file listings from directories |
---|
30 | for DIR in build/bin build/o build/include |
---|
31 | do |
---|
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 |
---|
48 | done |
---|
49 | |
---|
50 | # Compare file listings from directories (non-recursive) |
---|
51 | for DIR in . extract build preprocess |
---|
52 | do |
---|
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 |
---|
69 | done |
---|
70 | |
---|
71 | # Compare files in build/include directory (except *.mod) |
---|
72 | if [[ -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 |
---|
85 | fi |
---|
86 | cd $BASE_DIR |
---|
87 | |
---|
88 | # Compare files in preprocess directory (ignoring RUN_DIR in *.c & *.cpp files) |
---|
89 | if [[ -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 |
---|
111 | fi |
---|
112 | |
---|
113 | # Compare build command files |
---|
114 | cd test |
---|
115 | unset TEST_FILES CONTROL_FILES |
---|
116 | if [[ -f $TEST_NAME.build.commands.1 ]]; then |
---|
117 | TEST_FILES=$(ls -1 $TEST_NAME.build.commands.*) |
---|
118 | fi |
---|
119 | cd $BASE_DIR/control |
---|
120 | if [[ -f $TEST_NAME.build.commands.1 ]]; then |
---|
121 | CONTROL_FILES=$(ls -1 $TEST_NAME.build.commands.*) |
---|
122 | fi |
---|
123 | if [[ $TEST_FILES != $CONTROL_FILES ]]; then |
---|
124 | echo "FAILED: $TEST_NAME - number of build command files differs from control" |
---|
125 | exit 1 |
---|
126 | fi |
---|
127 | cd $BASE_DIR |
---|
128 | for FILE in $TEST_FILES |
---|
129 | do |
---|
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 |
---|
145 | done |
---|
146 | |
---|
147 | # Compare run output files |
---|
148 | cd test |
---|
149 | unset TEST_FILES CONTROL_FILES |
---|
150 | if [[ -f $TEST_NAME.exe.stdout.1 ]]; then |
---|
151 | TEST_FILES="$TEST_FILES $(ls -1 $TEST_NAME.exe.stdout.*)" |
---|
152 | fi |
---|
153 | cd $BASE_DIR/control |
---|
154 | if [[ -f $TEST_NAME.exe.stdout.1 ]]; then |
---|
155 | CONTROL_FILES="$CONTROL_FILES $(ls -1 $TEST_NAME.exe.stdout.*)" |
---|
156 | fi |
---|
157 | if [[ $TEST_FILES != $CONTROL_FILES ]]; then |
---|
158 | echo "FAILED: $TEST_NAME - number of run output files differs from control" |
---|
159 | exit 1 |
---|
160 | fi |
---|
161 | cd $BASE_DIR |
---|
162 | for FILE in $TEST_FILES |
---|
163 | do |
---|
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 |
---|
172 | done |
---|
173 | |
---|
174 | # Compare file contents ignoring RUN_DIR |
---|
175 | for FILE in .fcm-make/config-as-parsed.cfg .fcm-make/config-on-success.cfg |
---|
176 | do |
---|
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 |
---|
190 | done |
---|
191 | |
---|
192 | if [[ $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 |
---|
202 | fi |
---|
203 | |
---|
204 | rm -f $DIFF_OUTPUT |
---|
205 | exit 0 |
---|