tests: rlimit: add missing tests for rlimit-as / rlimit-cpu (#6895)

This is a follow-up to #6893.

Relates to #1604.
This commit is contained in:
Kelvin M. Klann 2025-09-12 10:34:02 +00:00 committed by GitHub
parent 2dbd31618c
commit aca3376a77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 49 additions and 14 deletions

View file

@ -0,0 +1 @@
rlimit-as -1234567890

View file

@ -0,0 +1 @@
rlimit-cpu -100

View file

@ -7,29 +7,43 @@ set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "firejail --profile=rlimit-bad-as.profile\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"invalid rlimit-as:"
}
after 100
send -- "firejail --profile=rlimit-bad-cpu.profile\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"invalid rlimit-cpu:"
}
after 100
send -- "firejail --profile=rlimit-bad-fsize.profile\r"
expect {
timeout {puts "TESTING ERROR 4\n";exit}
timeout {puts "TESTING ERROR 2\n";exit}
"invalid rlimit-fsize:"
}
after 100
send -- "firejail --profile=rlimit-bad-nofile.profile\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
timeout {puts "TESTING ERROR 3\n";exit}
"invalid rlimit-nofile:"
}
after 100
send -- "firejail --profile=rlimit-bad-nproc.profile\r"
expect {
timeout {puts "TESTING ERROR 6\n";exit}
timeout {puts "TESTING ERROR 4\n";exit}
"invalid rlimit-nproc:"
}
after 100
send -- "firejail --profile=rlimit-bad-sigpending.profile\r"
expect {
timeout {puts "TESTING ERROR 7\n";exit}
timeout {puts "TESTING ERROR 5\n";exit}
"invalid rlimit-sigpending:"
}
after 100

View file

@ -7,29 +7,43 @@ set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "firejail --rlimit-fsize=-1024\r"
send -- "firejail --rlimit-as=-1234567890\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"invalid rlimit-as: -1234567890"
}
after 100
send -- "firejail --rlimit-cpu=-100\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"invalid rlimit-cpu: -100"
}
after 100
send -- "firejail --rlimit-fsize=-1024\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"invalid rlimit-fsize: -1024"
}
after 100
send -- "firejail --rlimit-nofile=asdf\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
timeout {puts "TESTING ERROR 3\n";exit}
"invalid rlimit-nofile: asdf"
}
after 100
send -- "firejail --rlimit-nproc=100.23\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
timeout {puts "TESTING ERROR 4\n";exit}
"invalid rlimit-nproc: 100.23"
}
after 100
send -- "firejail --rlimit-sigpending=2345-78\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
timeout {puts "TESTING ERROR 5\n";exit}
"invalid rlimit-sigpending: 2345-78"
}
after 100

View file

@ -8,7 +8,7 @@ cd /home
spawn $env(SHELL)
match_max 100000
send -- "firejail --rlimit-as=1234567890 --rlimit-fsize=1024 --rlimit-nproc=1000 --rlimit-nofile=500 --rlimit-sigpending=200\r"
send -- "firejail --rlimit-as=1234567890 --rlimit-cpu=100 --rlimit-fsize=1024 --rlimit-nproc=1000 --rlimit-nofile=500 --rlimit-sigpending=200\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
@ -18,26 +18,30 @@ sleep 1
send -- "cat /proc/self/limits; pwd\r"
expect {
timeout {puts "TESTING ERROR 1.1\n";exit}
"Max file size 1024 1024"
"Max cpu time 100 100"
}
expect {
timeout {puts "TESTING ERROR 1.2\n";exit}
"Max processes 1000 1000"
"Max file size 1024 1024"
}
expect {
timeout {puts "TESTING ERROR 1.3\n";exit}
"Max open files 500 500"
"Max processes 1000 1000"
}
expect {
timeout {puts "TESTING ERROR 1.4\n";exit}
"Max address space 1234567890 1234567890"
"Max open files 500 500"
}
expect {
timeout {puts "TESTING ERROR 1.5\n";exit}
"Max pending signals 200 200"
"Max address space 1234567890 1234567890"
}
expect {
timeout {puts "TESTING ERROR 1.6\n";exit}
"Max pending signals 200 200"
}
expect {
timeout {puts "TESTING ERROR 1.7\n";exit}
"home"
}
after 100

View file

@ -1,4 +1,5 @@
rlimit-as 1234567890
rlimit-cpu 100
rlimit-fsize 1024
rlimit-nofile 500
rlimit-nproc 1000