From 5bb476f74efb4754b6f5f8d711c6b77898ef9385 Mon Sep 17 00:00:00 2001 From: smitsohu Date: Tue, 24 Sep 2019 13:42:19 +0200 Subject: testing --- test/fs/fs.sh | 7 ++++++ test/fs/private-cache.exp | 53 ++++++++++++++++++++++++++++++++++++++++ test/fs/whitelist-whitespace.exp | 41 +++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 test/fs/private-cache.exp create mode 100755 test/fs/whitelist-whitespace.exp (limited to 'test') diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 7e1d46f0a..e706acd8d 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -5,6 +5,7 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) +export LC_ALL=C # These directories are required by some tests: mkdir -p ~/Desktop ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos @@ -102,6 +103,9 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)" echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" ./whitelist-double.exp +echo "TESTING: whitelist file with whitespaces (test/fs/whitelist-whitespace.exp)" +./whitelist-whitespace.exp + echo "TESTING: whitelist (test/fs/whitelist.exp)" ./whitelist.exp @@ -117,6 +121,9 @@ echo "TESTING: fscheck --tmpfs non root (test/fs/fscheck-tmpfs.exp)" echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)" ./fscheck-private.exp +echo "TESTING: fscheck --private-cache (test/fs/fscheck-private-cache.exp)" +./fscheck-private-cache.exp + echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)" ./fscheck-readonly.exp diff --git a/test/fs/private-cache.exp b/test/fs/private-cache.exp new file mode 100755 index 000000000..0a1f00eb5 --- /dev/null +++ b/test/fs/private-cache.exp @@ -0,0 +1,53 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +if {[file exists ~/.cache]} { + puts "found .cache directory\n" +} else { + send -- "mkdir --mode=755 ~/.cache\r" +} +after 100 + +send -- "touch ~/.cache/abcdefg\r" +after 100 + +send -- "firejail --noprofile --private-cache\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "ls ~/.cache | wc -l\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "\n0" +} +after 100 + +send -- "exit\r" +sleep 1 + +send -- "rm -v ~/.cache/abcdefg\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "removed" +} +after 100 + +# redo the test with --private + +send -- "firejail --noprofile --private --private-cache\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "tmpfs not mounted" +} +sleep 1 + +send -- "exit\r" +sleep 1 + +puts "\nall done\n" diff --git a/test/fs/whitelist-whitespace.exp b/test/fs/whitelist-whitespace.exp new file mode 100755 index 000000000..b16668557 --- /dev/null +++ b/test/fs/whitelist-whitespace.exp @@ -0,0 +1,41 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "touch ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" +after 100 + +send -- "firejail --noprofile --whitelist=~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "ls ~ | wc -l\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "\n1" +} +after 100 + +send -- "ls ~\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "filewith many whitespaces " +} +after 100 + +send -- "exit\r" +sleep 1 + +send -- "rm -v ~/filewith\\\ \\\ many\\\ whitespaces\\\ \r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "removed" +} +after 100 + +puts "\nall done\n" -- cgit v1.2.3-54-g00ecf