diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-11 12:57:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-11 12:57:35 +0000 |
commit | 119b995437c52a164b2c5e51ef918c3f46b8a130 (patch) | |
tree | 831d555b51a3a6b4dd9160b1eb782f8b3d370660 | |
parent | 3e9aaae5dc384ae070c49507a92b1375397954cd (diff) | |
download | busybox-w32-119b995437c52a164b2c5e51ef918c3f46b8a130.tar.gz busybox-w32-119b995437c52a164b2c5e51ef918c3f46b8a130.tar.bz2 busybox-w32-119b995437c52a164b2c5e51ef918c3f46b8a130.zip |
hush: reinstate hush_test, add testcases for process subst
-rw-r--r-- | shell/hush_test/hush-parsing/noeol.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-parsing/noeol.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-parsing/process_subst.right | 2 | ||||
-rwxr-xr-x | shell/hush_test/hush-parsing/process_subst.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/var.right | 4 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var.tests | 10 | ||||
-rwxr-xr-x | shell/hush_test/run-all | 59 |
7 files changed, 80 insertions, 0 deletions
diff --git a/shell/hush_test/hush-parsing/noeol.right b/shell/hush_test/hush-parsing/noeol.right new file mode 100644 index 000000000..e427984d4 --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol.right | |||
@@ -0,0 +1 @@ | |||
HELLO | |||
diff --git a/shell/hush_test/hush-parsing/noeol.tests b/shell/hush_test/hush-parsing/noeol.tests new file mode 100755 index 000000000..a93113a03 --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | # next line has no EOL! | ||
2 | echo HELLO \ No newline at end of file | ||
diff --git a/shell/hush_test/hush-parsing/process_subst.right b/shell/hush_test/hush-parsing/process_subst.right new file mode 100644 index 000000000..8f9ab9d40 --- /dev/null +++ b/shell/hush_test/hush-parsing/process_subst.right | |||
@@ -0,0 +1,2 @@ | |||
1 | TESTzzBEST | ||
2 | TEST$(echo zz)BEST | ||
diff --git a/shell/hush_test/hush-parsing/process_subst.tests b/shell/hush_test/hush-parsing/process_subst.tests new file mode 100755 index 000000000..f8299a514 --- /dev/null +++ b/shell/hush_test/hush-parsing/process_subst.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | echo "TEST`echo zz;echo;echo`BEST" | ||
2 | echo "TEST`echo '$(echo zz)'`BEST" | ||
diff --git a/shell/hush_test/hush-vars/var.right b/shell/hush_test/hush-vars/var.right new file mode 100644 index 000000000..c13b98e38 --- /dev/null +++ b/shell/hush_test/hush-vars/var.right | |||
@@ -0,0 +1,4 @@ | |||
1 | http://busybox.net | ||
2 | http://busybox.net_abc | ||
3 | 1 | ||
4 | 0 | ||
diff --git a/shell/hush_test/hush-vars/var.tests b/shell/hush_test/hush-vars/var.tests new file mode 100755 index 000000000..b0637ea6b --- /dev/null +++ b/shell/hush_test/hush-vars/var.tests | |||
@@ -0,0 +1,10 @@ | |||
1 | URL=http://busybox.net | ||
2 | |||
3 | echo $URL | ||
4 | echo ${URL}_abc | ||
5 | |||
6 | true | ||
7 | false; echo $? | ||
8 | true | ||
9 | # BUG: prints 0, must be 1 | ||
10 | { false; echo $?; } | ||
diff --git a/shell/hush_test/run-all b/shell/hush_test/run-all new file mode 100755 index 000000000..ec8323008 --- /dev/null +++ b/shell/hush_test/run-all | |||
@@ -0,0 +1,59 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | test -x hush || { echo "No ./hush?!"; exit; } | ||
4 | |||
5 | PATH="$PWD:$PATH" # for hush and recho/zecho/printenv | ||
6 | export PATH | ||
7 | |||
8 | THIS_SH="$PWD/hush" | ||
9 | export THIS_SH | ||
10 | |||
11 | do_test() | ||
12 | { | ||
13 | test -d "$1" || return 0 | ||
14 | ( | ||
15 | cd "$1" || { echo "cannot cd $1!"; exit 1; } | ||
16 | for x in run-*; do | ||
17 | test -f "$x" || continue | ||
18 | case "$x" in | ||
19 | "$0"|run-minimal|run-gprof) ;; | ||
20 | *.orig|*~) ;; | ||
21 | #*) echo $x ; sh $x ;; | ||
22 | *) | ||
23 | sh "$x" >"../$1-$x.fail" 2>&1 && \ | ||
24 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; | ||
25 | ;; | ||
26 | esac | ||
27 | done | ||
28 | # Many bash run-XXX scripts just do this, | ||
29 | # no point in duplication it all over the place | ||
30 | for x in *.tests; do | ||
31 | test -x "$x" || continue | ||
32 | name="${x%%.tests}" | ||
33 | test -f "$name.right" || continue | ||
34 | { | ||
35 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 | ||
36 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" | ||
37 | } && echo "$1/$x: ok" || echo "$1/$x: fail" | ||
38 | done | ||
39 | ) | ||
40 | } | ||
41 | |||
42 | # Main part of this script | ||
43 | # Usage: run-all [directories] | ||
44 | |||
45 | if [ $# -lt 1 ]; then | ||
46 | # All sub directories | ||
47 | modules=`ls -d hush-*` | ||
48 | |||
49 | for module in $modules; do | ||
50 | do_test $module | ||
51 | done | ||
52 | else | ||
53 | while [ $# -ge 1 ]; do | ||
54 | if [ -d $1 ]; then | ||
55 | do_test $1 | ||
56 | fi | ||
57 | shift | ||
58 | done | ||
59 | fi | ||