From 0c5cad78cf8d56b7cf493b160806dc10b7e9d462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:40:00 -0300 Subject: [PATCH] test(packaging): cover shared systemctl guard (cherry picked from commit 6c26a10863c5056938a4454a53d089de8bb82394) --- xCAT-test/unit/xcatd_rpm_service_packaging.t | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xCAT-test/unit/xcatd_rpm_service_packaging.t b/xCAT-test/unit/xcatd_rpm_service_packaging.t index b5420f153..2af06e242 100644 --- a/xCAT-test/unit/xcatd_rpm_service_packaging.t +++ b/xCAT-test/unit/xcatd_rpm_service_packaging.t @@ -521,6 +521,15 @@ ok( !-e legacy_init($legacy_remove_root) && !-e managed_marker($legacy_remove_root), 'legacy remove clears both the script and stale provenance' ); +my $systemctl_ready_status = system( + '/bin/sh', '-c', + '[ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1' +) >> 8; +is( run_helper( stage_root(), 'can-use-systemctl' ), $systemctl_ready_status, + 'shared helper preserves the host systemctl readiness predicate' ); +is( run_helper( stage_root(), 'can-use-systemctl', '--invalid' ), 2, + 'systemctl readiness rejects unexpected arguments' ); + my $rpm_spec = read_file( File::Spec->catfile( $repo_root, 'xCAT-server', 'xCAT-server.spec' ) ); @@ -558,6 +567,12 @@ unlike( $rpm_spec, unlike( $rpm_spec, qr{"\$xcatd_init_compat" configure(?![^\n]*--explicit-target)}, 'every RPM lifecycle configuration uses the matching explicit target mode' ); +unlike( $rpm_spec, qr{xcat_can_use_systemctl}, + 'RPM scriptlets do not duplicate the shared systemctl readiness guard' ); +my @systemctl_readiness_calls = + ( $rpm_spec =~ /"\$xcatd_init_compat" can-use-systemctl/g ); +is( scalar @systemctl_readiness_calls, 3, + 'RPM delegates every active-systemd operation guard to the shared helper' ); like( $rpm_spec, qr{xcatd_init_compat=.*?"\$xcatd_init_compat" configure --replace}s, 'RPM upgrades refresh an existing SysV init script' );