summaryrefslogtreecommitdiffstats
path: root/test/arguments
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-07-25 12:29:00 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-07-25 12:29:00 -0400
commit23bd0c41457262e7ef5223a187e3c15e44be039c (patch)
treecfecd32023600b289099aca58fab53f0f3fcdb48 /test/arguments
parentMerge pull request #646 from reinerh/master (diff)
downloadfirejail-23bd0c41457262e7ef5223a187e3c15e44be039c.tar.gz
firejail-23bd0c41457262e7ef5223a187e3c15e44be039c.tar.zst
firejail-23bd0c41457262e7ef5223a187e3c15e44be039c.zip
argument subsystem testing framework
Diffstat (limited to 'test/arguments')
-rwxr-xr-xtest/arguments/arguments.sh17
-rwxr-xr-xtest/arguments/bashrun.exp86
-rwxr-xr-xtest/arguments/bashrun.sh22
-rwxr-xr-xtest/arguments/joinrun.exp91
-rwxr-xr-xtest/arguments/joinrun.sh22
-rw-r--r--test/arguments/main.c31
-rwxr-xr-xtest/arguments/outrun.exp90
-rwxr-xr-xtest/arguments/outrun.sh22
-rw-r--r--test/arguments/readme9
-rwxr-xr-xtest/arguments/symrun.exp71
-rwxr-xr-xtest/arguments/symrun.sh27
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
3echo "TESTING: 1. regular bash session"
4./bashrun.exp
5
6echo "TESTING: 2. symbolic link to firejail"
7./symrun.exp
8
9echo "TESTING: 3. --join option"
10./joinrun.exp
11
12echo "TESTING: 4. --output option"
13./outrun.exp
14rm out
15rm 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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "./bashrun.sh\r"
8expect {
9 timeout {puts "TESTING ERROR 1.1.1\n";exit}
10 "Arguments:"
11}
12expect {
13 timeout {puts "TESTING ERROR 1.1.2\n";exit}
14 "#arg1#"
15}
16expect {
17 timeout {puts "TESTING ERROR 1.1.3\n";exit}
18 "#arg2#"
19}
20
21expect {
22 timeout {puts "TESTING ERROR 1.2.1\n";exit}
23 "Arguments:"
24}
25expect {
26 timeout {puts "TESTING ERROR 1.2.2\n";exit}
27 "#arg1 tail#"
28}
29expect {
30 timeout {puts "TESTING ERROR 1.2.3\n";exit}
31 "#arg2 tail#"
32}
33
34expect {
35 timeout {puts "TESTING ERROR 1.3.1\n";exit}
36 "Arguments:"
37}
38expect {
39 timeout {puts "TESTING ERROR 1.3.2\n";exit}
40 "#arg1 tail#"
41}
42expect {
43 timeout {puts "TESTING ERROR 1.3.3\n";exit}
44 "#arg2 tail#"
45}
46
47expect {
48 timeout {puts "TESTING ERROR 1.4.1\n";exit}
49 "Arguments:"
50}
51expect {
52 timeout {puts "TESTING ERROR 1.4.2\n";exit}
53 "#arg1 tail#"
54}
55expect {
56 timeout {puts "TESTING ERROR 1.4.3\n";exit}
57 "#arg2 tail#"
58}
59
60expect {
61 timeout {puts "TESTING ERROR 1.5.1\n";exit}
62 "Arguments:"
63}
64expect {
65 timeout {puts "TESTING ERROR 1.5.2\n";exit}
66 "#arg1&tail#"
67}
68expect {
69 timeout {puts "TESTING ERROR 1.5.3\n";exit}
70 "#arg2&tail#"
71}
72
73expect {
74 timeout {puts "TESTING ERROR 1.6.1\n";exit}
75 "Arguments:"
76}
77expect {
78 timeout {puts "TESTING ERROR 1.6.2\n";exit}
79 "#arg1&tail#"
80}
81expect {
82 timeout {puts "TESTING ERROR 1.6.3\n";exit}
83 "#arg2&tail#"
84}
85
86puts "\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
3echo "TESTING: 1.1 - simple args"
4firejail --quiet ./argtest arg1 arg2
5
6# simple quotes, testing spaces in file names
7echo "TESTING: 1.2 - args with space and \""
8firejail --quiet ./argtest "arg1 tail" "arg2 tail"
9
10echo "TESTING: 1.3 - args with space and '"
11firejail --quiet ./argtest 'arg1 tail' 'arg2 tail'
12
13# escaped space in file names
14echo "TESTING: 1.4 - args with space and \\"
15firejail --quiet ./argtest arg1\ tail arg2\ tail
16
17# & char appears in URLs - URLs should be quoted
18echo "TESTING: 1.5 - args with & and \""
19firejail --quiet ./argtest "arg1&tail" "arg2&tail"
20
21echo "TESTING: 1.6 - args with & and '"
22firejail --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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7
8send -- "firejail --name=joinrun\r"
9sleep 2
10
11spawn $env(SHELL)
12send -- "./joinrun.sh\r"
13expect {
14 timeout {puts "TESTING ERROR 3.1.1\n";exit}
15 "Arguments:"
16}
17expect {
18 timeout {puts "TESTING ERROR 3.1.2\n";exit}
19 "#arg1#"
20}
21expect {
22 timeout {puts "TESTING ERROR 3.1.3\n";exit}
23 "#arg2#"
24}
25
26expect {
27 timeout {puts "TESTING ERROR 3.2.1\n";exit}
28 "Arguments:"
29}
30expect {
31 timeout {puts "TESTING ERROR 3.2.2\n";exit}
32 "#arg1 tail#"
33}
34expect {
35 timeout {puts "TESTING ERROR 3.2.3\n";exit}
36 "#arg2 tail#"
37}
38
39expect {
40 timeout {puts "TESTING ERROR 3.3.1\n";exit}
41 "Arguments:"
42}
43expect {
44 timeout {puts "TESTING ERROR 3.3.2\n";exit}
45 "#arg1 tail#"
46}
47expect {
48 timeout {puts "TESTING ERROR 3.3.3\n";exit}
49 "#arg2 tail#"
50}
51
52expect {
53 timeout {puts "TESTING ERROR 3.4.1\n";exit}
54 "Arguments:"
55}
56expect {
57 timeout {puts "TESTING ERROR 3.4.2\n";exit}
58 "#arg1 tail#"
59}
60expect {
61 timeout {puts "TESTING ERROR 3.4.3\n";exit}
62 "#arg2 tail#"
63}
64
65expect {
66 timeout {puts "TESTING ERROR 3.5.1\n";exit}
67 "Arguments:"
68}
69expect {
70 timeout {puts "TESTING ERROR 3.5.2\n";exit}
71 "#arg1&tail#"
72}
73expect {
74 timeout {puts "TESTING ERROR 3.5.3\n";exit}
75 "#arg2&tail#"
76}
77
78expect {
79 timeout {puts "TESTING ERROR 3.6.1\n";exit}
80 "Arguments:"
81}
82expect {
83 timeout {puts "TESTING ERROR 3.6.2\n";exit}
84 "#arg1&tail#"
85}
86expect {
87 timeout {puts "TESTING ERROR 3.6.3\n";exit}
88 "#arg2&tail#"
89}
90
91puts "\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
3echo "TESTING: 3.1 - simple args"
4firejail --join=joinrun ./argtest arg1 arg2
5
6# simple quotes, testing spaces in file names
7echo "TESTING: 3.2 - args with space and \""
8firejail --quiet ./argtest "arg1 tail" "arg2 tail"
9
10echo "TESTING: 3.3 - args with space and '"
11firejail --quiet ./argtest 'arg1 tail' 'arg2 tail'
12
13# escaped space in file names
14echo "TESTING: 3.4 - args with space and \\"
15firejail --quiet ./argtest arg1\ tail arg2\ tail
16
17# & char appears in URLs - URLs should be quoted
18echo "TESTING: 3.5 - args with & and \""
19firejail --quiet ./argtest "arg1&tail" "arg2&tail"
20
21echo "TESTING: 3.6 - args with & and '"
22firejail --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
22int 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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "./outrun.sh\r"
8expect {
9 timeout {puts "TESTING ERROR 4.1.1\n";exit}
10 "Arguments:"
11}
12expect {
13 timeout {puts "TESTING ERROR 4.1.2\n";exit}
14 "#arg1#"
15}
16expect {
17 timeout {puts "TESTING ERROR 4.1.3\n";exit}
18 "#arg2#"
19}
20
21exit
22#***************************************************
23# breaking down from here on - bug to fix
24#***************************************************
25expect {
26 timeout {puts "TESTING ERROR 4.2.1\n";exit}
27 "Arguments:"
28}
29expect {
30 timeout {puts "TESTING ERROR 4.2.2\n";exit}
31 "#arg1 tail#"
32}
33expect {
34 timeout {puts "TESTING ERROR 4.2.3\n";exit}
35 "#arg2 tail#"
36}
37
38expect {
39 timeout {puts "TESTING ERROR 4.3.1\n";exit}
40 "Arguments:"
41}
42expect {
43 timeout {puts "TESTING ERROR 4.3.2\n";exit}
44 "#arg1 tail#"
45}
46expect {
47 timeout {puts "TESTING ERROR 4.3.3\n";exit}
48 "#arg2 tail#"
49}
50
51expect {
52 timeout {puts "TESTING ERROR 4.4.1\n";exit}
53 "Arguments:"
54}
55expect {
56 timeout {puts "TESTING ERROR 4.4.2\n";exit}
57 "#arg1 tail#"
58}
59expect {
60 timeout {puts "TESTING ERROR 4.4.3\n";exit}
61 "#arg2 tail#"
62}
63
64expect {
65 timeout {puts "TESTING ERROR 4.5.1\n";exit}
66 "Arguments:"
67}
68expect {
69 timeout {puts "TESTING ERROR 4.5.2\n";exit}
70 "#arg1&tail#"
71}
72expect {
73 timeout {puts "TESTING ERROR 4.5.3\n";exit}
74 "#arg2&tail#"
75}
76
77expect {
78 timeout {puts "TESTING ERROR 4.6.1\n";exit}
79 "Arguments:"
80}
81expect {
82 timeout {puts "TESTING ERROR 4.6.2\n";exit}
83 "#arg1&tail#"
84}
85expect {
86 timeout {puts "TESTING ERROR 4.6.3\n";exit}
87 "#arg2&tail#"
88}
89
90puts "\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
3echo "TESTING: 4.1 - simple args"
4firejail --output=out ./argtest arg1 arg2
5
6# simple quotes, testing spaces in file names
7echo "TESTING: 4.2 - args with space and \""
8firejail --output=out ./argtest "arg1 tail" "arg2 tail"
9
10echo "TESTING: 4.3 - args with space and '"
11firejail --output=out ./argtest 'arg1 tail' 'arg2 tail'
12
13# escaped space in file names
14echo "TESTING: 4.4 - args with space and \\"
15firejail --output=out ./argtest arg1\ tail arg2\ tail
16
17# & char appears in URLs - URLs should be quoted
18echo "TESTING: 4.5 - args with & and \""
19firejail --output=out ./argtest "arg1&tail" "arg2&tail"
20
21echo "TESTING: 4.6 - args with & and '"
22firejail --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 @@
1Argument testing fremework for Firejail.
2
3A small test program, argtest, is compiled and installed in /usr/local/bin directory.
4Run "make && sudo make install" to install it.
5
6Run "make test" to run the tests.
7
8Run "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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "./bashrun.sh\r"
8expect {
9 timeout {puts "TESTING ERROR 2.1.1\n";exit}
10 "Arguments:"
11}
12expect {
13 timeout {puts "TESTING ERROR 2.1.2\n";exit}
14 "#arg1#"
15}
16expect {
17 timeout {puts "TESTING ERROR 2.1.3\n";exit}
18 "#arg2#"
19}
20
21expect {
22 timeout {puts "TESTING ERROR 2.3.1\n";exit}
23 "Arguments:"
24}
25expect {
26 timeout {puts "TESTING ERROR 2.3.2\n";exit}
27 "#arg1 tail#"
28}
29expect {
30 timeout {puts "TESTING ERROR 2.3.3\n";exit}
31 "#arg2 tail#"
32}
33
34expect {
35 timeout {puts "TESTING ERROR 2.4.1\n";exit}
36 "Arguments:"
37}
38expect {
39 timeout {puts "TESTING ERROR 2.4.2\n";exit}
40 "#arg1 tail#"
41}
42expect {
43 timeout {puts "TESTING ERROR 2.4.3\n";exit}
44 "#arg2 tail#"
45}
46
47expect {
48 timeout {puts "TESTING ERROR 2.5.1\n";exit}
49 "Arguments:"
50}
51expect {
52 timeout {puts "TESTING ERROR 2.5.2\n";exit}
53 "#arg1&tail#"
54}
55expect {
56 timeout {puts "TESTING ERROR 2.5.3\n";exit}
57 "#arg2&tail#"
58}
59
60expect {
61 timeout {puts "TESTING ERROR 2.6.1\n";exit}
62 "Arguments:"
63}
64expect {
65 timeout {puts "TESTING ERROR 2.6.2\n";exit}
66 "#arg1&tail#"
67}
68expect {
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
3mkdir symtest
4ln -s /usr/bin/firejail symtest/argtest
5
6echo "TESTING: 2.1 - simple args"
7symtest/argtest arg1 arg2
8
9# simple quotes, testing spaces in file names
10echo "TESTING: 2.2 - args with space and \""
11symtest/argtest "arg1 tail" "arg2 tail"
12
13echo "TESTING: 2.3 - args with space and '"
14symtest/argtest 'arg1 tail' 'arg2 tail'
15
16# escaped space in file names
17echo "TESTING: 2.4 - args with space and \\"
18symtest/argtest arg1\ tail arg2\ tail
19
20# & char appears in URLs - URLs should be quoted
21echo "TESTING: 2.5 - args with & and \""
22symtest/argtest "arg1&tail" "arg2&tail"
23
24echo "TESTING: 2.6 - args with & and '"
25symtest/argtest 'arg1&tail' 'arg2&tail'
26
27rm -fr symtest