From 1f26a3b31868b8ddf8fda34c805abc65094422d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:32:47 -0300 Subject: [PATCH] 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. --- xCAT-test/unit/remoteshell_kill_signal.t | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 xCAT-test/unit/remoteshell_kill_signal.t diff --git a/xCAT-test/unit/remoteshell_kill_signal.t b/xCAT-test/unit/remoteshell_kill_signal.t new file mode 100644 index 000000000..d10d15307 --- /dev/null +++ b/xCAT-test/unit/remoteshell_kill_signal.t @@ -0,0 +1,26 @@ +#!/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();