firejail/test/fs/macro-subpath.exp
Kelvin M. Klann ad89817c08
test/fs: deduplicate xdg dirs in macro tests (#7163)
To make it easier to add new directories.

Relates to #7147.
2026-05-13 14:14:31 +00:00

63 lines
1.8 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
set macros [ dict create \
"DESKTOP" "$::env(HOME)/Desktop" \
"DOCUMENTS" "$::env(HOME)/Documents" \
"DOWNLOADS" "$::env(HOME)/Downloads" \
"MUSIC" "$::env(HOME)/Music" \
"PICTURES" "$::env(HOME)/Pictures" \
"PROJECTS" "$::env(HOME)/Projects" \
"VIDEOS" "$::env(HOME)/Videos" \
]
# Test that macros work with subpaths (see #2359).
dict for {name path} $macros {
send -- "firejail --profile=./macro-subpath-whitelist.profile find $path/_firejail_test_dir | LC_ALL=C sort\r"
expect {
timeout {puts "TESTING ERROR 1 $name\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 1.1 $name\n";exit}
"$path/_firejail_test_dir/a" {}
"$path/_firejail_test_dir/b" {puts "TESTING ERROR 1.2 $name\n";exit}
}
after 100
}
dict for {name path} $macros {
send -- "firejail --profile=./macro-subpath-blacklist.profile ls $path/_firejail_test_dir; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 2 $name\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 2.1 $name\n";exit}
"Permission denied" {}
-re {ret 0} {puts "TESTING ERROR 2.2 $name\n";exit}
}
after 100
}
dict for {name path} $macros {
send -- "firejail --profile=./macro-subpath-readonly.profile touch $path/_firejail_test_dir/_firejail_test_file; echo ret \$?\r"
expect {
timeout {puts "TESTING ERROR 3 $name\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
timeout {puts "TESTING ERROR 3.1 $name\n";exit}
"Read-only file system" {}
-re {ret 0} {puts "TESTING ERROR 3.2 $name\n";exit}
}
after 100
}
puts "\nall done\n"