blob: 8487a8e7e458407dfd403f131f1c33aab50b6975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/sh
runtest (){
printf '=================================================================\n'
printf '======= args: %s\n' "$*"
"$@" 2>&1 | awk '/stack traceback:/, /\[C\]: [?]/ {next} {print}'
}
do_test_getopt (){
runtest ../alt_getopt -h -
runtest ../alt_getopt --help
runtest ../alt_getopt -h --help -v --verbose -V -o 123 -o234
runtest ../alt_getopt --output 123 --output 234 -n 999 -n9999 --len 5 --fake /dev/null
runtest ../alt_getopt -hVv -- -1 -2 -3
runtest ../alt_getopt --fake -v -- -1 -2 -3
runtest ../alt_getopt - -1 -2 -3
runtest ../alt_getopt --fake -v - -1 -2 -3
runtest ../alt_getopt -1 -2 -3
runtest ../alt_getopt -hvV
runtest ../alt_getopt -ho 123
runtest ../alt_getopt -hoV 123
runtest ../alt_getopt --unknown
runtest ../alt_getopt --output='file.out' -nNNN --len=LENGTH
runtest ../alt_getopt --output --file--
runtest ../alt_getopt --output
runtest ../alt_getopt -ho
runtest ../alt_getopt --help -o
runtest ../alt_getopt --help=value
runtest ../alt_getopt -ofile1 --set_value 111 --output file2 \
--set-output=file3
true
}
do_test (){
do_test_getopt
}
OBJDIR=${OBJDIR:=.}
do_test > $OBJDIR/_test.res 2>&1
if ! diff -u test.out $OBJDIR/_test.res; then
echo "rewrite fails" 1>&2
exit 1
fi
|