summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar smitsohu <smitsohu@gmail.com>2019-09-24 13:42:19 +0200
committerLibravatar smitsohu <smitsohu@gmail.com>2019-09-24 13:42:19 +0200
commit5bb476f74efb4754b6f5f8d711c6b77898ef9385 (patch)
treeb90acab8efa0b202f0416d87c68caaabaf0f6ee9 /test
parentMerge branch 'master' of https://github.com/netblue30/firejail (diff)
downloadfirejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.tar.gz
firejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.tar.zst
firejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.zip
testing
Diffstat (limited to 'test')
-rwxr-xr-xtest/fs/fs.sh7
-rwxr-xr-xtest/fs/private-cache.exp53
-rwxr-xr-xtest/fs/whitelist-whitespace.exp41
3 files changed, 101 insertions, 0 deletions
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index 7e1d46f0a..e706acd8d 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -5,6 +5,7 @@
5 5
6export MALLOC_CHECK_=3 6export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8export LC_ALL=C
8 9
9# These directories are required by some tests: 10# These directories are required by some tests:
10mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos 11mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos
@@ -102,6 +103,9 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)"
102echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" 103echo "TESTING: double whitelist (test/fs/whitelist-double.exp)"
103./whitelist-double.exp 104./whitelist-double.exp
104 105
106echo "TESTING: whitelist file with whitespaces (test/fs/whitelist-whitespace.exp)"
107./whitelist-whitespace.exp
108
105echo "TESTING: whitelist (test/fs/whitelist.exp)" 109echo "TESTING: whitelist (test/fs/whitelist.exp)"
106./whitelist.exp 110./whitelist.exp
107 111
@@ -117,6 +121,9 @@ echo "TESTING: fscheck --tmpfs non root (test/fs/fscheck-tmpfs.exp)"
117echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)" 121echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)"
118./fscheck-private.exp 122./fscheck-private.exp
119 123
124echo "TESTING: fscheck --private-cache (test/fs/fscheck-private-cache.exp)"
125./fscheck-private-cache.exp
126
120echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)" 127echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)"
121./fscheck-readonly.exp 128./fscheck-readonly.exp
122 129
diff --git a/test/fs/private-cache.exp b/test/fs/private-cache.exp
new file mode 100755
index 000000000..0a1f00eb5
--- /dev/null
+++ b/test/fs/private-cache.exp
@@ -0,0 +1,53 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7if {[file exists ~/.cache]} {
8 puts "found .cache directory\n"
9} else {
10 send -- "mkdir --mode=755 ~/.cache\r"
11}
12after 100
13
14send -- "touch ~/.cache/abcdefg\r"
15after 100
16
17send -- "firejail --noprofile --private-cache\r"
18expect {
19 timeout {puts "TESTING ERROR 1\n";exit}
20 "Child process initialized"
21}
22sleep 1
23
24send -- "ls ~/.cache | wc -l\r"
25expect {
26 timeout {puts "TESTING ERROR 2\n";exit}
27 "\n0"
28}
29after 100
30
31send -- "exit\r"
32sleep 1
33
34send -- "rm -v ~/.cache/abcdefg\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 "removed"
38}
39after 100
40
41# redo the test with --private
42
43send -- "firejail --noprofile --private --private-cache\r"
44expect {
45 timeout {puts "TESTING ERROR 4\n";exit}
46 "tmpfs not mounted"
47}
48sleep 1
49
50send -- "exit\r"
51sleep 1
52
53puts "\nall done\n"
diff --git a/test/fs/whitelist-whitespace.exp b/test/fs/whitelist-whitespace.exp
new file mode 100755
index 000000000..b16668557
--- /dev/null
+++ b/test/fs/whitelist-whitespace.exp
@@ -0,0 +1,41 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "touch ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r"
8after 100
9
10send -- "firejail --noprofile --whitelist=~/filewith\\\ \\\ many\\\ whitespaces\\\ \r"
11expect {
12 timeout {puts "TESTING ERROR 1\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17send -- "ls ~ | wc -l\r"
18expect {
19 timeout {puts "TESTING ERROR 2\n";exit}
20 "\n1"
21}
22after 100
23
24send -- "ls ~\r"
25expect {
26 timeout {puts "TESTING ERROR 3\n";exit}
27 "filewith many whitespaces "
28}
29after 100
30
31send -- "exit\r"
32sleep 1
33
34send -- "rm -v ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r"
35expect {
36 timeout {puts "TESTING ERROR 4\n";exit}
37 "removed"
38}
39after 100
40
41puts "\nall done\n"