diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/arguments/arguments.sh | 17 | ||||
-rwxr-xr-x | test/arguments/bashrun.exp | 86 | ||||
-rwxr-xr-x | test/arguments/bashrun.sh | 22 | ||||
-rwxr-xr-x | test/arguments/joinrun.exp | 91 | ||||
-rwxr-xr-x | test/arguments/joinrun.sh | 22 | ||||
-rw-r--r-- | test/arguments/main.c | 31 | ||||
-rwxr-xr-x | test/arguments/outrun.exp | 90 | ||||
-rwxr-xr-x | test/arguments/outrun.sh | 22 | ||||
-rw-r--r-- | test/arguments/readme | 9 | ||||
-rwxr-xr-x | test/arguments/symrun.exp | 71 | ||||
-rwxr-xr-x | test/arguments/symrun.sh | 27 |
11 files changed, 488 insertions, 0 deletions
diff --git a/test/arguments/arguments.sh b/test/arguments/arguments.sh new file mode 100755 index 000000000..a9b3f9587 --- /dev/null +++ b/test/arguments/arguments.sh | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | echo "TESTING: 1. regular bash session" | ||
4 | ./bashrun.exp | ||
5 | |||
6 | echo "TESTING: 2. symbolic link to firejail" | ||
7 | ./symrun.exp | ||
8 | |||
9 | echo "TESTING: 3. --join option" | ||
10 | ./joinrun.exp | ||
11 | |||
12 | echo "TESTING: 4. --output option" | ||
13 | ./outrun.exp | ||
14 | rm out | ||
15 | rm out.* | ||
16 | |||
17 | |||
diff --git a/test/arguments/bashrun.exp b/test/arguments/bashrun.exp new file mode 100755 index 000000000..a3c9e382d --- /dev/null +++ b/test/arguments/bashrun.exp | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "./bashrun.sh\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 1.1.1\n";exit} | ||
10 | "Arguments:" | ||
11 | } | ||
12 | expect { | ||
13 | timeout {puts "TESTING ERROR 1.1.2\n";exit} | ||
14 | "#arg1#" | ||
15 | } | ||
16 | expect { | ||
17 | timeout {puts "TESTING ERROR 1.1.3\n";exit} | ||
18 | "#arg2#" | ||
19 | } | ||
20 | |||
21 | expect { | ||
22 | timeout {puts "TESTING ERROR 1.2.1\n";exit} | ||
23 | "Arguments:" | ||
24 | } | ||
25 | expect { | ||
26 | timeout {puts "TESTING ERROR 1.2.2\n";exit} | ||
27 | "#arg1 tail#" | ||
28 | } | ||
29 | expect { | ||
30 | timeout {puts "TESTING ERROR 1.2.3\n";exit} | ||
31 | "#arg2 tail#" | ||
32 | } | ||
33 | |||
34 | expect { | ||
35 | timeout {puts "TESTING ERROR 1.3.1\n";exit} | ||
36 | "Arguments:" | ||
37 | } | ||
38 | expect { | ||
39 | timeout {puts "TESTING ERROR 1.3.2\n";exit} | ||
40 | "#arg1 tail#" | ||
41 | } | ||
42 | expect { | ||
43 | timeout {puts "TESTING ERROR 1.3.3\n";exit} | ||
44 | "#arg2 tail#" | ||
45 | } | ||
46 | |||
47 | expect { | ||
48 | timeout {puts "TESTING ERROR 1.4.1\n";exit} | ||
49 | "Arguments:" | ||
50 | } | ||
51 | expect { | ||
52 | timeout {puts "TESTING ERROR 1.4.2\n";exit} | ||
53 | "#arg1 tail#" | ||
54 | } | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 1.4.3\n";exit} | ||
57 | "#arg2 tail#" | ||
58 | } | ||
59 | |||
60 | expect { | ||
61 | timeout {puts "TESTING ERROR 1.5.1\n";exit} | ||
62 | "Arguments:" | ||
63 | } | ||
64 | expect { | ||
65 | timeout {puts "TESTING ERROR 1.5.2\n";exit} | ||
66 | "#arg1&tail#" | ||
67 | } | ||
68 | expect { | ||
69 | timeout {puts "TESTING ERROR 1.5.3\n";exit} | ||
70 | "#arg2&tail#" | ||
71 | } | ||
72 | |||
73 | expect { | ||
74 | timeout {puts "TESTING ERROR 1.6.1\n";exit} | ||
75 | "Arguments:" | ||
76 | } | ||
77 | expect { | ||
78 | timeout {puts "TESTING ERROR 1.6.2\n";exit} | ||
79 | "#arg1&tail#" | ||
80 | } | ||
81 | expect { | ||
82 | timeout {puts "TESTING ERROR 1.6.3\n";exit} | ||
83 | "#arg2&tail#" | ||
84 | } | ||
85 | |||
86 | puts "\nall done\n" | ||
diff --git a/test/arguments/bashrun.sh b/test/arguments/bashrun.sh new file mode 100755 index 000000000..c2f209548 --- /dev/null +++ b/test/arguments/bashrun.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | echo "TESTING: 1.1 - simple args" | ||
4 | firejail --quiet ./argtest arg1 arg2 | ||
5 | |||
6 | # simple quotes, testing spaces in file names | ||
7 | echo "TESTING: 1.2 - args with space and \"" | ||
8 | firejail --quiet ./argtest "arg1 tail" "arg2 tail" | ||
9 | |||
10 | echo "TESTING: 1.3 - args with space and '" | ||
11 | firejail --quiet ./argtest 'arg1 tail' 'arg2 tail' | ||
12 | |||
13 | # escaped space in file names | ||
14 | echo "TESTING: 1.4 - args with space and \\" | ||
15 | firejail --quiet ./argtest arg1\ tail arg2\ tail | ||
16 | |||
17 | # & char appears in URLs - URLs should be quoted | ||
18 | echo "TESTING: 1.5 - args with & and \"" | ||
19 | firejail --quiet ./argtest "arg1&tail" "arg2&tail" | ||
20 | |||
21 | echo "TESTING: 1.6 - args with & and '" | ||
22 | firejail --quiet ./argtest 'arg1&tail' 'arg2&tail' | ||
diff --git a/test/arguments/joinrun.exp b/test/arguments/joinrun.exp new file mode 100755 index 000000000..8e8570e4f --- /dev/null +++ b/test/arguments/joinrun.exp | |||
@@ -0,0 +1,91 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | |||
8 | send -- "firejail --name=joinrun\r" | ||
9 | sleep 2 | ||
10 | |||
11 | spawn $env(SHELL) | ||
12 | send -- "./joinrun.sh\r" | ||
13 | expect { | ||
14 | timeout {puts "TESTING ERROR 3.1.1\n";exit} | ||
15 | "Arguments:" | ||
16 | } | ||
17 | expect { | ||
18 | timeout {puts "TESTING ERROR 3.1.2\n";exit} | ||
19 | "#arg1#" | ||
20 | } | ||
21 | expect { | ||
22 | timeout {puts "TESTING ERROR 3.1.3\n";exit} | ||
23 | "#arg2#" | ||
24 | } | ||
25 | |||
26 | expect { | ||
27 | timeout {puts "TESTING ERROR 3.2.1\n";exit} | ||
28 | "Arguments:" | ||
29 | } | ||
30 | expect { | ||
31 | timeout {puts "TESTING ERROR 3.2.2\n";exit} | ||
32 | "#arg1 tail#" | ||
33 | } | ||
34 | expect { | ||
35 | timeout {puts "TESTING ERROR 3.2.3\n";exit} | ||
36 | "#arg2 tail#" | ||
37 | } | ||
38 | |||
39 | expect { | ||
40 | timeout {puts "TESTING ERROR 3.3.1\n";exit} | ||
41 | "Arguments:" | ||
42 | } | ||
43 | expect { | ||
44 | timeout {puts "TESTING ERROR 3.3.2\n";exit} | ||
45 | "#arg1 tail#" | ||
46 | } | ||
47 | expect { | ||
48 | timeout {puts "TESTING ERROR 3.3.3\n";exit} | ||
49 | "#arg2 tail#" | ||
50 | } | ||
51 | |||
52 | expect { | ||
53 | timeout {puts "TESTING ERROR 3.4.1\n";exit} | ||
54 | "Arguments:" | ||
55 | } | ||
56 | expect { | ||
57 | timeout {puts "TESTING ERROR 3.4.2\n";exit} | ||
58 | "#arg1 tail#" | ||
59 | } | ||
60 | expect { | ||
61 | timeout {puts "TESTING ERROR 3.4.3\n";exit} | ||
62 | "#arg2 tail#" | ||
63 | } | ||
64 | |||
65 | expect { | ||
66 | timeout {puts "TESTING ERROR 3.5.1\n";exit} | ||
67 | "Arguments:" | ||
68 | } | ||
69 | expect { | ||
70 | timeout {puts "TESTING ERROR 3.5.2\n";exit} | ||
71 | "#arg1&tail#" | ||
72 | } | ||
73 | expect { | ||
74 | timeout {puts "TESTING ERROR 3.5.3\n";exit} | ||
75 | "#arg2&tail#" | ||
76 | } | ||
77 | |||
78 | expect { | ||
79 | timeout {puts "TESTING ERROR 3.6.1\n";exit} | ||
80 | "Arguments:" | ||
81 | } | ||
82 | expect { | ||
83 | timeout {puts "TESTING ERROR 3.6.2\n";exit} | ||
84 | "#arg1&tail#" | ||
85 | } | ||
86 | expect { | ||
87 | timeout {puts "TESTING ERROR 3.6.3\n";exit} | ||
88 | "#arg2&tail#" | ||
89 | } | ||
90 | |||
91 | puts "\nall done\n" | ||
diff --git a/test/arguments/joinrun.sh b/test/arguments/joinrun.sh new file mode 100755 index 000000000..f6c2b2e22 --- /dev/null +++ b/test/arguments/joinrun.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | echo "TESTING: 3.1 - simple args" | ||
4 | firejail --join=joinrun ./argtest arg1 arg2 | ||
5 | |||
6 | # simple quotes, testing spaces in file names | ||
7 | echo "TESTING: 3.2 - args with space and \"" | ||
8 | firejail --quiet ./argtest "arg1 tail" "arg2 tail" | ||
9 | |||
10 | echo "TESTING: 3.3 - args with space and '" | ||
11 | firejail --quiet ./argtest 'arg1 tail' 'arg2 tail' | ||
12 | |||
13 | # escaped space in file names | ||
14 | echo "TESTING: 3.4 - args with space and \\" | ||
15 | firejail --quiet ./argtest arg1\ tail arg2\ tail | ||
16 | |||
17 | # & char appears in URLs - URLs should be quoted | ||
18 | echo "TESTING: 3.5 - args with & and \"" | ||
19 | firejail --quiet ./argtest "arg1&tail" "arg2&tail" | ||
20 | |||
21 | echo "TESTING: 3.6 - args with & and '" | ||
22 | firejail --quiet ./argtest 'arg1&tail' 'arg2&tail' | ||
diff --git a/test/arguments/main.c b/test/arguments/main.c new file mode 100644 index 000000000..75bdca715 --- /dev/null +++ b/test/arguments/main.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2016 Firejail Authors | ||
3 | * | ||
4 | * This file is part of firejail project | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | #include <stdio.h> | ||
21 | |||
22 | int main(int argc, char **argv) { | ||
23 | printf("Arguments:\n"); | ||
24 | |||
25 | int i; | ||
26 | for (i = 0; i < argc; i++) { | ||
27 | printf("#%s#\n", argv[i]); | ||
28 | } | ||
29 | |||
30 | return 0; | ||
31 | } | ||
diff --git a/test/arguments/outrun.exp b/test/arguments/outrun.exp new file mode 100755 index 000000000..d28e75661 --- /dev/null +++ b/test/arguments/outrun.exp | |||
@@ -0,0 +1,90 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "./outrun.sh\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 4.1.1\n";exit} | ||
10 | "Arguments:" | ||
11 | } | ||
12 | expect { | ||
13 | timeout {puts "TESTING ERROR 4.1.2\n";exit} | ||
14 | "#arg1#" | ||
15 | } | ||
16 | expect { | ||
17 | timeout {puts "TESTING ERROR 4.1.3\n";exit} | ||
18 | "#arg2#" | ||
19 | } | ||
20 | |||
21 | exit | ||
22 | #*************************************************** | ||
23 | # breaking down from here on - bug to fix | ||
24 | #*************************************************** | ||
25 | expect { | ||
26 | timeout {puts "TESTING ERROR 4.2.1\n";exit} | ||
27 | "Arguments:" | ||
28 | } | ||
29 | expect { | ||
30 | timeout {puts "TESTING ERROR 4.2.2\n";exit} | ||
31 | "#arg1 tail#" | ||
32 | } | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 4.2.3\n";exit} | ||
35 | "#arg2 tail#" | ||
36 | } | ||
37 | |||
38 | expect { | ||
39 | timeout {puts "TESTING ERROR 4.3.1\n";exit} | ||
40 | "Arguments:" | ||
41 | } | ||
42 | expect { | ||
43 | timeout {puts "TESTING ERROR 4.3.2\n";exit} | ||
44 | "#arg1 tail#" | ||
45 | } | ||
46 | expect { | ||
47 | timeout {puts "TESTING ERROR 4.3.3\n";exit} | ||
48 | "#arg2 tail#" | ||
49 | } | ||
50 | |||
51 | expect { | ||
52 | timeout {puts "TESTING ERROR 4.4.1\n";exit} | ||
53 | "Arguments:" | ||
54 | } | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 4.4.2\n";exit} | ||
57 | "#arg1 tail#" | ||
58 | } | ||
59 | expect { | ||
60 | timeout {puts "TESTING ERROR 4.4.3\n";exit} | ||
61 | "#arg2 tail#" | ||
62 | } | ||
63 | |||
64 | expect { | ||
65 | timeout {puts "TESTING ERROR 4.5.1\n";exit} | ||
66 | "Arguments:" | ||
67 | } | ||
68 | expect { | ||
69 | timeout {puts "TESTING ERROR 4.5.2\n";exit} | ||
70 | "#arg1&tail#" | ||
71 | } | ||
72 | expect { | ||
73 | timeout {puts "TESTING ERROR 4.5.3\n";exit} | ||
74 | "#arg2&tail#" | ||
75 | } | ||
76 | |||
77 | expect { | ||
78 | timeout {puts "TESTING ERROR 4.6.1\n";exit} | ||
79 | "Arguments:" | ||
80 | } | ||
81 | expect { | ||
82 | timeout {puts "TESTING ERROR 4.6.2\n";exit} | ||
83 | "#arg1&tail#" | ||
84 | } | ||
85 | expect { | ||
86 | timeout {puts "TESTING ERROR 4.6.3\n";exit} | ||
87 | "#arg2&tail#" | ||
88 | } | ||
89 | |||
90 | puts "\nall done\n" | ||
diff --git a/test/arguments/outrun.sh b/test/arguments/outrun.sh new file mode 100755 index 000000000..cfd8e684c --- /dev/null +++ b/test/arguments/outrun.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | echo "TESTING: 4.1 - simple args" | ||
4 | firejail --output=out ./argtest arg1 arg2 | ||
5 | |||
6 | # simple quotes, testing spaces in file names | ||
7 | echo "TESTING: 4.2 - args with space and \"" | ||
8 | firejail --output=out ./argtest "arg1 tail" "arg2 tail" | ||
9 | |||
10 | echo "TESTING: 4.3 - args with space and '" | ||
11 | firejail --output=out ./argtest 'arg1 tail' 'arg2 tail' | ||
12 | |||
13 | # escaped space in file names | ||
14 | echo "TESTING: 4.4 - args with space and \\" | ||
15 | firejail --output=out ./argtest arg1\ tail arg2\ tail | ||
16 | |||
17 | # & char appears in URLs - URLs should be quoted | ||
18 | echo "TESTING: 4.5 - args with & and \"" | ||
19 | firejail --output=out ./argtest "arg1&tail" "arg2&tail" | ||
20 | |||
21 | echo "TESTING: 4.6 - args with & and '" | ||
22 | firejail --output=out ./argtest 'arg1&tail' 'arg2&tail' | ||
diff --git a/test/arguments/readme b/test/arguments/readme new file mode 100644 index 000000000..f5844848e --- /dev/null +++ b/test/arguments/readme | |||
@@ -0,0 +1,9 @@ | |||
1 | Argument testing fremework for Firejail. | ||
2 | |||
3 | A small test program, argtest, is compiled and installed in /usr/local/bin directory. | ||
4 | Run "make && sudo make install" to install it. | ||
5 | |||
6 | Run "make test" to run the tests. | ||
7 | |||
8 | Run "make uninstall" to remove the test program. | ||
9 | |||
diff --git a/test/arguments/symrun.exp b/test/arguments/symrun.exp new file mode 100755 index 000000000..1466b791e --- /dev/null +++ b/test/arguments/symrun.exp | |||
@@ -0,0 +1,71 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "./bashrun.sh\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 2.1.1\n";exit} | ||
10 | "Arguments:" | ||
11 | } | ||
12 | expect { | ||
13 | timeout {puts "TESTING ERROR 2.1.2\n";exit} | ||
14 | "#arg1#" | ||
15 | } | ||
16 | expect { | ||
17 | timeout {puts "TESTING ERROR 2.1.3\n";exit} | ||
18 | "#arg2#" | ||
19 | } | ||
20 | |||
21 | expect { | ||
22 | timeout {puts "TESTING ERROR 2.3.1\n";exit} | ||
23 | "Arguments:" | ||
24 | } | ||
25 | expect { | ||
26 | timeout {puts "TESTING ERROR 2.3.2\n";exit} | ||
27 | "#arg1 tail#" | ||
28 | } | ||
29 | expect { | ||
30 | timeout {puts "TESTING ERROR 2.3.3\n";exit} | ||
31 | "#arg2 tail#" | ||
32 | } | ||
33 | |||
34 | expect { | ||
35 | timeout {puts "TESTING ERROR 2.4.1\n";exit} | ||
36 | "Arguments:" | ||
37 | } | ||
38 | expect { | ||
39 | timeout {puts "TESTING ERROR 2.4.2\n";exit} | ||
40 | "#arg1 tail#" | ||
41 | } | ||
42 | expect { | ||
43 | timeout {puts "TESTING ERROR 2.4.3\n";exit} | ||
44 | "#arg2 tail#" | ||
45 | } | ||
46 | |||
47 | expect { | ||
48 | timeout {puts "TESTING ERROR 2.5.1\n";exit} | ||
49 | "Arguments:" | ||
50 | } | ||
51 | expect { | ||
52 | timeout {puts "TESTING ERROR 2.5.2\n";exit} | ||
53 | "#arg1&tail#" | ||
54 | } | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 2.5.3\n";exit} | ||
57 | "#arg2&tail#" | ||
58 | } | ||
59 | |||
60 | expect { | ||
61 | timeout {puts "TESTING ERROR 2.6.1\n";exit} | ||
62 | "Arguments:" | ||
63 | } | ||
64 | expect { | ||
65 | timeout {puts "TESTING ERROR 2.6.2\n";exit} | ||
66 | "#arg1&tail#" | ||
67 | } | ||
68 | expect { | ||
69 | timeout {puts "TESTING ERROR 2.6.3\n";exit} | ||
70 | "#arg2&tail#" | ||
71 | } | ||
diff --git a/test/arguments/symrun.sh b/test/arguments/symrun.sh new file mode 100755 index 000000000..b46803ae2 --- /dev/null +++ b/test/arguments/symrun.sh | |||
@@ -0,0 +1,27 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | mkdir symtest | ||
4 | ln -s /usr/bin/firejail symtest/argtest | ||
5 | |||
6 | echo "TESTING: 2.1 - simple args" | ||
7 | symtest/argtest arg1 arg2 | ||
8 | |||
9 | # simple quotes, testing spaces in file names | ||
10 | echo "TESTING: 2.2 - args with space and \"" | ||
11 | symtest/argtest "arg1 tail" "arg2 tail" | ||
12 | |||
13 | echo "TESTING: 2.3 - args with space and '" | ||
14 | symtest/argtest 'arg1 tail' 'arg2 tail' | ||
15 | |||
16 | # escaped space in file names | ||
17 | echo "TESTING: 2.4 - args with space and \\" | ||
18 | symtest/argtest arg1\ tail arg2\ tail | ||
19 | |||
20 | # & char appears in URLs - URLs should be quoted | ||
21 | echo "TESTING: 2.5 - args with & and \"" | ||
22 | symtest/argtest "arg1&tail" "arg2&tail" | ||
23 | |||
24 | echo "TESTING: 2.6 - args with & and '" | ||
25 | symtest/argtest 'arg1&tail' 'arg2&tail' | ||
26 | |||
27 | rm -fr symtest | ||