firejail/test/fs/macro.exp
Kelvin M. Klann 5abf0577a7
feature: add ${PROJECTS} macro (#7157)
Based on the new ~/Projects directory from version 0.20 of the
xdg-user-dirs specification[1]:

* `XDG_PROJECTS_DIR="$HOME/Projects"`

Relates to #7147 #7151.

[1] https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
2026-05-09 13:19:42 +00:00

216 lines
5.9 KiB
Text
Executable file

#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2026 Firejail Authors
# License GPL v2
set timeout 3
spawn $env(SHELL)
match_max 100000
send -- "firejail --profile=./macro-whitelist.profile ls ~\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 1.1 Desktop\n";exit}
"Desktop"
}
expect {
timeout {puts "TESTING ERROR 1.1 Documents\n";exit}
"Documents"
}
expect {
timeout {puts "TESTING ERROR 1.1 Downloads\n";exit}
"Downloads"
}
expect {
timeout {puts "TESTING ERROR 1.1 Music\n";exit}
"Music"
}
expect {
timeout {puts "TESTING ERROR 1.1 Pictures\n";exit}
"Pictures"
}
expect {
timeout {puts "TESTING ERROR 1.1 Projects\n";exit}
"Projects"
}
expect {
timeout {puts "TESTING ERROR 1.1 Videos\n";exit}
"Videos"
}
after 100
# blacklist
send -- "firejail --profile=./macro-blacklist.profile ls ~/Desktop; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Desktop\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Desktop\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Desktop\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Documents; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Documents\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Documents\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Documents\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Downloads; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Downloads\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Downloads\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Downloads\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Music; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Music\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Music\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Music\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Pictures; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Pictures\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Pictures\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Pictures\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Projects; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Projects\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Projects\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Projects\n";exit}
}
after 100
send -- "firejail --profile=./macro-blacklist.profile ls ~/Videos; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 Videos\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 Videos\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 Videos\n";exit}
}
after 100
# read-only
send -- "firejail --profile=./macro-readonly.profile touch ~/Desktop/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Desktop\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Desktop\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Desktop\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Documents/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Documents\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Documents\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Documents\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Downloads/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Downloads\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Downloads\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Downloads\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Music/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Music\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Music\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Music\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Pictures/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Pictures\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Pictures\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Pictures\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Projects/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Projects\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Projects\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Projects\n";exit}
}
after 100
send -- "firejail --profile=./macro-readonly.profile touch ~/Videos/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 Videos\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 Videos\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 Videos\n";exit}
}
after 100
puts "\nall done\n"