Просмотр исходного кода

Update to new tfkit (gdca322f)

Alois Mahdal 9 лет назад
Родитель
Сommit
8c7acc7c52

+ 2
- 2
utils/tfkit/doc/templates/grep_engine/TF_RUN Просмотреть файл

@@ -1,7 +1,7 @@
1 1
 #!/bin/bash
2 2
 
3
-. $TF_DIR/include/subtest.sh
4
-. $TF_DIR/include/tools.sh
3
+. "$TF_DIR/include/subtest.sh"
4
+. "$TF_DIR/include/tools.sh"
5 5
 
6 6
 tf_enum_subtests() {
7 7
     echo fixed

+ 3
- 3
utils/tfkit/include/common.sh Просмотреть файл

@@ -102,7 +102,7 @@ tf_debug() {
102 102
     for msg in "$@";
103 103
     do
104 104
         $TF_COLOR && echo -ne "$TF_COLOR_CYAN" >&2
105
-        echo "||| $1" >&2;
105
+        echo "||| $msg" >&2;
106 106
         $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
107 107
     done
108 108
 }
@@ -116,7 +116,7 @@ tf_think() {
116 116
     for msg in "$@";
117 117
     do
118 118
         $TF_COLOR && echo -ne "$TF_COLOR_LBLACK" >&2
119
-        echo "$pfx$1$sfx" >&2;
119
+        echo "$pfx$msg$sfx" >&2;
120 120
         $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
121 121
     done
122 122
 }
@@ -129,7 +129,7 @@ tf_warn() {
129 129
     for msg in "$@";
130 130
     do
131 131
         $TF_COLOR && echo -ne "$TF_COLOR_LRED" >&2
132
-        echo "$1" >&2;
132
+        echo "$msg" >&2;
133 133
         $TF_COLOR && echo -ne "$TF_COLOR_NONE" >&2
134 134
     done
135 135
 }

+ 7
- 7
utils/tfkit/include/harness.sh Просмотреть файл

@@ -2,7 +2,7 @@
2 2
 # ffoo test harness
3 3
 # See LICENSE file for copyright and license details.
4 4
 
5
-. $TF_DIR/include/common.sh
5
+. "$TF_DIR/include/common.sh"
6 6
 
7 7
 #
8 8
 # Default path to header generator
@@ -34,7 +34,7 @@ __tf_collect_if_needed() {
34 34
     esac
35 35
     $will || return 0
36 36
     mkdir -p "$artifact_dir/$stamp"
37
-    cp -r $tmpdir/* "$artifact_dir/$stamp"
37
+    cp -r "$tmpdir"/* "$artifact_dir/$stamp"
38 38
 }
39 39
 
40 40
 __tf_default_header() {
@@ -65,9 +65,9 @@ tf_enum_tests() {
65 65
     # List what looks like test; relative to $TF_SUITE
66 66
     #
67 67
     tf_debug "TF_SUITE='$TF_SUITE'"
68
-    test -d $TF_SUITE || return 0
68
+    test -d "$TF_SUITE" || return 0
69 69
     find -L \
70
-        $TF_SUITE \
70
+        "$TF_SUITE" \
71 71
         -mindepth 2 \
72 72
         -maxdepth 2 \
73 73
         -type f \
@@ -95,16 +95,16 @@ tf_run_tests() {
95 95
     do
96 96
         tf_think "... $tname"
97 97
         tmpdir=$(mktemp -d)
98
-        stamp=$(date +artifacts-$tname-%Y%m%d-%H%M%S)
98
+        stamp=$(date "+artifacts-$tname-%Y%m%d-%H%M%S")
99 99
         cp -r "$TF_SUITE/$tname/"* "$tmpdir"
100
-        pushd $tmpdir >/dev/null
100
+        pushd "$tmpdir" >/dev/null
101 101
             TF_DIR="$tf_dir" TF_SUITE=$tf_suite TF_TNAME="$tname" \
102 102
                 ./TF_RUN
103 103
             tes=$?
104 104
             __tf_collect_if_needed $tes
105 105
             test $tes -gt $es && es=$tes
106 106
         popd >/dev/null
107
-        rm -rf $tmpdir
107
+        rm -rf "$tmpdir"
108 108
         if test $tes -eq 0;
109 109
         then
110 110
             tf_think "''' $tname ($tes)"

+ 3
- 3
utils/tfkit/include/subtest.sh Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-. $TF_DIR/include/common.sh
3
+. "$TF_DIR/include/common.sh"
4 4
 
5 5
 tf_enum_subtests() {
6 6
     #
@@ -22,7 +22,7 @@ tf_do_subtest() {
22 22
     #
23 23
     # Run single subtest inc. setup/cleanup if present
24 24
     #
25
-    local subtname=$1       # this subtest name
25
+    local subtname="$1"     # this subtest name
26 26
     local ses=0             # subtest exit status
27 27
     local tcmd=""           # test command
28 28
     local setup=true        # setup command
@@ -31,7 +31,7 @@ tf_do_subtest() {
31 31
     test -f TF_CLEANUP && cleanup=". TF_CLEANUP"
32 32
     if $setup;
33 33
     then
34
-        tcmd="$(tf_name2cmd $subtname)"
34
+        tcmd="$(tf_name2cmd "$subtname")"
35 35
         tf_debug "tcmd='$tcmd'"
36 36
         $tcmd; ses=$?
37 37
     else

+ 16
- 11
utils/tfkit/include/tools.sh Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-. $TF_DIR/include/common.sh
3
+. "$TF_DIR/include/common.sh"
4 4
 
5 5
 # 1. exec: [test] -> [result]
6 6
 # 2. eval:           [result] == [oracle]
@@ -30,17 +30,21 @@ tf_testflt() {
30 30
 
31 31
     # get args
32 32
     #
33
+    local orig_args="$0 $*"
34
+    tf_debug "orig_args=$orig_args"
35
+    local arg_err=false
33 36
     while true; do case "$1" in
34
-        -i) t_in="$2";          shift 2 ;;
35
-        -n) t_name="$2";        shift 2 ;;
36
-        -O) o_out="$2";         shift 2 ;;
37
-        -E) o_err="$2";         shift 2 ;;
38
-        -S) o_es="$2";          shift 2 ;;
37
+        -i) t_in="$2";          shift 2 || { arg_err=true; break; } ;;
38
+        -n) t_name="$2";        shift 2 || { arg_err=true; break; } ;;
39
+        -O) o_out="$2";         shift 2 || { arg_err=true; break; } ;;
40
+        -E) o_err="$2";         shift 2 || { arg_err=true; break; } ;;
41
+        -S) o_es="$2";          shift 2 || { arg_err=true; break; } ;;
39 42
         --)                     shift; break ;;
40 43
         "")                            break ;;
41 44
         -*) tf_warn "wrong testcli arg: $1"; return $TF_ES_BAILOUT ;;
42 45
         *)                             break ;;
43 46
     esac done
47
+    $arg_err && { tf_warn "error parsing arguments: $orig_args"; return $TF_ES_BAILOUT; }
44 48
     tf_debug "t_in='$t_in'"
45 49
     tf_debug "t_name='$t_name'"
46 50
     tf_debug "o_out='$o_out'"
@@ -53,6 +57,7 @@ tf_testflt() {
53 57
     test -r "$t_in"    || { tf_warn "missing input file: $t_in"     ; return $TF_ES_BAILOUT; }
54 58
     test -e "$o_out"   || { tf_warn "missing oracle stdout: $o_out" ; return $TF_ES_BAILOUT; }
55 59
     test -e "$o_err"   || { tf_warn "missing oracle stderr: $o_err" ; return $TF_ES_BAILOUT; }
60
+    test "$o_es" -ge 0 || { tf_warn "invalid oracle status: $o_es"  ; return $TF_ES_BAILOUT; }
56 61
 
57 62
     # prepare
58 63
     #
@@ -61,18 +66,18 @@ tf_testflt() {
61 66
     r_err="result/$t_name.stderr"
62 67
     tf_debug "r_out='$r_out'"
63 68
     tf_debug "r_err='$r_err'"
64
-    touch $r_out || { tf_warn "cannot create tmp file: $r_out" ; return $TF_ES_BAILOUT; }
65
-    touch $r_err || { tf_warn "cannot create tmp file: $r_err" ; return $TF_ES_PANIC; }
69
+    touch "$r_out" || { tf_warn "cannot create tmp file: $r_out" ; return $TF_ES_BAILOUT; }
70
+    touch "$r_err" || { tf_warn "cannot create tmp file: $r_err" ; return $TF_ES_PANIC; }
66 71
 
67 72
     # run
68 73
     #
69
-    ( <$t_in eval "$@" >$r_out 2>$r_err ); r_es=$?
74
+    ( <"$t_in" eval "$@" >"$r_out" 2>"$r_err" ); r_es=$?
70 75
     tf_debug "r_es='$r_es'"
71 76
 
72 77
     # eval/report/exit
73 78
     #
74 79
     test $r_es = $o_es || { tf_warn "bad exit status: $r_es (need $o_es)" ; t_es=$TF_ES_FAIL; }
75
-    diff -u $o_err $r_err || t_es=$TF_ES_FAIL
76
-    diff -u $o_out $r_out || t_es=$TF_ES_FAIL
80
+    diff -u "$o_err" "$r_err" || t_es=$TF_ES_FAIL
81
+    diff -u "$o_out" "$r_out" || t_es=$TF_ES_FAIL
77 82
     return $t_es
78 83
 }

+ 2
- 2
utils/tfkit/runtests Просмотреть файл

@@ -13,12 +13,12 @@ export TF_SUITE="${TF_SUITE:-tests}"
13 13
 export TF_ARTIFACTS="${TF_ARTIFACTS:-tfkit-artifacts}"
14 14
 export TF_COLLECT="${TF_COLLECT:-auto}"
15 15
 
16
-. $TF_DIR/include/harness.sh \
16
+. "$TF_DIR/include/harness.sh" \
17 17
  || die "cannot import harness; is TF_DIR set properly?: $TF_DIR"
18 18
 
19 19
 
20 20
 usage() {
21
-    echo "usage: $(basename $0) [-c|-C] [-t tests_re] [-s subtest_re] [-p binpath] [-v] [-d]" >&2
21
+    echo "usage: $(basename "$0") [-c|-C] [-t tests_re] [-s subtest_re] [-p binpath] [-v] [-d]" >&2
22 22
     exit 2
23 23
 }
24 24