Commit 35b5da95 authored by David Johnson's avatar David Johnson

If nice fails, don't use it to run iperf in linktest.

(Some containers are deprivileged and cannot even run setpriority.
Traditional nice is helpful to linktest, because even if its setpriority
call fails, it still runs the command.  busybox nice just fails (which
is arguably the right behavior, but it's not consistent).  So now we do
a quick trial of the platform nice to see what it can do, and only use
it if it succeeds on /bin/true.)
parent 26305979
......@@ -152,6 +152,7 @@ use constant EXIT_OK => 0;
# Protos
sub TimeStamp();
sub PATH_NICE();
sub NICE_ARGS();
# struct for representing a link.
struct ( edge => {
......@@ -525,7 +526,7 @@ if (&dotest(TEST_BW)) {
if ($printsched) {
&schedlog("start iperf listener");
} else {
$listener_iperf = &start_listener(PATH_NICE, "-n", "-10",
$listener_iperf = &start_listener(NICE_ARGS(),
$PATH_IPERF,"-s","-f","b","-u",
"-w","200000","-l",IPERF_PKTSIZE);
}
......@@ -1861,7 +1862,7 @@ sub bw_test {
" (bw=${bw}bps, time=${duration}s," .
" sbsize=200000, acktime=${acktime}ms)");
} else {
&my_system(PATH_NICE, "-n", "-10", $PATH_IPERF,
&my_system(NICE_ARGS(), $PATH_IPERF,
"-c", $edge->src . "-" . $edge->name,
"-t", "$duration", "-f", "b",
"-r", "-u", "-w", "200000",
......@@ -3128,3 +3129,25 @@ sub PATH_NICE()
return "/usr/bin/nice" if (-x "/usr/bin/nice");
return "nice";
}
my $CAN_NICE;
sub NICE_ARGS()
{
if (!defined($CAN_NICE)) {
system(PATH_NICE()." -n -10 /bin/true");
if ($?) {
print STDERR "WARNING: cannot nice; skipping for iperf!\n";
$CAN_NICE = 0;
}
else {
$CAN_NICE = 1;
}
}
if ($CAN_NICE) {
return (PATH_NICE(),"-n","-10")
}
else {
return ();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment