aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/environment/deterministic-exit-code.exp55
-rwxr-xr-xtest/environment/environment.sh3
-rwxr-xr-xtest/fs/fs.sh3
-rwxr-xr-xtest/fs/private-cwd.exp52
-rwxr-xr-xtest/private-lib/private-lib.sh2
5 files changed, 114 insertions, 1 deletions
diff --git a/test/environment/deterministic-exit-code.exp b/test/environment/deterministic-exit-code.exp
new file mode 100755
index 000000000..165b9ebe0
--- /dev/null
+++ b/test/environment/deterministic-exit-code.exp
@@ -0,0 +1,55 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2019 Firejail Authors
4# License GPL v2
5
6set timeout 4
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17send -- "({ nohup bash -c \"sleep 0.2; exit 53\" &> /dev/null & } &)\r"
18send -- "exit 35\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Parent is shutting down"
22}
23after 300
24
25send -- "echo $?\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "53"
29}
30after 100
31
32send -- "firejail --deterministic-exit-code\r"
33expect {
34 timeout {puts "TESTING ERROR 3\n";exit}
35 "Child process initialized"
36}
37sleep 1
38
39send -- "({ nohup bash -c \"sleep 0.2; exit 53\" &> /dev/null & } &)\r"
40send -- "exit 35\r"
41expect {
42 timeout {puts "TESTING ERROR 4\n";exit}
43 "Parent is shutting down"
44}
45after 300
46
47send -- "echo $?\r"
48expect {
49 timeout {puts "TESTING ERROR 5\n";exit}
50 "35"
51}
52after 100
53
54
55puts "\nall done\n"
diff --git a/test/environment/environment.sh b/test/environment/environment.sh
index 85d6c0873..5b4aa32f4 100755
--- a/test/environment/environment.sh
+++ b/test/environment/environment.sh
@@ -116,3 +116,6 @@ echo "TESTING: rlimit errors (test/environment/rlimit-bad.exp)"
116 116
117echo "TESTING: rlimit errors profile (test/environment/rlimit-bad-profile.exp)" 117echo "TESTING: rlimit errors profile (test/environment/rlimit-bad-profile.exp)"
118./rlimit-bad-profile.exp 118./rlimit-bad-profile.exp
119
120echo "TESTING: deterministic exit code (test/environment/deterministic-exit-code.exp"
121./deterministic-exit-code.exp
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index 0fc216b20..7e1d46f0a 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -69,6 +69,9 @@ echo "TESTING: empty private-etc (test/fs/private-etc-empty.exp)"
69echo "TESTING: private-bin (test/fs/private-bin.exp)" 69echo "TESTING: private-bin (test/fs/private-bin.exp)"
70./private-bin.exp 70./private-bin.exp
71 71
72echo "TESTING: private-cwd (test/fs/private-cwd.exp)"
73./private-cwd.exp
74
72echo "TESTING: macros (test/fs/macro.exp)" 75echo "TESTING: macros (test/fs/macro.exp)"
73./macro.exp 76./macro.exp
74 77
diff --git a/test/fs/private-cwd.exp b/test/fs/private-cwd.exp
new file mode 100755
index 000000000..0fa87a92f
--- /dev/null
+++ b/test/fs/private-cwd.exp
@@ -0,0 +1,52 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2019 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "cd /tmp\r"
11after 100
12
13# testing profile and private
14send -- "firejail --private-cwd\r"
15expect {
16 timeout {puts "TESTING ERROR 0\n";exit}
17 "Child process initialized"
18}
19sleep 1
20
21send -- "pwd\r"
22expect {
23 timeout {puts "TESTING ERROR 1\n";exit}
24 "$env(HOME)"
25}
26after 100
27
28send -- "exit\r"
29sleep 1
30
31send -- "cd /\r"
32after 100
33
34# testing profile and private
35send -- "firejail --private-cwd=/tmp\r"
36expect {
37 timeout {puts "TESTING ERROR 3\n";exit}
38 "Child process initialized"
39}
40sleep 1
41
42send -- "pwd\r"
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 "/tmp"
46}
47after 100
48
49send -- "exit\r"
50sleep 1
51
52puts "all done\n"
diff --git a/test/private-lib/private-lib.sh b/test/private-lib/private-lib.sh
index 5e9d75379..79913fed6 100755
--- a/test/private-lib/private-lib.sh
+++ b/test/private-lib/private-lib.sh
@@ -5,7 +5,7 @@
5 5
6export MALLOC_CHECK_=3g 6export MALLOC_CHECK_=3g
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8LIST="gnome-logs gnome-system-log gnome-nettool pavucontrol dig whois evince galculator gnome-calculator gedit leafpad mousepad pluma transmission-gtk xcalc atril gpicview eom eog" 8LIST="gnome-logs gnome-system-log gnome-nettool pavucontrol dig evince whois galculator gnome-calculator gedit leafpad mousepad pluma transmission-gtk xcalc atril gpicview eom eog"
9 9
10 10
11for app in $LIST; do 11for app in $LIST; do