firejail/test/environment/nice.exp
2026-01-05 12:42:17 -05:00

99 lines
1.6 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 10
spawn $env(SHELL)
match_max 100000
send -- "firejail --nice=15\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
sleep 1
send -- "top -b -n 1 | awk '{ print \$4, \$12 }'\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"15"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"sh"
}
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"15"
}
expect {
timeout {puts "TESTING ERROR 6\n";exit}
"top"
}
sleep 1
send -- "exit\r"
after 100
send -- "firejail --profile=./nice.profile\r"
expect {
timeout {puts "TESTING ERROR 10\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
sleep 1
send -- "top -b -n 1 | awk '{ print \$4, \$12 }'\r"
expect {
timeout {puts "TESTING ERROR 12\n";exit}
"15"
}
expect {
timeout {puts "TESTING ERROR 13\n";exit}
"sh"
}
expect {
timeout {puts "TESTING ERROR 15\n";exit}
"15"
}
expect {
timeout {puts "TESTING ERROR 16\n";exit}
"top"
}
sleep 1
send -- "exit\r"
after 100
# negative nice value should result in nice=0
send -- "firejail --nice=-5\r"
expect {
timeout {puts "TESTING ERROR 17\n";exit}
-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
sleep 1
send -- "top -b -n 1 | awk '{ print \$4, \$12 }'\r"
expect {
timeout {puts "TESTING ERROR 19\n";exit}
"0"
}
expect {
timeout {puts "TESTING ERROR 20\n";exit}
"sh"
}
expect {
timeout {puts "TESTING ERROR 22\n";exit}
"0"
}
expect {
timeout {puts "TESTING ERROR 23\n";exit}
"top"
}
sleep 1
send -- "exit\r"
after 100
puts "\nall done\n"