From e7fbd682f8ab04f3f505c1bcfa165295739e06dc Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Mar 2017 09:39:24 -0400 Subject: testing --- test/fs/mkdir.exp | 7 ++++++ test/fs/mkdir2.profile | 1 + test/fs/mkdir_mkfile.exp | 9 +++++++ test/fs/mkfile.profile | 1 + test/root/cgroup.exp | 61 +++++++++++++++++++++++++++++++++++++++++++++ test/root/root.sh | 7 ++++-- test/utils/join-profile.exp | 2 +- test/utils/join2.exp | 2 +- test/utils/join3.exp | 2 +- test/utils/join4.exp | 2 +- 10 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 test/fs/mkdir2.profile create mode 100644 test/fs/mkfile.profile create mode 100755 test/root/cgroup.exp (limited to 'test') diff --git a/test/fs/mkdir.exp b/test/fs/mkdir.exp index 111db06db..81df7cd86 100755 --- a/test/fs/mkdir.exp +++ b/test/fs/mkdir.exp @@ -17,4 +17,11 @@ expect { send -- "rm -rf ~/.firejail_test\r" after 100 +send -- "firejail --profile=mkdir2.profile\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "only directories in user home or /tmp" +} +after 100 + puts "\nall done\n" diff --git a/test/fs/mkdir2.profile b/test/fs/mkdir2.profile new file mode 100644 index 000000000..28afb8d21 --- /dev/null +++ b/test/fs/mkdir2.profile @@ -0,0 +1 @@ +mkdir /etc/somefile diff --git a/test/fs/mkdir_mkfile.exp b/test/fs/mkdir_mkfile.exp index e2e7d3ef0..28a5ae459 100755 --- a/test/fs/mkdir_mkfile.exp +++ b/test/fs/mkdir_mkfile.exp @@ -42,5 +42,14 @@ expect { "_firejail_test_dir/dir1/dir2/dir3/file1" } after 100 +send -- "exit\r" +after 100 + +send -- "firejail --profile=mkfile.profile\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "only files in user home or /tmp" +} +after 100 puts "all done\n" diff --git a/test/fs/mkfile.profile b/test/fs/mkfile.profile new file mode 100644 index 000000000..6b7fbb322 --- /dev/null +++ b/test/fs/mkfile.profile @@ -0,0 +1 @@ +mkfile /etc/somefile diff --git a/test/root/cgroup.exp b/test/root/cgroup.exp new file mode 100755 index 000000000..4b07183a1 --- /dev/null +++ b/test/root/cgroup.exp @@ -0,0 +1,61 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2017 Firejail Authors +# License GPL v2 + +set timeout 10 +cd /home +spawn $env(SHELL) +match_max 100000 + + +send -- "mkdir /sys/fs/cgroup/systemd/firejail\r" +sleep 1 +send -- "ls /sys/fs/cgroup/systemd/firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "tasks" +} + +send -- "firejail --name=\"join testing\" --cgroup=/sys/fs/cgroup/systemd/firejail/tasks\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "wc -l /sys/fs/cgroup/systemd/firejail/tasks\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "3" +} + +spawn $env(SHELL) +send -- "firejail --join=\"join testing\"\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Switching to pid" +} +sleep 1 +send -- "ps aux\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "/bin/bash" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "/bin/bash" +} + +after 100 + +spawn $env(SHELL) +send -- "wc -l /sys/fs/cgroup/systemd/firejail/tasks\r" +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "3" +} +after 100 + +puts "\nall done\n" diff --git a/test/root/root.sh b/test/root/root.sh index 82fdc90b5..406e7dc4f 100755 --- a/test/root/root.sh +++ b/test/root/root.sh @@ -1,7 +1,7 @@ #!/bin/bash # set a new firejail config file -cp firejail.config /etc/firejail/firejail.config +#cp firejail.config /etc/firejail/firejail.config #******************************** # servers @@ -84,6 +84,9 @@ echo "TESTING: firejail configuration (test/root/checkcfg.exp)" ./checkcfg.exp cp ../../etc/firejail.config /etc/firejail/. +echo "TESTING: cgroup (test/root/cgroup.exp)" +./cgroup.exp + echo "TESTING: tmpfs (test/root/option_tmpfs.exp)" ./option_tmpfs.exp @@ -117,5 +120,5 @@ else fi # restore the default config file -cp ../../etc/firejail.config /etc/firejail/firejail.config +#cp ../../etc/firejail.config /etc/firejail/firejail.config diff --git a/test/utils/join-profile.exp b/test/utils/join-profile.exp index a2078c2f6..716bd2947 100755 --- a/test/utils/join-profile.exp +++ b/test/utils/join-profile.exp @@ -29,7 +29,7 @@ expect { "/bin/bash" } -send -- "exit" +send -- "exit\r" after 100 puts "\nall done\n" diff --git a/test/utils/join2.exp b/test/utils/join2.exp index b7d1f345f..0c1fa6684 100755 --- a/test/utils/join2.exp +++ b/test/utils/join2.exp @@ -32,7 +32,7 @@ expect { "/bin/bash" } -send -- "exit" +send -- "exit\r" after 100 puts "\nall done\n" diff --git a/test/utils/join3.exp b/test/utils/join3.exp index c0cc7c2e4..968aa3008 100755 --- a/test/utils/join3.exp +++ b/test/utils/join3.exp @@ -32,7 +32,7 @@ expect { "/bin/bash" } -send -- "exit" +send -- "exit\r" after 100 puts "\nall done\n" diff --git a/test/utils/join4.exp b/test/utils/join4.exp index c953320e0..27f52fd56 100755 --- a/test/utils/join4.exp +++ b/test/utils/join4.exp @@ -32,7 +32,7 @@ expect { "/bin/bash" } -send -- "exit" +send -- "exit\r" after 100 puts "\nall done\n" -- cgit v1.2.3-54-g00ecf