2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-08 20:50:44 +00:00
Files
xcat-core/xCAT-test/unit/remoteshell_kill_signal.t
T
Vinícius Ferrão 1f26a3b318 test(remoteshell): pin the signal that stops the ssh daemon
Check that no kill in the postscript gives the signal number without a hyphen,
and that the ssh daemon gets the signal that a process cannot catch.
2026-08-29 18:32:47 -03:00

27 lines
823 B
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
use FindBin;
use Test::More;
my $script = File::Spec->catfile( $FindBin::Bin, '..', '..',
'xCAT', 'postscripts', 'remoteshell' );
plan skip_all => 'remoteshell not found' unless -r $script;
open( my $fh, '<', $script ) or die "Unable to read $script: $!";
my $source = do { local $/; <$fh> };
close($fh);
# A kill without the hyphen reads the signal number as one more process id, so
# the target gets the default signal, which a process can catch, and the
# process with that id is signalled as well.
my @bare = ( $source =~ /^[^#\n]*\bkill\s+\d/gm );
is( scalar(@bare), 0, 'no kill gives the signal number without a hyphen' );
like( $source, qr/kill -9 \$PIDLIST/,
'the ssh daemon gets the signal that a process cannot catch' );
done_testing();