aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-04-13 20:47:18 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-04-13 20:47:18 -0400
commitc85acb7ba71b153806632256b511b915b872c5bc (patch)
tree0b7d6a11cde99266be994fd319b6edaa4ccd21cf /test
parentprofile fixes (diff)
downloadfirejail-c85acb7ba71b153806632256b511b915b872c5bc.tar.gz
firejail-c85acb7ba71b153806632256b511b915b872c5bc.tar.zst
firejail-c85acb7ba71b153806632256b511b915b872c5bc.zip
wait up to 10 seconds for sandbox shutdown
Diffstat (limited to 'test')
-rwxr-xr-xtest/catchsignal-master.sh4
-rwxr-xr-xtest/catchsignal.sh27
-rwxr-xr-xtest/catchsignal2.sh49
-rwxr-xr-xtest/option-shutdown2.exp42
-rwxr-xr-xtest/option-shutdown3.exp62
-rwxr-xr-xtest/option-shutdown4.exp66
-rwxr-xr-xtest/pid.exp2
-rwxr-xr-xtest/test.sh9
8 files changed, 260 insertions, 1 deletions
diff --git a/test/catchsignal-master.sh b/test/catchsignal-master.sh
new file mode 100755
index 000000000..62a1801cc
--- /dev/null
+++ b/test/catchsignal-master.sh
@@ -0,0 +1,4 @@
1#!/bin/bash
2
3./catchsignal.sh &
4./catchsignal.sh &
diff --git a/test/catchsignal.sh b/test/catchsignal.sh
new file mode 100755
index 000000000..87a1d0adf
--- /dev/null
+++ b/test/catchsignal.sh
@@ -0,0 +1,27 @@
1#!/bin/bash
2
3_term() {
4 echo "Caught Signal"
5 echo 1
6 sleep 1
7 echo 2
8 sleep 1
9 echo 3
10 sleep 1
11 echo 4
12 sleep 1
13 echo 5
14 sleep 1
15
16 kill $pid
17 exit
18}
19
20trap _term SIGTERM
21trap _term SIGINT
22
23echo "Sleeping..."
24
25sleep inf &
26pid=$!
27wait $pid
diff --git a/test/catchsignal2.sh b/test/catchsignal2.sh
new file mode 100755
index 000000000..424350397
--- /dev/null
+++ b/test/catchsignal2.sh
@@ -0,0 +1,49 @@
1#!/bin/bash
2
3_term() {
4 echo "Caught Signal"
5 echo 1
6 sleep 1
7 echo 2
8 sleep 1
9 echo 3
10 sleep 1
11 echo 4
12 sleep 1
13 echo 5
14 sleep 1
15
16 echo 10
17 sleep 1
18 echo 20
19 sleep 1
20 echo 30
21 sleep 1
22 echo 40
23 sleep 1
24 echo 50
25 sleep 1
26
27 echo 100
28 sleep 1
29 echo 200
30 sleep 1
31 echo 300
32 sleep 1
33 echo 400
34 sleep 1
35 echo 500
36 sleep 1
37
38 kill $pid
39 exit
40}
41
42trap _term SIGTERM
43trap _term SIGINT
44
45echo "Sleeping..."
46
47sleep inf &
48pid=$!
49wait $pid
diff --git a/test/option-shutdown2.exp b/test/option-shutdown2.exp
new file mode 100755
index 000000000..403bc30be
--- /dev/null
+++ b/test/option-shutdown2.exp
@@ -0,0 +1,42 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7set firstspawn $spawn_id
8
9send -- "firejail --name=shutdowntesting ./catchsignal.sh\r"
10expect {
11 timeout {puts "TESTING ERROR 0\n";exit}
12 "Child process initialized"
13}
14sleep 2
15
16spawn $env(SHELL)
17send -- "firejail --shutdown=shutdowntesting\r"
18
19set spawn_id $firstspawn
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "1"
23}
24expect {
25 timeout {puts "TESTING ERROR 2\n";exit}
26 "2"
27}
28expect {
29 timeout {puts "TESTING ERROR 3\n";exit}
30 "3"
31}
32expect {
33 timeout {puts "TESTING ERROR 4\n";exit}
34 "4"
35}
36expect {
37 timeout {puts "TESTING ERROR 5\n";exit}
38 "5"
39}
40sleep 1
41
42puts "\nalldone\n"
diff --git a/test/option-shutdown3.exp b/test/option-shutdown3.exp
new file mode 100755
index 000000000..0ef371cd8
--- /dev/null
+++ b/test/option-shutdown3.exp
@@ -0,0 +1,62 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7set firstspawn $spawn_id
8
9send -- "firejail --name=shutdowntesting ./catchsignal-master.sh\r"
10expect {
11 timeout {puts "TESTING ERROR 0\n";exit}
12 "Child process initialized"
13}
14sleep 2
15
16spawn $env(SHELL)
17send -- "firejail --shutdown=shutdowntesting\r"
18
19set spawn_id $firstspawn
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "1"
23}
24expect {
25 timeout {puts "TESTING ERROR 2\n";exit}
26 "1"
27}
28expect {
29 timeout {puts "TESTING ERROR 3\n";exit}
30 "2"
31}
32expect {
33 timeout {puts "TESTING ERROR 4\n";exit}
34 "2"
35}
36expect {
37 timeout {puts "TESTING ERROR 5\n";exit}
38 "3"
39}
40expect {
41 timeout {puts "TESTING ERROR 6\n";exit}
42 "3"
43}
44expect {
45 timeout {puts "TESTING ERROR 7\n";exit}
46 "4"
47}
48expect {
49 timeout {puts "TESTING ERROR 8\n";exit}
50 "4"
51}
52expect {
53 timeout {puts "TESTING ERROR 9\n";exit}
54 "5"
55}
56expect {
57 timeout {puts "TESTING ERROR 10\n";exit}
58 "5"
59}
60sleep 1
61
62puts "\nalldone\n"
diff --git a/test/option-shutdown4.exp b/test/option-shutdown4.exp
new file mode 100755
index 000000000..f188ec66d
--- /dev/null
+++ b/test/option-shutdown4.exp
@@ -0,0 +1,66 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7set firstspawn $spawn_id
8
9send -- "firejail --name=shutdowntesting ./catchsignal2.sh\r"
10expect {
11 timeout {puts "TESTING ERROR 0\n";exit}
12 "Child process initialized"
13}
14sleep 2
15
16spawn $env(SHELL)
17send -- "firejail --shutdown=shutdowntesting\r"
18
19set spawn_id $firstspawn
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "1"
23}
24expect {
25 timeout {puts "TESTING ERROR 2\n";exit}
26 "2"
27}
28expect {
29 timeout {puts "TESTING ERROR 3\n";exit}
30 "3"
31}
32expect {
33 timeout {puts "TESTING ERROR 4\n";exit}
34 "4"
35}
36expect {
37 timeout {puts "TESTING ERROR 5\n";exit}
38 "5"
39}
40expect {
41 timeout {puts "TESTING ERROR 10\n";exit}
42 "10"
43}
44expect {
45 timeout {puts "TESTING ERROR 20\n";exit}
46 "20"
47}
48expect {
49 timeout {puts "TESTING ERROR 30\n";exit}
50 "30"
51}
52expect {
53 timeout {puts "TESTING ERROR 40\n";exit}
54 "40"
55}
56expect {
57 timeout {puts "TESTING ERROR 50\n";exit}
58 "50"
59}
60expect {
61 timeout {puts "TESTING ERROR 60\n";exit}
62 "Killed"
63}
64sleep 1
65
66puts "\nalldone\n"
diff --git a/test/pid.exp b/test/pid.exp
index fb5b90f04..cdeb9d5fb 100755
--- a/test/pid.exp
+++ b/test/pid.exp
@@ -37,7 +37,7 @@ sleep 1
37send -- "ps aux |wc -l; pwd\r" 37send -- "ps aux |wc -l; pwd\r"
38expect { 38expect {
39 timeout {puts "TESTING ERROR 5\n";exit} 39 timeout {puts "TESTING ERROR 5\n";exit}
40 "6" {puts "normal system\n'} 40 "6" {puts "normal system\n"}
41 "5" {puts "grsecurity\n"} 41 "5" {puts "grsecurity\n"}
42} 42}
43expect { 43expect {
diff --git a/test/test.sh b/test/test.sh
index 96ef8f423..c6fe4f299 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -133,6 +133,15 @@ echo "TESTING: rlimit (option_rlimit.exp)"
133echo "TESTING: shutdown (option_shutdown.exp)" 133echo "TESTING: shutdown (option_shutdown.exp)"
134./option-shutdown.exp 134./option-shutdown.exp
135 135
136echo "TESTING: shutdown2 (option_shutdown2.exp)"
137./option-shutdown2.exp
138
139echo "TESTING: shutdown3 (option_shutdown3.exp)"
140./option-shutdown3.exp
141
142echo "TESTING: shutdown4 (option_shutdown4.exp)"
143./option-shutdown4.exp
144
136echo "TESTING: join (option-join.exp)" 145echo "TESTING: join (option-join.exp)"
137./option-join.exp 146./option-join.exp
138 147