openafs/tests/rx/perf-t
Andrew Deason e07768aaf7 tests: Introduce afstest.pm
Create a perl module for some generic common code for our tests
written in perl: afstest.pm. With this commit, the module just
contains a couple of functions to calculate paths in our src and obj
trees (src_path(), obj_path()), analogous to afstest_src_path and
afstest_obj_path in our C helper library, libafstest_common.la.

Convert all existing perl test code that uses C_TAP_SOURCE/C_TAP_BUILD
to use these new functions.

Change-Id: I5e4d45e3d2d59449bbfc426476cb29b710c73bc1
Reviewed-on: https://gerrit.openafs.org/14800
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
2021-10-03 17:55:18 -04:00

50 lines
1.2 KiB
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
use afstest qw(obj_path);
use Test::More tests=>4;
use POSIX qw(:sys_wait_h :signal_h);
my $port = 4000;
my $rxperf = obj_path("src/tools/rxperf/rxperf");
# Start up an rxperf server
my $pid = fork();
if ($pid == -1) {
fail("Failed to fork rxperf server");
exit(1);
} elsif ($pid == 0) {
exec({$rxperf}
"rxperf", "server", "-p", $port, "-u", "1024", "-H", "-N");
die("Kabooom ?");
}
pass("Started rxperf server");
# Start up an rxperf client, and run a test
is(0,
system("$rxperf client -c rpc -p $port -S 1048576 -R 1048576 -T 30 -u 1024 -H -N"),
"single threaded client ran successfully");
is (0,
system("$rxperf client -c rpc -p $port -S 1048576 -R 1048576 -T 1 -t 30 -u 1024 -H -N"),
"multi threaded client ran succesfully");
# Kill the server, and check its exit code
kill("TERM", $pid);
waitpid($pid, 0);
my $ecode = ${^CHILD_ERROR_NATIVE};
if (WIFSIGNALED($ecode) && WTERMSIG($ecode) != SIGTERM) {
fail("Server died with signal ".WTERMSIG($ecode));
} elsif (WIFEXITED($ecode) && WEXITSTATUS($ecode) != 0) {
fail("Server exited with code". WEXITSTATUS($ecode));
} else {
pass("Server exited succesfully");
}