Debian Codegraph @

tests/wrapper-utils.sh

raw symbols SCIP
1 #!/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_pass()
12 {
13 echo -n "UNEXPECTED "
14 }
15
16 function expected_fail()
17 {
18 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_rc()
27 {
28 EXP_RC=$1
29 ACT_RC=$2
30
31 if [ $ACT_RC -eq $RC_PASS -a $EXP_RC -ne $RC_PASS ]; then
32 unexpected_pass
33 return $RC_XPASS
34 elif [ $EXP_RC -ne $RC_PASS -a $EXP_RC -eq $ACT_RC ]; then
35 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_check()
46 {
47 EXP_RC=$1
48 shift
49
50 OUTPUT=`$@`
51 check_rc $EXP_RC $?
52 RC=$?
53 echo $OUTPUT
54
55 exit $RC
56 }