Commit | Line | Data |
---|---|---|
62402cb1 MP |
1 | #!/bin/sh |
2 | ||
3 | run() { | |
4 | prog=$1; shift | |
5 | name=$1; shift | |
6 | answer=$1; shift | |
7 | ||
8 | echo Running test $name. | |
9 | ||
10 | result=`./$prog $*` | |
11 | if [ "$answer" != "$result" ]; then | |
12 | echo "Test \"$*\" failed with: $result" | |
13 | exit 2 | |
14 | fi | |
15 | } | |
16 | ||
17 | make -q testcases | |
18 | ||
19 | run test1 "test1 - 1" "arg1: 1 arg2: (none)" --arg1 | |
20 | run test1 "test1 - 2" "arg1: 0 arg2: foo" --arg2 foo | |
21 | run test1 "test1 - 3" "arg1: 1 arg2: something" --arg1 --arg2 something | |
22 | run test1 "test1 - 4" "arg1: 0 arg2: another" --simple another | |
23 | run test1 "test1 - 5" "arg1: 1 arg2: alias" --two | |
24 | run test1 "test1 - 6" "arg1: 1 arg2: (none) rest: --arg2" --arg1 -- --arg2 | |
25 | run test1 "test1 - 7" "arg1: 0 arg2: abcd rest: --arg1" --simple abcd -- --arg1 | |
26 | run test1 "test1 - 8" "arg1: 1 arg2: (none) rest: --arg2" --arg1 --takerest --arg2 | |
27 | run test1 "test1 - 9" "arg1: 0 arg2: foo" -2 foo | |
28 | run test1 "test1 - 10" "arg1: 0 arg2: (none) arg3: 50" -3 50 | |
29 | run test1 "test1 - 11" "arg1: 0 arg2: bar" -T bar | |
30 | run test1 "test1 - 12" "arg1: 1 arg2: (none)" -O | |
31 | run test1 "test1 - 13" "arg1: 1 arg2: foo" -OT foo | |
32 | run test1 "test1 - 14" "arg1: 0 arg2: (none) inc: 1" --inc | |
33 | run test1 "test1 - 15" "arg1: 0 arg2: foo inc: 1" -i --arg2 foo | |
34 | POSIX_ME_HARDER=1 run test1 "test1 - 16" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something | |
35 | POSIXLY_CORRECT=1 run test1 "test1 - 17" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something | |
36 | run test1 "test1 - 18" "callback: c sampledata bar arg1: 1 arg2: (none)" --arg1 --cb bar | |
37 | run test1 "test1 - 19" "./test1 ;" --echo-args | |
38 | run test1 "test1 - 20" "./test1 ; --arg1" --echo-args --arg1 | |
39 | run test1 "test1 - 21" "./test1 ; --arg2 something" -T something -e | |
40 | run test1 "test1 - 22" "./test1 ; --arg2 something -- more args" -T something -a more args | |
41 | run test1 "test1 - 23" "./test1 ; --echo-args -a" --echo-args -e -a | |
42 | run test1 "test1 - 24" "arg1: 0 arg2: (none) short: 1" -shortoption | |
43 | run test1 "test1 - 25" "arg1: 0 arg2: (none) short: 1" --shortoption | |
44 | run test1 "test1 - 26" "callback: c arg for cb2 foo arg1: 0 arg2: (none)" --cb2 foo | |
45 | ||
46 | echo "" | |
47 | echo "Passed." |