From c06ea32c672a0d50374bd8d64c5e987ccefd287c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:14:13 -0300 Subject: [PATCH] test(netboot): cover volatile kernel arguments --- xCAT-test/unit/boot_utils.t | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 xCAT-test/unit/boot_utils.t diff --git a/xCAT-test/unit/boot_utils.t b/xCAT-test/unit/boot_utils.t new file mode 100644 index 000000000..5d19f3b55 --- /dev/null +++ b/xCAT-test/unit/boot_utils.t @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../../perl-xCAT"; + +use Test::More; + +use xCAT::BootUtils; + +my @cases = ( + [ undef, undef, 'undefined input remains undefined' ], + [ '', '', 'empty input remains empty' ], + [ '0', '0', 'false string input remains unchanged' ], + [ 'console=ttyS0 quiet', 'console=ttyS0 quiet ', 'volatile options are retained' ], + [ 'R::root=/dev/sda R::console=ttyS0', '', 'persistent-only options are omitted' ], + [ + 'console=ttyS0 R::root=/dev/sda quiet', + 'console=ttyS0 quiet ', + 'persistent options are omitted from mixed input' + ], + [ + 'first R::persist=1 second R::last=1 third', + 'first second third ', + 'volatile option ordering is preserved' + ], +); + +for my $case (@cases) { + my ($input, $expected, $description) = @{$case}; + is( xCAT::BootUtils::volatile_addkcmdline($input), $expected, $description ); +} + +my $original = 'first R::persist=1 second'; +is( xCAT::BootUtils::volatile_addkcmdline($original), 'first second ', 'the normalized value is returned' ); +is( $original, 'first R::persist=1 second', 'the caller value is not modified' ); + +done_testing();