1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7# timeout's exit value is complicated!
8testcmd "times out" '.1 sleep 100 ; echo $?'  '124\n' '' ''
9testcmd "failure" '-s MONKEY .1 sleep 100 2>/dev/null ; echo $?' '125\n' '' ''
10testcmd "early failure" '2>/dev/null ; echo $?' '125\n' '' ''
11testcmd "can't execute" '.1 / 2>/dev/null ; echo $?' '126\n' '' ''
12testcmd "can't find" '.1 /does/not/exist 2>/dev/null ; echo $?' '127\n' '' ''
13testcmd "custom signal" '-s 3 .1 sleep 100; echo $?' '124\n' '' ''
14testcmd "killed" '-s 9 .1 sleep 100; echo $?' '137\n' '' ''
15testcmd "TERM" '-s TERM .1 sleep 100; echo $?' '124\n' '' ''
16testcmd "exit 0" '.1 true ; echo $?' '0\n' '' ''
17testcmd "exit 1" '.1 false ; echo $?' '1\n' '' ''
18
19testcmd "--preserve-status" '--preserve-status .1 sleep 100 ; echo $?' '143\n' '' ''
20testcmd "--preserve-status killed" '--preserve-status -s 9 .1 sleep 100 ; echo $?' '137\n' '' ''
21