diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 13:37:25 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 13:37:25 +0200 |
commit | 0eed355eac5a8f589f607825a56c87b6c93db79a (patch) | |
tree | 9063c1d8cd1d7a1377463abffc4a2fe8d17de340 | |
parent | 42ba757d5e80ba25cc192939aa3525049f9e092f (diff) | |
download | busybox-w32-0eed355eac5a8f589f607825a56c87b6c93db79a.tar.gz busybox-w32-0eed355eac5a8f589f607825a56c87b6c93db79a.tar.bz2 busybox-w32-0eed355eac5a8f589f607825a56c87b6c93db79a.zip |
ash: suppress readonly1.tests false positive; add readonly0.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash_test/ash-vars/readonly0.right | 13 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/readonly0.tests | 45 | ||||
-rw-r--r-- | shell/ash_test/ash-vars/readonly1.right | 4 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/readonly1.tests | 4 |
4 files changed, 62 insertions, 4 deletions
diff --git a/shell/ash_test/ash-vars/readonly0.right b/shell/ash_test/ash-vars/readonly0.right new file mode 100644 index 000000000..f3a6bde9e --- /dev/null +++ b/shell/ash_test/ash-vars/readonly0.right | |||
@@ -0,0 +1,13 @@ | |||
1 | readonly a='A' | ||
2 | readonly b='B' | ||
3 | Ok:0 | ||
4 | |||
5 | ./readonly0.tests: line 19: a: is read only | ||
6 | Fail:2 | ||
7 | ./readonly0.tests: readonly: line 21: a: is read only | ||
8 | Fail:2 | ||
9 | |||
10 | ./readonly0.tests: export: line 27: a: is read only | ||
11 | Fail:2 | ||
12 | |||
13 | Fail:1 | ||
diff --git a/shell/ash_test/ash-vars/readonly0.tests b/shell/ash_test/ash-vars/readonly0.tests new file mode 100755 index 000000000..94af79060 --- /dev/null +++ b/shell/ash_test/ash-vars/readonly0.tests | |||
@@ -0,0 +1,45 @@ | |||
1 | unset a b | ||
2 | # | ||
3 | readonly a=A | ||
4 | b=B | ||
5 | readonly b | ||
6 | # readonly on already readonly var is harmless: | ||
7 | readonly b a | ||
8 | readonly | grep '^readonly [ab]=' | ||
9 | # this should work: | ||
10 | export a b | ||
11 | export -n a b | ||
12 | echo Ok:$? | ||
13 | env | grep -e^a= -e^b= # shows nothing | ||
14 | |||
15 | echo | ||
16 | # these should all fail (despite the same value being assigned) | ||
17 | # bash does not abort even in non-interactive more (in script) | ||
18 | # ash does, using subshell to continue | ||
19 | true; (a=A) | ||
20 | echo Fail:$? | ||
21 | true; (readonly a=A) | ||
22 | echo Fail:$? | ||
23 | |||
24 | echo | ||
25 | # in bash, assignment in export fails, but export succeeds! :) | ||
26 | # we don't mimic that! | ||
27 | true; (export a=Z) | ||
28 | echo Fail:$? | ||
29 | #env | grep '^a=' | ||
30 | #echo "^^^a is exported" | ||
31 | export -n a # undo that bashism, if it happens | ||
32 | |||
33 | ## ash: assignment errors in "a=Z CMD" lead to CMD not executed | ||
34 | ## echo | ||
35 | ## export b | ||
36 | ## # this fails to both set and export a: | ||
37 | ## a=Z env | echo grep '^[ab]=' | ||
38 | ## echo "^^^a is not exported" | ||
39 | ## # but external command does get executed, and $? is not mangled (stays 42): | ||
40 | ## (exit 42); a=Z env echo Visible:$? | ||
41 | |||
42 | echo | ||
43 | # ash: this fails *silently*, bug? bash says "cannot unset: readonly variable" | ||
44 | true; unset a | ||
45 | echo Fail:$? | ||
diff --git a/shell/ash_test/ash-vars/readonly1.right b/shell/ash_test/ash-vars/readonly1.right index 2b363e325..1f5be64c7 100644 --- a/shell/ash_test/ash-vars/readonly1.right +++ b/shell/ash_test/ash-vars/readonly1.right | |||
@@ -1,2 +1,2 @@ | |||
1 | One:1 | 1 | Fail:2 |
2 | One:1 | 2 | Fail:2 |
diff --git a/shell/ash_test/ash-vars/readonly1.tests b/shell/ash_test/ash-vars/readonly1.tests index 81b461f5f..f3cccd940 100755 --- a/shell/ash_test/ash-vars/readonly1.tests +++ b/shell/ash_test/ash-vars/readonly1.tests | |||
@@ -1,7 +1,7 @@ | |||
1 | readonly bla=123 | 1 | readonly bla=123 |
2 | # Bare "eval bla=123" should abort ("eval" is a special builtin): | 2 | # Bare "eval bla=123" should abort ("eval" is a special builtin): |
3 | (eval bla=123 2>/dev/null; echo BUG) | 3 | (eval bla=123 2>/dev/null; echo BUG) |
4 | echo One:$? | 4 | echo Fail:$? |
5 | # "command BLTIN" disables "special-ness", should not abort: | 5 | # "command BLTIN" disables "special-ness", should not abort: |
6 | command eval bla=123 2>/dev/null | 6 | command eval bla=123 2>/dev/null |
7 | echo One:$? | 7 | echo Fail:$? |