aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-21 13:37:25 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-21 13:37:25 +0200
commit0eed355eac5a8f589f607825a56c87b6c93db79a (patch)
tree9063c1d8cd1d7a1377463abffc4a2fe8d17de340
parent42ba757d5e80ba25cc192939aa3525049f9e092f (diff)
downloadbusybox-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.right13
-rwxr-xr-xshell/ash_test/ash-vars/readonly0.tests45
-rw-r--r--shell/ash_test/ash-vars/readonly1.right4
-rwxr-xr-xshell/ash_test/ash-vars/readonly1.tests4
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 @@
1readonly a='A'
2readonly b='B'
3Ok:0
4
5./readonly0.tests: line 19: a: is read only
6Fail:2
7./readonly0.tests: readonly: line 21: a: is read only
8Fail:2
9
10./readonly0.tests: export: line 27: a: is read only
11Fail:2
12
13Fail: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 @@
1unset a b
2#
3readonly a=A
4b=B
5readonly b
6# readonly on already readonly var is harmless:
7readonly b a
8readonly | grep '^readonly [ab]='
9# this should work:
10export a b
11export -n a b
12echo Ok:$?
13env | grep -e^a= -e^b= # shows nothing
14
15echo
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
19true; (a=A)
20echo Fail:$?
21true; (readonly a=A)
22echo Fail:$?
23
24echo
25# in bash, assignment in export fails, but export succeeds! :)
26# we don't mimic that!
27true; (export a=Z)
28echo Fail:$?
29#env | grep '^a='
30#echo "^^^a is exported"
31export -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
42echo
43# ash: this fails *silently*, bug? bash says "cannot unset: readonly variable"
44true; unset a
45echo 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 @@
1One:1 1Fail:2
2One:1 2Fail: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 @@
1readonly bla=123 1readonly 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)
4echo One:$? 4echo Fail:$?
5# "command BLTIN" disables "special-ness", should not abort: 5# "command BLTIN" disables "special-ness", should not abort:
6command eval bla=123 2>/dev/null 6command eval bla=123 2>/dev/null
7echo One:$? 7echo Fail:$?