|
@@ -1,4 +1,5 @@
|
1
|
1
|
#!/bin/bash
|
|
2
|
+#shellcheck disable=SC1090
|
2
|
3
|
|
3
|
4
|
. "$TF_DIR/include/common.sh"
|
4
|
5
|
|
|
@@ -10,10 +11,10 @@ tf_testflt() {
|
10
|
11
|
# Run a simple test for a unix filter
|
11
|
12
|
#
|
12
|
13
|
# tf_testflt -n foo [-i foo.stdin] \
|
13
|
|
- # [-O foo.stdout] [-E foo.stderr] [-S 3] \
|
|
14
|
+ # [-O foo.out] [-E foo.err] [-S 3] \
|
14
|
15
|
# cmd arg...
|
15
|
16
|
#
|
16
|
|
- # Will drop *result/NAME.stdout* and *result/NAME.stderr* (intentionally
|
|
17
|
+ # Will drop *result/NAME.out* and *result/NAME.err* (intentionally
|
17
|
18
|
# not cleaning up).
|
18
|
19
|
#
|
19
|
20
|
|
|
@@ -44,10 +45,10 @@ tf_testflt() {
|
44
|
45
|
-S) o_es="$2"; shift 2 || { arg_err=true; break; } ;;
|
45
|
46
|
--) shift; break ;;
|
46
|
47
|
"") break ;;
|
47
|
|
- -*) tf_warn "wrong testcli arg: $1"; return $TF_ES_BAILOUT ;;
|
|
48
|
+ -*) tf_warn "wrong testcli arg: $1"; return "$TF_ES_BAILOUT" ;;
|
48
|
49
|
*) break ;;
|
49
|
50
|
esac done
|
50
|
|
- $arg_err && { tf_warn "error parsing arguments: $orig_args"; return $TF_ES_BAILOUT; }
|
|
51
|
+ $arg_err && { tf_warn "error parsing arguments: $orig_args"; return "$TF_ES_BAILOUT"; }
|
51
|
52
|
tf_debug "t_in='$t_in'"
|
52
|
53
|
tf_debug "t_name='$t_name'"
|
53
|
54
|
tf_debug "o_out='$o_out'"
|
|
@@ -55,22 +56,22 @@ tf_testflt() {
|
55
|
56
|
tf_debug "o_es='$o_es'"
|
56
|
57
|
tf_debug "test command: $*"
|
57
|
58
|
test "$t_in" = "-" && t_in=/dev/stdin # works better for check below
|
58
|
|
- test -z "$t_name" && { tf_warn "missing test name" ; return $TF_ES_BAILOUT; }
|
59
|
|
- test -z "$1" && { tf_warn "missing test command" ; return $TF_ES_BAILOUT; }
|
60
|
|
- test -r "$t_in" || { tf_warn "missing input file: $t_in" ; return $TF_ES_BAILOUT; }
|
61
|
|
- test -e "$o_out" || { tf_warn "missing oracle stdout: $o_out" ; return $TF_ES_BAILOUT; }
|
62
|
|
- test -e "$o_err" || { tf_warn "missing oracle stderr: $o_err" ; return $TF_ES_BAILOUT; }
|
63
|
|
- test "$o_es" -ge 0 || { tf_warn "invalid oracle status: $o_es" ; return $TF_ES_BAILOUT; }
|
|
59
|
+ test -z "$t_name" && { tf_warn "missing test name" ; return "$TF_ES_BAILOUT"; }
|
|
60
|
+ test -z "$1" && { tf_warn "missing test command" ; return "$TF_ES_BAILOUT"; }
|
|
61
|
+ test -r "$t_in" || { tf_warn "missing input file: $t_in" ; return "$TF_ES_BAILOUT"; }
|
|
62
|
+ test -e "$o_out" || { tf_warn "missing oracle stdout: $o_out" ; return "$TF_ES_BAILOUT"; }
|
|
63
|
+ test -e "$o_err" || { tf_warn "missing oracle stderr: $o_err" ; return "$TF_ES_BAILOUT"; }
|
|
64
|
+ test "$o_es" -ge 0 || { tf_warn "invalid oracle status: $o_es" ; return "$TF_ES_BAILOUT"; }
|
64
|
65
|
|
65
|
66
|
# prepare
|
66
|
67
|
#
|
67
|
68
|
mkdir -p result
|
68
|
|
- r_out="result/$t_name.stdout"
|
69
|
|
- r_err="result/$t_name.stderr"
|
|
69
|
+ r_out="result/$t_name.out"
|
|
70
|
+ r_err="result/$t_name.err"
|
70
|
71
|
tf_debug "r_out='$r_out'"
|
71
|
72
|
tf_debug "r_err='$r_err'"
|
72
|
|
- touch "$r_out" || { tf_warn "cannot create tmp file: $r_out" ; return $TF_ES_BAILOUT; }
|
73
|
|
- touch "$r_err" || { tf_warn "cannot create tmp file: $r_err" ; return $TF_ES_PANIC; }
|
|
73
|
+ touch "$r_out" || { tf_warn "cannot create tmp file: $r_out" ; return "$TF_ES_BAILOUT"; }
|
|
74
|
+ touch "$r_err" || { tf_warn "cannot create tmp file: $r_err" ; return "$TF_ES_PANIC"; }
|
74
|
75
|
|
75
|
76
|
# run
|
76
|
77
|
#
|
|
@@ -79,8 +80,8 @@ tf_testflt() {
|
79
|
80
|
|
80
|
81
|
# eval/report/exit
|
81
|
82
|
#
|
82
|
|
- test $r_es = $o_es || { tf_warn "bad exit status: $r_es (need $o_es)" ; t_es=$TF_ES_FAIL; }
|
|
83
|
+ test "$r_es" = "$o_es" || { tf_warn "bad exit status: $r_es (need $o_es)" ; t_es=$TF_ES_FAIL; }
|
83
|
84
|
$diff -u "$o_err" "$r_err" || t_es=$TF_ES_FAIL
|
84
|
85
|
$diff -u "$o_out" "$r_out" || t_es=$TF_ES_FAIL
|
85
|
|
- return $t_es
|
|
86
|
+ return "$t_es"
|
86
|
87
|
}
|