Merge pull request #7147 from kmk3/test-fs-improve-macros

test: improve tests related to macros
This commit is contained in:
Kelvin M. Klann 2026-04-27 11:06:34 +00:00 committed by GitHub
commit 6f4fb7e898
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 59 deletions

View file

@ -98,15 +98,15 @@ echo "TESTING: private-cwd (test/fs/private-cwd.exp)"
echo "TESTING: macros (test/fs/macro.exp)"
./macro.exp
rm -f ~/Desktop/_firejail_test_file
rm -f ~/Documents/_firejail_test_file
rm -f ~/Downloads/_firejail_test_file
rm -f ~/Music/_firejail_test_file
rm -f ~/Pictures/_firejail_test_file
rm -f ~/Videos/_firejail_test_file
echo "TESTING: whitelist empty (test/fs/whitelist-empty.exp)"
./whitelist-empty.exp
rm -f ~/Videos/_firejail_test_fil
rm -f ~/Pictures/_firejail_test_file
rm -f ~/Music/_firejail_test_file
rm -f ~/Downloads/_firejail_test_file
rm -f ~/Documents/_firejail_test_file
rm -f ~/Desktop/_firejail_test_file
echo "TESTING: private whitelist (test/fs/private-whitelist.exp)"
./private-whitelist.exp

View file

@ -1,6 +1,6 @@
blacklist ${VIDEOS}
blacklist ${DOCUMENTS}
blacklist ${MUSIC}
blacklist ${DOWNLOADS}
blacklist ${PICTURES}
blacklist ${DESKTOP}
blacklist ${DOCUMENTS}
blacklist ${DOWNLOADS}
blacklist ${MUSIC}
blacklist ${PICTURES}
blacklist ${VIDEOS}

View file

@ -1,6 +1,6 @@
read-only ${VIDEOS}
read-only ${DOCUMENTS}
read-only ${MUSIC}
read-only ${DOWNLOADS}
read-only ${PICTURES}
read-only ${DESKTOP}
read-only ${DOCUMENTS}
read-only ${DOWNLOADS}
read-only ${MUSIC}
read-only ${PICTURES}
read-only ${VIDEOS}

View file

@ -1,6 +1,6 @@
whitelist ${VIDEOS}
whitelist ${DOCUMENTS}
whitelist ${MUSIC}
whitelist ${DOWNLOADS}
whitelist ${PICTURES}
whitelist ${DESKTOP}
whitelist ${DOCUMENTS}
whitelist ${DOWNLOADS}
whitelist ${MUSIC}
whitelist ${PICTURES}
whitelist ${VIDEOS}

View file

@ -3,7 +3,7 @@
# Copyright (C) 2014-2026 Firejail Authors
# License GPL v2
set timeout 10
set timeout 1
spawn $env(SHELL)
match_max 100000
@ -37,138 +37,150 @@ expect {
timeout {puts "TESTING ERROR 6\n";exit}
"Videos"
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Desktop\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Desktop; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 7\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 8.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Documents\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Documents; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 9\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 10\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 10.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Downloads\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Downloads; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 11\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 12\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 12.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Music\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Music; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 13\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 14\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 14.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Pictures\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Pictures; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 15\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 16\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 16.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Videos\r"
send -- "firejail --profile=./macro-blacklist.profile ls ~/Videos; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 17\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 18\n";exit}
"Permission denied"
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 18.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Desktop/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Desktop/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 19\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 20\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 20.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Documents/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Documents/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 21\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 22\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 22.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Downloads/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Downloads/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 23\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 24\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 24.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Music/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Music/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 25\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 26\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 26.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Pictures/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Pictures/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 27\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 28\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 28.1\n";exit}
}
sleep 1
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Videos/blablabla\r"
send -- "firejail --profile=./macro-readonly.profile touch ~/Videos/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 29\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 30\n";exit}
"Read-only file system"
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 30.1\n";exit}
}
sleep 1
after 100
puts "\nall done\n"