| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Standard return codes |
| 4 | RC_PASS=0 |
| 5 | RC_CONFIG=1 |
| 6 | RC_FAIL=2 |
| 7 | RC_XFAIL=3 |
| 8 | RC_XPASS=4 |
| 9 | RC_BUG=99 |
| 10 | |
| 11 | function unexpected_passscip-shell shell shell-project 0.0.0 unexpected_pass().() |
| 12 | { |
| 13 | echoscip-shell system . . echo. -n "UNEXPECTED " |
| 14 | } |
| 15 | |
| 16 | function expected_failscip-shell shell shell-project 0.0.0 expected_fail().() |
| 17 | { |
| 18 | echoscip-shell system . . echo. -n "EXPECTED " |
| 19 | } |
| 20 | |
| 21 | # check_rc (<expected return code>, <actual return code>) |
| 22 | # Returns: Adjusted return code |
| 23 | # |
| 24 | # Check the actual and expected return codes to identify |
| 25 | # expected failures and unexpected passes. |
| 26 | function check_rcscip-shell shell shell-project 0.0.0 check_rc().() |
| 27 | { |
| 28 | EXP_RC=$1 |
| 29 | ACT_RC=$2 |
| 30 | |
| 31 | if [scip-shell system . . `[`. $ACT_RC -eq $RC_PASS -a $EXP_RC -ne $RC_PASS ]; then |
| 32 | unexpected_passscip-shell shell shell-project 0.0.0 unexpected_pass(). |
| 33 | return $RC_XPASS |
| 34 | elif [scip-shell system . . `[`. $EXP_RC -ne $RC_PASS -a $EXP_RC -eq $ACT_RC ]; then |
| 35 | expected_failscip-shell shell shell-project 0.0.0 expected_fail(). |
| 36 | return $RC_XFAIL |
| 37 | else |
| 38 | return $ACT_RC |
| 39 | fi |
| 40 | } |
| 41 | |
| 42 | # exec_and_check (<expected return code>, <command-line ...>) |
| 43 | # Does not return |
| 44 | # Execute a test command and check for expected failures and unexpected passes. |
| 45 | function exec_and_checkscip-shell shell shell-project 0.0.0 exec_and_check().() |
| 46 | { |
| 47 | EXP_RC=$1 |
| 48 | shift |
| 49 | |
| 50 | OUTPUT=`$@` |
| 51 | check_rcscip-shell shell shell-project 0.0.0 check_rc(). $EXP_RC $? |
| 52 | RC=$? |
| 53 | echoscip-shell system . . echo. $OUTPUT |
| 54 | |
| 55 | exit $RC |
| 56 | } |