From fffce11c3da087172c069ec0ff4c788f5bcc522b Mon Sep 17 00:00:00 2001 From: netblue30 Date: Thu, 10 Nov 2016 20:15:22 -0500 Subject: testing --- test/fs/fs.sh | 9 +++++++++ test/fs/read-write.exp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 test/fs/read-write.exp (limited to 'test/fs') diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 8ad67141a..0b9cf977e 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -8,6 +8,15 @@ export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) rm -fr ~/_firejail_test_* echo "TESTING: mkdir/mkfile (test/fs/mkdir_mkfile.exp)" +./mkdir_mkfile.exp +rm -fr ~/_firejail_test_* + +mkdir ~/_firejail_test_dir +touch ~/_firejail_test_dir/a +mkdir ~/_firejail_test_dir/test1 +touch ~/_firejail_test_dir/test1/b +echo "TESTING: read/write (test/fs/read-write.exp)" +./read-write.exp rm -fr ~/_firejail_test_* echo "TESTING: /sys/fs access (test/fs/sys_fs.exp)" diff --git a/test/fs/read-write.exp b/test/fs/read-write.exp new file mode 100755 index 000000000..cfca15605 --- /dev/null +++ b/test/fs/read-write.exp @@ -0,0 +1,49 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + + +send -- "firejail --read-only=~/_firejail_test_dir --read-write=~/_firejail_test_dir/test1\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "echo mytest >~/_firejail_test_dir/a;echo done\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "done" +} + +send -- "echo mytest >~/_firejail_test_dir/test1/b;echo done\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "done" +} + +send -- "cat ~/_firejail_test_dir/a;echo done\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "mytest" {puts "TESTING ERROR 4\n";exit} + "done" +} + + +send -- "cat ~/_firejail_test_dir/test1/b;echo done\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "mytest" +} +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "done" +} + +after 100 +puts "\nall done\n" -- cgit v1.2.3-54-g00ecf