mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
3f4f862d14
tests/rx/perf-t and tests/rx/simple-t contain an identical section of perl code for checking the exit status of the relevant server process. The spacing around some string concatenations are missing some spaces. Add the missing spaces. Thanks to sahilcdq@proton.me and cwills@sinenomine.net for pointing these out. Change-Id: Ieca3e6e5eabbd1c65c07edc33f1a884fc0fac248 Reviewed-on: https://gerrit.openafs.org/15848 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Sahil Siddiq <sahilcdq@proton.me> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
89 lines
3.0 KiB
Perl
Executable File
89 lines
3.0 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
#
|
|
# Copyright (c) 2024 Sahil Siddiq <sahilcdq@proton.me>.
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
use strict;
|
|
use warnings;
|
|
use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
|
|
|
|
use afstest qw(obj_path);
|
|
use Test::More tests=>6;
|
|
use POSIX qw(:sys_wait_h :signal_h);
|
|
|
|
my $port = 4000;
|
|
my $service = 1234;
|
|
my $server = obj_path("tests/rx/simple-server");
|
|
my $client = obj_path("tests/rx/simple-client");
|
|
my $server_pid;
|
|
|
|
# Start up the server
|
|
$server_pid = open(my $server_fh, '-|', $server, $port, $service);
|
|
if (!defined($server_pid)) {
|
|
die("Failed to run $server: $!");
|
|
}
|
|
|
|
# Wait for the server to finish starting
|
|
while (my $line = <$server_fh>) {
|
|
chomp($line);
|
|
diag($line);
|
|
}
|
|
|
|
# Server is now ready to receive calls
|
|
|
|
pass("Started server");
|
|
|
|
# Start up a client, and run a test
|
|
my $message = 'Hello OpenAFS';
|
|
my $expected = 'Uryyb BcraNSF';
|
|
my $got = qx($client localhost $port $service "$message");
|
|
chomp($got);
|
|
|
|
is(0, $?, "Client ran successfully");
|
|
is($expected, $got, "Rot13 performed successfully");
|
|
|
|
# Test a case where the server aborts the call
|
|
$message = 'This exceeds the message size';
|
|
$got = qx($client localhost $port $service "$message" 2>&1);
|
|
$expected = "simple-client: rx_Read failed
|
|
simple-client: call aborted with code 201
|
|
";
|
|
my $got_ret = ($? >> 8);
|
|
my $expected_ret = 201;
|
|
|
|
is($expected_ret, $got_ret, "Client exited with correct status");
|
|
is($got, $expected, "Client saw an aborted call");
|
|
|
|
# Kill the server process
|
|
kill("TERM", $server_pid);
|
|
|
|
close($server_fh);
|
|
my $ecode = ${^CHILD_ERROR_NATIVE};
|
|
if (WIFSIGNALED($ecode) && WTERMSIG($ecode) == SIGTERM) {
|
|
pass("Server died with SIGTERM");
|
|
} elsif (WIFSIGNALED($ecode)) {
|
|
fail("Server died with signal " . WTERMSIG($ecode));
|
|
} else {
|
|
fail("Server exited with code " . WEXITSTATUS($ecode));
|
|
}
|