aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils')
-rwxr-xr-xtest/utils/caps-print.exp32
-rw-r--r--test/utils/caps1.profile1
-rw-r--r--test/utils/caps2.profile1
-rwxr-xr-xtest/utils/catchsignal-master.sh4
-rwxr-xr-xtest/utils/catchsignal.sh27
-rwxr-xr-xtest/utils/catchsignal2.sh49
-rwxr-xr-xtest/utils/cpu-print.exp24
-rwxr-xr-xtest/utils/dns-print.exp24
-rwxr-xr-xtest/utils/firemon-caps.exp130
-rwxr-xr-xtest/utils/firemon-cgroup.exp41
-rwxr-xr-xtest/utils/firemon-cpu.exp45
-rwxr-xr-xtest/utils/firemon-seccomp.exp49
-rwxr-xr-xtest/utils/fs-print.exp32
-rwxr-xr-xtest/utils/help.exp25
-rwxr-xr-xtest/utils/join-profile.exp35
-rwxr-xr-xtest/utils/join.exp38
-rwxr-xr-xtest/utils/join2.exp38
-rwxr-xr-xtest/utils/join3.exp38
-rwxr-xr-xtest/utils/join4.exp38
-rwxr-xr-xtest/utils/list.exp51
-rwxr-xr-xtest/utils/ls.exp69
-rwxr-xr-xtest/utils/man.exp20
-rw-r--r--test/utils/name.profile1
-rwxr-xr-xtest/utils/protocol-print.exp24
-rwxr-xr-xtest/utils/seccomp-print.exp36
-rwxr-xr-xtest/utils/shutdown.exp35
-rwxr-xr-xtest/utils/shutdown2.exp45
-rwxr-xr-xtest/utils/shutdown3.exp65
-rwxr-xr-xtest/utils/shutdown4.exp65
-rwxr-xr-xtest/utils/top.exp40
-rwxr-xr-xtest/utils/trace.exp115
-rwxr-xr-xtest/utils/tree.exp63
-rwxr-xr-xtest/utils/utils.sh102
-rwxr-xr-xtest/utils/version.exp18
34 files changed, 1420 insertions, 0 deletions
diff --git a/test/utils/caps-print.exp b/test/utils/caps-print.exp
new file mode 100755
index 000000000..fa5239da2
--- /dev/null
+++ b/test/utils/caps-print.exp
@@ -0,0 +1,32 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --caps.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "setgid - disabled"
22}
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "setuid - disabled"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "net_raw - disabled"
30}
31after 100
32puts "\nall done\n"
diff --git a/test/utils/caps1.profile b/test/utils/caps1.profile
new file mode 100644
index 000000000..e14655b2e
--- /dev/null
+++ b/test/utils/caps1.profile
@@ -0,0 +1 @@
caps.drop chown,kill \ No newline at end of file
diff --git a/test/utils/caps2.profile b/test/utils/caps2.profile
new file mode 100644
index 000000000..cb2258c52
--- /dev/null
+++ b/test/utils/caps2.profile
@@ -0,0 +1 @@
caps.keep chown,kill \ No newline at end of file
diff --git a/test/utils/catchsignal-master.sh b/test/utils/catchsignal-master.sh
new file mode 100755
index 000000000..62a1801cc
--- /dev/null
+++ b/test/utils/catchsignal-master.sh
@@ -0,0 +1,4 @@
1#!/bin/bash
2
3./catchsignal.sh &
4./catchsignal.sh &
diff --git a/test/utils/catchsignal.sh b/test/utils/catchsignal.sh
new file mode 100755
index 000000000..87a1d0adf
--- /dev/null
+++ b/test/utils/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/utils/catchsignal2.sh b/test/utils/catchsignal2.sh
new file mode 100755
index 000000000..424350397
--- /dev/null
+++ b/test/utils/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/utils/cpu-print.exp b/test/utils/cpu-print.exp
new file mode 100755
index 000000000..ca2e57313
--- /dev/null
+++ b/test/utils/cpu-print.exp
@@ -0,0 +1,24 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test --cpu=1,2\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --cpu.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Cpus_allowed_list: 1-2"
22}
23after 100
24puts "\nall done\n"
diff --git a/test/utils/dns-print.exp b/test/utils/dns-print.exp
new file mode 100755
index 000000000..406ab5149
--- /dev/null
+++ b/test/utils/dns-print.exp
@@ -0,0 +1,24 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test --dns=1.2.3.4\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --dns.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "nameserver 1.2.3.4"
22}
23after 100
24puts "\nall done\n"
diff --git a/test/utils/firemon-caps.exp b/test/utils/firemon-caps.exp
new file mode 100755
index 000000000..76aa13725
--- /dev/null
+++ b/test/utils/firemon-caps.exp
@@ -0,0 +1,130 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=bingo1 --noprofile --caps\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=bingo2 --noprofile\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firejail --name=bingo3 --noprofile --caps.drop=all\r"
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "Child process initialized"
30}
31sleep 1
32
33spawn $env(SHELL)
34send -- "firejail --noprofile --name=bingo4 --caps.drop=chown,kill\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 "Child process initialized"
38}
39sleep 1
40
41spawn $env(SHELL)
42send -- "firejail --noprofile --name=bingo5 --caps.keep=chown,kill\r"
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 "Child process initialized"
46}
47sleep 1
48
49spawn $env(SHELL)
50send -- "firejail --name=bingo6 --profile=caps1.profile\r"
51expect {
52 timeout {puts "TESTING ERROR 5\n";exit}
53 "Child process initialized"
54}
55sleep 1
56
57spawn $env(SHELL)
58send -- "firejail --name=bingo7 --profile=caps2.profile\r"
59expect {
60 timeout {puts "TESTING ERROR 0\n";exit}
61 "Child process initialized"
62}
63sleep 1
64
65spawn $env(SHELL)
66send -- "firemon --caps\r"
67expect {
68 timeout {puts "TESTING ERROR 8.1\n";exit}
69 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
70 "bingo1"
71}
72expect {
73 timeout {puts "TESTING ERROR 8.2\n";exit}
74 "31cffff"
75}
76expect {
77 timeout {puts "TESTING ERROR 8.3\n";exit}
78 "bingo2"
79}
80expect {
81 timeout {puts "TESTING ERROR 8.4\n";exit}
82 "fffffff"
83}
84expect {
85 timeout {puts "TESTING ERROR 8.5\n";exit}
86 "bingo3"
87}
88expect {
89 timeout {puts "TESTING ERROR 8.6\n";exit}
90 "000000000000"
91}
92
93expect {
94 timeout {puts "TESTING ERROR 8.7\n";exit}
95 "bingo4"
96}
97expect {
98 timeout {puts "TESTING ERROR 8.8\n";exit}
99 "ffffffde"
100}
101expect {
102 timeout {puts "TESTING ERROR 8.9\n";exit}
103 "bingo5"
104}
105expect {
106 timeout {puts "TESTING ERROR 8.10\n";exit}
107 "0000000000000021"
108}
109
110expect {
111 timeout {puts "TESTING ERROR 8.11\n";exit}
112 "bingo6"
113}
114expect {
115 timeout {puts "TESTING ERROR 8.12\n";exit}
116 "ffffffde"
117}
118expect {
119 timeout {puts "TESTING ERROR 8.13\n";exit}
120 "bingo7"
121}
122expect {
123 timeout {puts "TESTING ERROR 8.14\n";exit}
124 "0000000000000021"
125}
126
127after 100
128
129puts "all done\n"
130
diff --git a/test/utils/firemon-cgroup.exp b/test/utils/firemon-cgroup.exp
new file mode 100755
index 000000000..b1ab083ae
--- /dev/null
+++ b/test/utils/firemon-cgroup.exp
@@ -0,0 +1,41 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test1\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=test2\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firemon --cgroup\r"
27sleep 4
28expect {
29 timeout {puts "TESTING ERROR 2\n";exit}
30 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
31 "name=test1"
32}
33expect {
34 timeout {puts "TESTING ERROR 3\n";exit}
35 "name=test2"
36}
37
38after 100
39
40puts "\nall done\n"
41
diff --git a/test/utils/firemon-cpu.exp b/test/utils/firemon-cpu.exp
new file mode 100755
index 000000000..f2ecd4a5c
--- /dev/null
+++ b/test/utils/firemon-cpu.exp
@@ -0,0 +1,45 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test1\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=test2\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firemon --cpu\r"
27sleep 4
28expect {
29 timeout {puts "TESTING ERROR 2\n";exit}
30 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
31 "name=test1"
32}
33expect {
34 timeout {puts "TESTING ERROR 3\n";exit}
35 "Cpus_allowed_list"
36}
37expect {
38 timeout {puts "TESTING ERROR 4\n";exit}
39 "name=test2"
40}
41
42after 100
43
44puts "\nall done\n"
45
diff --git a/test/utils/firemon-seccomp.exp b/test/utils/firemon-seccomp.exp
new file mode 100755
index 000000000..26c478344
--- /dev/null
+++ b/test/utils/firemon-seccomp.exp
@@ -0,0 +1,49 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --noprofile --name=bingo1 --seccomp\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --noprofile --name=bingo2\r"
19expect {
20 timeout {puts "TESTING ERROR 0.1\n";exit}
21 "Child process initialized"
22}
23sleep 1
24
25
26
27
28spawn $env(SHELL)
29send -- "firemon --seccomp\r"
30expect {
31 timeout {puts "TESTING ERROR 1\n";exit}
32 "need to be root" {puts "TESTING SKIP: /proc mounted as hidepid\n"; exit}
33 "bingo1"
34}
35expect {
36 timeout {puts "TESTING ERROR 2\n";exit}
37 "Seccomp: 2"
38}
39expect {
40 timeout {puts "TESTING ERROR 3\n";exit}
41 "bingo2"
42}
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 "Seccomp: 0"
46}
47after 100
48
49puts "all done\n"
diff --git a/test/utils/fs-print.exp b/test/utils/fs-print.exp
new file mode 100755
index 000000000..4d4ceb718
--- /dev/null
+++ b/test/utils/fs-print.exp
@@ -0,0 +1,32 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --fs.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "blacklist /boot"
22}
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "blacklist /dev/kmsg"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "blacklist /proc/kmsg"
30}
31after 100
32puts "\nall done\n"
diff --git a/test/utils/help.exp b/test/utils/help.exp
new file mode 100755
index 000000000..5b9864578
--- /dev/null
+++ b/test/utils/help.exp
@@ -0,0 +1,25 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --help\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "License GPL version 2 or later"
14}
15after 100
16
17send -- "firejail -?\r"
18expect {
19 timeout {puts "TESTING ERROR 0\n";exit}
20 "License GPL version 2 or later"
21}
22after 100
23
24puts "\n"
25
diff --git a/test/utils/join-profile.exp b/test/utils/join-profile.exp
new file mode 100755
index 000000000..a2078c2f6
--- /dev/null
+++ b/test/utils/join-profile.exp
@@ -0,0 +1,35 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7
8send -- "firejail --profile=name.profile\r"
9expect {
10 timeout {puts "TESTING ERROR 0\n";exit}
11 "Child process initialized"
12}
13sleep 2
14
15spawn $env(SHELL)
16send -- "firejail --join=jointesting\r"
17expect {
18 timeout {puts "TESTING ERROR 1\n";exit}
19 "Switching to pid"
20}
21sleep 1
22send -- "ps aux\r"
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "/bin/bash"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "/bin/bash"
30}
31
32send -- "exit"
33after 100
34
35puts "\nall done\n"
diff --git a/test/utils/join.exp b/test/utils/join.exp
new file mode 100755
index 000000000..fc30bc6a4
--- /dev/null
+++ b/test/utils/join.exp
@@ -0,0 +1,38 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7cd /home
8spawn $env(SHELL)
9match_max 100000
10
11send -- "firejail --name=jointesting --cpu=0 --nice=2\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --join=jointesting\r"
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "Switching to pid"
23}
24sleep 1
25send -- "ps aux\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "/bin/bash"
29}
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "/bin/bash"
33}
34
35send -- "exit"
36after 100
37
38puts "\nall done\n"
diff --git a/test/utils/join2.exp b/test/utils/join2.exp
new file mode 100755
index 000000000..5895eb730
--- /dev/null
+++ b/test/utils/join2.exp
@@ -0,0 +1,38 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7cd /home
8spawn $env(SHELL)
9match_max 100000
10
11send -- "firejail --name=\"join testing\"\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --join=\"join testing\"\r"
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "Switching to pid"
23}
24sleep 1
25send -- "ps aux\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "/bin/bash"
29}
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "/bin/bash"
33}
34
35send -- "exit"
36after 100
37
38puts "\nall done\n"
diff --git a/test/utils/join3.exp b/test/utils/join3.exp
new file mode 100755
index 000000000..3ccc47bf9
--- /dev/null
+++ b/test/utils/join3.exp
@@ -0,0 +1,38 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7cd /home
8spawn $env(SHELL)
9match_max 100000
10
11send -- "firejail --name=join\\ testing\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --join=join\\ testing\r"
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "Switching to pid"
23}
24sleep 1
25send -- "ps aux\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "/bin/bash"
29}
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "/bin/bash"
33}
34
35send -- "exit"
36after 100
37
38puts "\nall done\n"
diff --git a/test/utils/join4.exp b/test/utils/join4.exp
new file mode 100755
index 000000000..c367dd770
--- /dev/null
+++ b/test/utils/join4.exp
@@ -0,0 +1,38 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7cd /home
8spawn $env(SHELL)
9match_max 100000
10
11send -- "firejail --name=123test\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --join=123test\r"
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "Switching to pid"
23}
24sleep 1
25send -- "ps aux\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "/bin/bash"
29}
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "/bin/bash"
33}
34
35send -- "exit"
36after 100
37
38puts "\nall done\n"
diff --git a/test/utils/list.exp b/test/utils/list.exp
new file mode 100755
index 000000000..69db1f568
--- /dev/null
+++ b/test/utils/list.exp
@@ -0,0 +1,51 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15after 100
16
17spawn $env(SHELL)
18send -- "firejail\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23after 100
24
25spawn $env(SHELL)
26send -- "firejail\r"
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "Child process initialized"
30}
31sleep 1
32
33spawn $env(SHELL)
34send -- "firejail --list\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 ":firejail"
38}
39expect {
40 timeout {puts "TESTING ERROR 4\n";exit}
41 ":firejail"
42}
43expect {
44 timeout {puts "TESTING ERROR 5\n";exit}
45 ":firejail"
46}
47after 100
48
49
50puts "\n"
51
diff --git a/test/utils/ls.exp b/test/utils/ls.exp
new file mode 100755
index 000000000..ff6867c51
--- /dev/null
+++ b/test/utils/ls.exp
@@ -0,0 +1,69 @@
1#!/usr/bin/expect -f
2
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6set firstspawn $spawn_id
7
8
9send -- "rm -f lstesting\r"
10sleep 1
11send -- "firejail --private --name=test\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 1
17send -- "echo my_testing > ~/lstesting\r"
18after 100
19
20# ls
21spawn $env(SHELL)
22send -- "firejail --ls=test ~/.\r"
23expect {
24 timeout {puts "TESTING ERROR 1\n";exit}
25 "lstesting"
26}
27sleep 1
28
29# get
30send -- "firejail --get=test ~/lstesting\r"
31sleep 1
32send -- "cat lstesting\r"
33expect {
34 timeout {puts "TESTING ERROR 2n";exit}
35 "my_testing"
36}
37after 100
38
39# put
40send -- "echo put_test > ~/lstesting\r"
41after 100
42send -- "firejail --put=test ~/lstesting ~/lstesting_2\r"
43sleep 1
44
45set spawn_id $firstspawn
46send -- "ls -al ~\r"
47expect {
48 timeout {puts "TESTING ERROR 3\n";exit}
49 "lstesting_2"
50}
51
52after 100
53send -- "cat ~/lstesting_2\r"
54expect {
55 timeout {puts "TESTING ERROR 4\n";exit}
56 "put_test"
57}
58after 100
59send -- "exit\r"
60sleep 1
61
62
63
64
65
66send -- "rm -f lstesting\r"
67
68after 100
69puts "\nall done\n"
diff --git a/test/utils/man.exp b/test/utils/man.exp
new file mode 100755
index 000000000..d29f760b0
--- /dev/null
+++ b/test/utils/man.exp
@@ -0,0 +1,20 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "man firejail\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Linux namespaces sandbox program"
14}
15after 100
16
17send -- "q\r"
18after 100
19puts "\n"
20
diff --git a/test/utils/name.profile b/test/utils/name.profile
new file mode 100644
index 000000000..1aa9f2d64
--- /dev/null
+++ b/test/utils/name.profile
@@ -0,0 +1 @@
name jointesting
diff --git a/test/utils/protocol-print.exp b/test/utils/protocol-print.exp
new file mode 100755
index 000000000..b4b94ea93
--- /dev/null
+++ b/test/utils/protocol-print.exp
@@ -0,0 +1,24 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --protocol.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "unix,inet,inet6"
22}
23after 100
24puts "\nall done\n"
diff --git a/test/utils/seccomp-print.exp b/test/utils/seccomp-print.exp
new file mode 100755
index 000000000..f6ff1e721
--- /dev/null
+++ b/test/utils/seccomp-print.exp
@@ -0,0 +1,36 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 2
16
17spawn $env(SHELL)
18send -- "firejail --seccomp.print=test\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "EXAMINE_SYSCAL"
22}
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "init_module"
26}
27expect {
28 timeout {puts "TESTING ERROR 3\n";exit}
29 "delete_module"
30}
31expect {
32 timeout {puts "TESTING ERROR 4\n";exit}
33 "RETURN_ALLOW"
34}
35after 100
36puts "\nall done\n"
diff --git a/test/utils/shutdown.exp b/test/utils/shutdown.exp
new file mode 100755
index 000000000..15a9a62c8
--- /dev/null
+++ b/test/utils/shutdown.exp
@@ -0,0 +1,35 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7cd /home
8spawn $env(SHELL)
9match_max 100000
10
11send -- "firejail --name=shutdowntesting\r"
12expect {
13 timeout {puts "TESTING ERROR 0\n";exit}
14 "Child process initialized"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --shutdown=shutdowntesting; echo done\r"
20expect {
21 timeout {puts "TESTING ERROR 4\n";exit}
22 "done"
23}
24sleep 5
25
26spawn $env(SHELL)
27send -- "firejail --list;echo done\r"
28expect {
29 timeout {puts "TESTING ERROR 5\n";exit}
30 "shutdowntesting" {puts "TESTING ERROR 6\n";exit}
31 "done"
32}
33sleep 1
34
35puts "\nall done\n"
diff --git a/test/utils/shutdown2.exp b/test/utils/shutdown2.exp
new file mode 100755
index 000000000..777a73ec9
--- /dev/null
+++ b/test/utils/shutdown2.exp
@@ -0,0 +1,45 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10set firstspawn $spawn_id
11
12send -- "firejail --name=shutdowntesting ./catchsignal.sh\r"
13expect {
14 timeout {puts "TESTING ERROR 0\n";exit}
15 "Child process initialized"
16}
17sleep 2
18
19spawn $env(SHELL)
20send -- "firejail --shutdown=shutdowntesting\r"
21
22set spawn_id $firstspawn
23expect {
24 timeout {puts "TESTING ERROR 1\n";exit}
25 "1"
26}
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "2"
30}
31expect {
32 timeout {puts "TESTING ERROR 3\n";exit}
33 "3"
34}
35expect {
36 timeout {puts "TESTING ERROR 4\n";exit}
37 "4"
38}
39expect {
40 timeout {puts "TESTING ERROR 5\n";exit}
41 "5"
42}
43after 100
44
45puts "\nalldone\n"
diff --git a/test/utils/shutdown3.exp b/test/utils/shutdown3.exp
new file mode 100755
index 000000000..a74fb3386
--- /dev/null
+++ b/test/utils/shutdown3.exp
@@ -0,0 +1,65 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10set firstspawn $spawn_id
11
12send -- "firejail --name=shutdowntesting ./catchsignal-master.sh\r"
13expect {
14 timeout {puts "TESTING ERROR 0\n";exit}
15 "Child process initialized"
16}
17sleep 2
18
19spawn $env(SHELL)
20send -- "firejail --shutdown=shutdowntesting\r"
21
22set spawn_id $firstspawn
23expect {
24 timeout {puts "TESTING ERROR 1\n";exit}
25 "1"
26}
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "1"
30}
31expect {
32 timeout {puts "TESTING ERROR 3\n";exit}
33 "2"
34}
35expect {
36 timeout {puts "TESTING ERROR 4\n";exit}
37 "2"
38}
39expect {
40 timeout {puts "TESTING ERROR 5\n";exit}
41 "3"
42}
43expect {
44 timeout {puts "TESTING ERROR 6\n";exit}
45 "3"
46}
47expect {
48 timeout {puts "TESTING ERROR 7\n";exit}
49 "4"
50}
51expect {
52 timeout {puts "TESTING ERROR 8\n";exit}
53 "4"
54}
55expect {
56 timeout {puts "TESTING ERROR 9\n";exit}
57 "5"
58}
59expect {
60 timeout {puts "TESTING ERROR 10\n";exit}
61 "5"
62}
63after 100
64
65puts "\nalldone\n"
diff --git a/test/utils/shutdown4.exp b/test/utils/shutdown4.exp
new file mode 100755
index 000000000..2942ba3d5
--- /dev/null
+++ b/test/utils/shutdown4.exp
@@ -0,0 +1,65 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10set firstspawn $spawn_id
11
12send -- "firejail --name=shutdowntesting ./catchsignal2.sh\r"
13expect {
14 timeout {puts "TESTING ERROR 0\n";exit}
15 "Child process initialized"
16}
17sleep 2
18
19spawn $env(SHELL)
20send -- "firejail --shutdown=shutdowntesting\r"
21
22set spawn_id $firstspawn
23expect {
24 timeout {puts "TESTING ERROR 1\n";exit}
25 "1"
26}
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "2"
30}
31expect {
32 timeout {puts "TESTING ERROR 3\n";exit}
33 "3"
34}
35expect {
36 timeout {puts "TESTING ERROR 4\n";exit}
37 "4"
38}
39expect {
40 timeout {puts "TESTING ERROR 5\n";exit}
41 "5"
42}
43expect {
44 timeout {puts "TESTING ERROR 10\n";exit}
45 "10"
46}
47expect {
48 timeout {puts "TESTING ERROR 20\n";exit}
49 "20"
50}
51expect {
52 timeout {puts "TESTING ERROR 30\n";exit}
53 "30"
54}
55expect {
56 timeout {puts "TESTING ERROR 40\n";exit}
57 "40"
58}
59expect {
60 timeout {puts "TESTING ERROR 50\n";exit}
61 "50"
62}
63after 100
64
65puts "\nalldone\n"
diff --git a/test/utils/top.exp b/test/utils/top.exp
new file mode 100755
index 000000000..d530e5a85
--- /dev/null
+++ b/test/utils/top.exp
@@ -0,0 +1,40 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --name=test1\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15sleep 1
16
17spawn $env(SHELL)
18send -- "firejail --name=test2\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23sleep 1
24
25spawn $env(SHELL)
26send -- "firejail --top\r"
27sleep 4
28expect {
29 timeout {puts "TESTING ERROR 2\n";exit}
30 "name=test1"
31}
32expect {
33 timeout {puts "TESTING ERROR 2\n";exit}
34 "name=test2"
35}
36
37after 100
38
39puts "\nall done\n"
40
diff --git a/test/utils/trace.exp b/test/utils/trace.exp
new file mode 100755
index 000000000..78a04b273
--- /dev/null
+++ b/test/utils/trace.exp
@@ -0,0 +1,115 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 30
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --trace mkdir ttt\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15expect {
16 timeout {puts "TESTING ERROR 1\n";exit}
17 "mkdir:mkdir ttt"
18}
19sleep 1
20
21send -- "firejail --trace rmdir ttt\r"
22expect {
23 timeout {puts "TESTING ERROR 2\n";exit}
24 "Child process initialized"
25}
26expect {
27 timeout {puts "TESTING ERROR 3\n";exit}
28 "rmdir:rmdir ttt"
29}
30sleep 1
31
32send -- "firejail --trace touch ttt\r"
33expect {
34 timeout {puts "TESTING ERROR 4\n";exit}
35 "Child process initialized"
36}
37expect {
38 timeout {puts "TESTING ERROR 5\n";exit}
39 "touch:open ttt" {puts "OK\n";}
40 "touch:open64 ttt" {puts "OK\n";}
41}
42sleep 1
43
44send -- "firejail --trace rm ttt\r"
45expect {
46 timeout {puts "TESTING ERROR 6\n";exit}
47 "Child process initialized"
48}
49expect {
50 timeout {puts "TESTING ERROR 7\n";exit}
51 "rm:unlinkat ttt"
52}
53sleep 1
54
55send -- "firejail --trace wget -q debian.org\r"
56expect {
57 timeout {puts "TESTING ERROR 8.1\n";exit}
58 "Child process initialized"
59}
60expect {
61 timeout {puts "TESTING ERROR 8.2\n";exit}
62 "bash:open /dev/tty" {puts "OK\n";}
63 "bash:open64 /dev/tty" {puts "OK\n";}
64}
65expect {
66 timeout {puts "TESTING ERROR 8.3\n";exit}
67 "wget:fopen64 /etc/wgetrc" {puts "OK\n";}
68 "wget:fopen /etc/wgetrc" {puts "OK\n";}
69}
70expect {
71 timeout {puts "TESTING ERROR 8.4\n";exit}
72 "wget:fopen /etc/hosts"
73}
74expect {
75 timeout {puts "TESTING ERROR 8.5\n";exit}
76 "wget:connect"
77}
78expect {
79 timeout {puts "TESTING ERROR 8.6\n";exit}
80 "wget:fopen64 index.html" {puts "OK\n";}
81 "wget:fopen index.html" {puts "OK\n";}
82 "Parent is shutting down" {puts "OK\n";}
83}
84sleep 1
85
86send -- "firejail --trace rm index.html\r"
87expect {
88 timeout {puts "TESTING ERROR 9\n";exit}
89 "Child process initialized"
90}
91expect {
92 timeout {puts "TESTING ERROR 10\n";exit}
93 "rm:unlinkat index.html" {puts "OK\n";}
94 "Parent is shutting down" {puts "OK\n";}
95}
96sleep 1
97
98send -- "firejail --trace\r"
99expect {
100 timeout {puts "TESTING ERROR 11\n";exit}
101 "Child process initialized"
102}
103expect {
104 timeout {puts "TESTING ERROR 12\n";exit}
105 "bash:open /dev/tty" {puts "64bit\n"}
106 "bash:open64 /dev/tty" {puts "32bit\n"}
107}
108expect {
109 timeout {puts "TESTING ERROR 13\n";exit}
110 "bash:access /etc/terminfo/" {puts "debian\n"}
111 "bash:access /usr/share/terminfo/" {puts "arch\n"}
112}
113after 100
114
115puts "\nall done\n"
diff --git a/test/utils/tree.exp b/test/utils/tree.exp
new file mode 100755
index 000000000..a8ef763f1
--- /dev/null
+++ b/test/utils/tree.exp
@@ -0,0 +1,63 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Child process initialized"
14}
15after 100
16
17spawn $env(SHELL)
18send -- "firejail\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23after 100
24
25spawn $env(SHELL)
26send -- "firejail\r"
27expect {
28 timeout {puts "TESTING ERROR 2\n";exit}
29 "Child process initialized"
30}
31sleep 1
32
33spawn $env(SHELL)
34send -- "firejail --tree\r"
35expect {
36 timeout {puts "TESTING ERROR 3\n";exit}
37 ":firejail"
38}
39expect {
40 timeout {puts "TESTING ERROR 3.1\n";exit}
41 ":/bin/bash"
42}
43expect {
44 timeout {puts "TESTING ERROR 4\n";exit}
45 ":firejail"
46}
47expect {
48 timeout {puts "TESTING ERROR 4.1\n";exit}
49 ":/bin/bash"
50}
51expect {
52 timeout {puts "TESTING ERROR 5\n";exit}
53 ":firejail"
54}
55expect {
56 timeout {puts "TESTING ERROR 5.1\n";exit}
57 ":/bin/bash"
58}
59after 100
60
61
62puts "\n"
63
diff --git a/test/utils/utils.sh b/test/utils/utils.sh
new file mode 100755
index 000000000..bd91110f7
--- /dev/null
+++ b/test/utils/utils.sh
@@ -0,0 +1,102 @@
1#!/bin/bash
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8
9echo "TESTING: version (test/utils/version.exp)"
10./version.exp
11
12echo "TESTING: help (test/utils/help.exp)"
13./help.exp
14
15which man
16if [ "$?" -eq 0 ];
17then
18 echo "TESTING: man (test/utils/man.exp)"
19 ./man.exp
20else
21 echo "TESTING SKIP: man not found"
22fi
23
24echo "TESTING: list (test/utils/list.exp)"
25./list.exp
26
27echo "TESTING: tree (test/utils/tree.exp)"
28./tree.exp
29
30if [ $(grep -c ^processor /proc/cpuinfo) -gt 1 ];
31then
32 echo "TESTING: cpu.print (test/utils/cpu-print.exp)"
33 ./cpu-print.exp
34else
35 echo "TESTING SKIP: cpu.print, not enough CPUs"
36fi
37
38echo "TESTING: fs.print (test/utils/fs-print.exp)"
39./fs-print.exp
40
41echo "TESTING: dns.print (test/utils/dns-print.exp)"
42./dns-print.exp
43
44echo "TESTING: caps.print (test/utils/caps-print.exp)"
45./caps-print.exp
46
47echo "TESTING: seccomp.print (test/utils/seccomp-print.exp)"
48./seccomp-print.exp
49
50echo "TESTING: protocol.print (test/utils/protocol-print.exp)"
51./protocol-print.exp
52
53echo "TESTING: shutdown (test/utils/shutdown.exp)"
54./shutdown.exp
55
56echo "TESTING: shutdown2 (test/utils/shutdown2.exp)"
57./shutdown2.exp
58
59echo "TESTING: shutdown3 (test/utils/shutdown3.exp)"
60./shutdown3.exp
61
62echo "TESTING: shutdown4 (test/utils/shutdown4.exp)"
63./shutdown4.exp
64
65echo "TESTING: join (test/utils/join.exp)"
66./join.exp
67
68echo "TESTING: join2 (test/utils/join2.exp)"
69./join2.exp
70
71echo "TESTING: join3 (test/utils/join3.exp)"
72./join3.exp
73
74echo "TESTING: join3 (test/utils/join4.exp)"
75./join4.exp
76
77echo "TESTING: join profile (test/utils/join-profile.exp)"
78./join-profile.exp
79
80echo "TESTING: trace (test/utils/trace.exp)"
81rm -f index.html*
82./trace.exp
83rm -f index.html*
84
85echo "TESTING: top (test/utils/top.exp)"
86./top.exp
87
88echo "TESTING: file transfer (test/utils/ls.exp)"
89./ls.exp
90
91echo "TESTING: firemon seccomp (test/utils/firemon-seccomp.exp)"
92./firemon-seccomp.exp
93
94echo "TESTING: firemon caps (test/utils/firemon-caps.exp)"
95./firemon-caps.exp
96
97echo "TESTING: firemon cpu (test/utils/firemon-cpu.exp)"
98./firemon-cpu.exp
99
100echo "TESTING: firemon cgroup (test/utils/firemon-cgroup.exp)"
101./firemon-cgroup.exp
102
diff --git a/test/utils/version.exp b/test/utils/version.exp
new file mode 100755
index 000000000..2ce6f1680
--- /dev/null
+++ b/test/utils/version.exp
@@ -0,0 +1,18 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --version\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "firejail version "
14}
15after 100
16
17puts "\n"
18