| [0f4ac10] | 1 | # A test.py run (including what happens in the nightly build) runs the dimexpr-match test in a coarse, quick-check, fashion.
 | 
|---|
 | 2 | # This script helps you run the dimexpr-match test manually, in a more thorough fashion.
 | 
|---|
 | 3 | # test.py runs do not use this script.
 | 
|---|
 | 4 | 
 | 
|---|
| [090b076] | 5 | # When a test.py run shows that an output has changed, use this script for verification, before running --regenerate-expected.
 | 
|---|
 | 6 | # Particularly with -ERRS, we don't actually care what the error message is (likely source of noise requiring --regenerate-expected), just that all the should-reject cases are rejected (which this script shows).
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | # Success means the script does not print "TEST FAILURE."
 | 
|---|
 | 9 | # Expect one large output with a mix of "done" and "skip" messages.  That is the acceptance cases.
 | 
|---|
 | 10 | # Then expect many small outputs all showing rc=1.  These are the rejection cases.
 | 
|---|
 | 11 | 
 | 
|---|
| [0f4ac10] | 12 | # The thoroughness that this script affords is
 | 
|---|
 | 13 | #   - verifying that _each_ rejection case is rejected, among a huge number of rejection cases
 | 
|---|
 | 14 | #     - particularly, counting those that reject by way of CFACC calling GCC, which issues a warning; these rejections are not reached by getting CFACC to report all errors at once
 | 
|---|
 | 15 | #   - observing the behaviour of a compiler other than the CFACC version in whose folder the test occurs; for example, GCC
 | 
|---|
 | 16 | 
 | 
|---|
| [090b076] | 17 | # usage examples
 | 
|---|
 | 18 | #   ./dimexpr-match-detail.sh cfa
 | 
|---|
 | 19 | #   ./dimexpr-match-detail.sh      # same as above
 | 
|---|
| [0f4ac10] | 20 | #   ./dimexpr-match-detail.sh ~/cfa6/build/driver/cfa
 | 
|---|
| [090b076] | 21 | #   ./dimexpr-match-detail.sh "$cfa -m32 -nodebug"
 | 
|---|
| [0f4ac10] | 22 | #   ./dimexpr-match-detail.sh 'gcc -x c'
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | compiler=${1:-cfa}
 | 
|---|
 | 26 | test=${2:-dimexpr-match-c.cfa}
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | # Same as first half of the auto-test: check that all the cases that should be accepted are accepted
 | 
|---|
 | 29 | set -x
 | 
|---|
 | 30 | $compiler $test
 | 
|---|
 | 31 | rc=$?
 | 
|---|
 | 32 | { set +x; } 2> /dev/null
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | if [ $rc -gt 0 ]; then
 | 
|---|
 | 35 |     echo
 | 
|---|
 | 36 |     echo
 | 
|---|
 | 37 |     echo "TEST FAILURE: compiler rejected a case that should be accepted"
 | 
|---|
 | 38 |     echo
 | 
|---|
 | 39 |     echo
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 |     exit 1
 | 
|---|
 | 42 | fi
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | set -x
 | 
|---|
 | 45 | ./a.out
 | 
|---|
 | 46 | rc=$?
 | 
|---|
 | 47 | { set +x; } 2> /dev/null
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | if [ $rc -gt 0 ]; then
 | 
|---|
 | 50 |     echo
 | 
|---|
 | 51 |     echo
 | 
|---|
 | 52 |     echo "TEST FAILURE: runtime crash on a case that should be accepted"
 | 
|---|
 | 53 |     echo
 | 
|---|
 | 54 |     echo
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 |     exit 1
 | 
|---|
 | 57 | fi
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | # More detailed alternative to the second half of the auto-test: check that each case that the first half skipped is rejected, when run all by itself
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | function verifyCompilationRejection() {
 | 
|---|
 | 62 |     set -x
 | 
|---|
 | 63 |     $compiler $1 &> /dev/null
 | 
|---|
 | 64 |     rc=$?
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 |     { set +x; } 2> /dev/null
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 |     if [ $rc -eq 0 ]; then
 | 
|---|
 | 69 |         echo
 | 
|---|
 | 70 |         echo
 | 
|---|
 | 71 |         echo "TEST FAILURE: compiler accepted case that should be rejected:"
 | 
|---|
 | 72 |         echo $1
 | 
|---|
 | 73 |         echo
 | 
|---|
 | 74 |         echo
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 |         # keep checking other cases
 | 
|---|
 | 77 |     fi
 | 
|---|
 | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | export -f verifyCompilationRejection
 | 
|---|
 | 81 | export compiler
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 | ./a.out -cmd4skip | sed -E -n 's/skip.*\| *//p' | xargs -n 1 -I {} bash -c 'verifyCompilationRejection "$@"' _ {}
 | 
|---|