diff options
author | smitsohu <smitsohu@gmail.com> | 2019-09-24 13:42:19 +0200 |
---|---|---|
committer | smitsohu <smitsohu@gmail.com> | 2019-09-24 13:42:19 +0200 |
commit | 5bb476f74efb4754b6f5f8d711c6b77898ef9385 (patch) | |
tree | b90acab8efa0b202f0416d87c68caaabaf0f6ee9 | |
parent | Merge branch 'master' of https://github.com/netblue30/firejail (diff) | |
download | firejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.tar.gz firejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.tar.zst firejail-5bb476f74efb4754b6f5f8d711c6b77898ef9385.zip |
testing
-rwxr-xr-x | test/fs/fs.sh | 7 | ||||
-rwxr-xr-x | test/fs/private-cache.exp | 53 | ||||
-rwxr-xr-x | test/fs/whitelist-whitespace.exp | 41 |
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 | ||
6 | export MALLOC_CHECK_=3 | 6 | export MALLOC_CHECK_=3 |
7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) | 7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) |
8 | export LC_ALL=C | ||
8 | 9 | ||
9 | # These directories are required by some tests: | 10 | # These directories are required by some tests: |
10 | mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos | 11 | mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos |
@@ -102,6 +103,9 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)" | |||
102 | echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" | 103 | echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" |
103 | ./whitelist-double.exp | 104 | ./whitelist-double.exp |
104 | 105 | ||
106 | echo "TESTING: whitelist file with whitespaces (test/fs/whitelist-whitespace.exp)" | ||
107 | ./whitelist-whitespace.exp | ||
108 | |||
105 | echo "TESTING: whitelist (test/fs/whitelist.exp)" | 109 | echo "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)" | |||
117 | echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)" | 121 | echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)" |
118 | ./fscheck-private.exp | 122 | ./fscheck-private.exp |
119 | 123 | ||
124 | echo "TESTING: fscheck --private-cache (test/fs/fscheck-private-cache.exp)" | ||
125 | ./fscheck-private-cache.exp | ||
126 | |||
120 | echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)" | 127 | echo "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 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | if {[file exists ~/.cache]} { | ||
8 | puts "found .cache directory\n" | ||
9 | } else { | ||
10 | send -- "mkdir --mode=755 ~/.cache\r" | ||
11 | } | ||
12 | after 100 | ||
13 | |||
14 | send -- "touch ~/.cache/abcdefg\r" | ||
15 | after 100 | ||
16 | |||
17 | send -- "firejail --noprofile --private-cache\r" | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 1\n";exit} | ||
20 | "Child process initialized" | ||
21 | } | ||
22 | sleep 1 | ||
23 | |||
24 | send -- "ls ~/.cache | wc -l\r" | ||
25 | expect { | ||
26 | timeout {puts "TESTING ERROR 2\n";exit} | ||
27 | "\n0" | ||
28 | } | ||
29 | after 100 | ||
30 | |||
31 | send -- "exit\r" | ||
32 | sleep 1 | ||
33 | |||
34 | send -- "rm -v ~/.cache/abcdefg\r" | ||
35 | expect { | ||
36 | timeout {puts "TESTING ERROR 3\n";exit} | ||
37 | "removed" | ||
38 | } | ||
39 | after 100 | ||
40 | |||
41 | # redo the test with --private | ||
42 | |||
43 | send -- "firejail --noprofile --private --private-cache\r" | ||
44 | expect { | ||
45 | timeout {puts "TESTING ERROR 4\n";exit} | ||
46 | "tmpfs not mounted" | ||
47 | } | ||
48 | sleep 1 | ||
49 | |||
50 | send -- "exit\r" | ||
51 | sleep 1 | ||
52 | |||
53 | puts "\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 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "touch ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" | ||
8 | after 100 | ||
9 | |||
10 | send -- "firejail --noprofile --whitelist=~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" | ||
11 | expect { | ||
12 | timeout {puts "TESTING ERROR 1\n";exit} | ||
13 | "Child process initialized" | ||
14 | } | ||
15 | sleep 1 | ||
16 | |||
17 | send -- "ls ~ | wc -l\r" | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 2\n";exit} | ||
20 | "\n1" | ||
21 | } | ||
22 | after 100 | ||
23 | |||
24 | send -- "ls ~\r" | ||
25 | expect { | ||
26 | timeout {puts "TESTING ERROR 3\n";exit} | ||
27 | "filewith many whitespaces " | ||
28 | } | ||
29 | after 100 | ||
30 | |||
31 | send -- "exit\r" | ||
32 | sleep 1 | ||
33 | |||
34 | send -- "rm -v ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" | ||
35 | expect { | ||
36 | timeout {puts "TESTING ERROR 4\n";exit} | ||
37 | "removed" | ||
38 | } | ||
39 | after 100 | ||
40 | |||
41 | puts "\nall done\n" | ||