[1980] | 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 done .cache/.bld etc flags src |
---|
| 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 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 .cache/.ext bin obj lib inc ppsrc |
---|
| 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 . |
---|
| 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 inc directory (except *.mod) |
---|
| 72 | if [[ -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 |
---|
| 85 | fi |
---|
| 86 | cd $BASE_DIR |
---|
| 87 | |
---|
| 88 | # Compare files in ppsrc directory (ignoring RUN_DIR in *.c files) |
---|
| 89 | if [[ -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 |
---|
| 111 | fi |
---|
| 112 | |
---|
| 113 | # Compare build command and run output 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 | if [[ -f $TEST_NAME.exe.stdout.1 ]]; then |
---|
| 120 | TEST_FILES="$TEST_FILES $(ls -1 $TEST_NAME.exe.stdout.*)" |
---|
| 121 | fi |
---|
| 122 | cd $BASE_DIR/control |
---|
| 123 | if [[ -f $TEST_NAME.build.commands.1 ]]; then |
---|
| 124 | CONTROL_FILES=$(ls -1 $TEST_NAME.build.commands.*) |
---|
| 125 | fi |
---|
| 126 | if [[ -f $TEST_NAME.exe.stdout.1 ]]; then |
---|
| 127 | CONTROL_FILES="$CONTROL_FILES $(ls -1 $TEST_NAME.exe.stdout.*)" |
---|
| 128 | fi |
---|
| 129 | if [[ $TEST_FILES != $CONTROL_FILES ]]; then |
---|
| 130 | echo "FAILED: $TEST_NAME - number of build command or run output files differ from control" |
---|
| 131 | exit 1 |
---|
| 132 | fi |
---|
| 133 | cd $BASE_DIR |
---|
| 134 | for FILE in $TEST_FILES |
---|
| 135 | do |
---|
| 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 |
---|
| 144 | done |
---|
| 145 | |
---|
| 146 | # Compare file contents ignoring RUN_DIR |
---|
| 147 | for FILE in Makefile fcm_env.sh cfg/bld.cfg cfg/parsed_bld.cfg cfg/ext.cfg cfg/parsed_ext.cfg |
---|
| 148 | do |
---|
| 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 |
---|
| 162 | done |
---|
| 163 | |
---|
| 164 | if [[ $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 |
---|
| 179 | fi |
---|
| 180 | |
---|
| 181 | rm -f $DIFF_OUTPUT |
---|
| 182 | exit 0 |
---|