From 6711a5ce9ecb76c56ec7b23f4598b6240cb23a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Fri, 4 Sep 2026 15:31:33 -0300 Subject: [PATCH] test(genesis): tighten s390x coverage --- .../integration/dhcp_isc_config_validation.t | 1 - .../integration/dhcp_kea_config_validation.t | 7 ------ xCAT-test/unit/dhcp_boot_policy.t | 24 ------------------- xCAT-test/unit/dhcp_isc_client_arch.t | 8 +++---- xCAT-test/unit/dhcp_kea_plugin_intent.t | 10 +------- xCAT-test/unit/genesis_openembedded.t | 6 +++++ .../unit/genesis_openembedded_activation.t | 4 ++-- xCAT-test/unit/genesis_openembedded_console.t | 22 +++++++++++++---- .../unit/genesis_openembedded_discovery.t | 6 ++--- xCAT-test/unit/mknb_exported_genesis.t | 16 ++----------- xCAT-test/unit/mknb_xcatd_address.t | 23 +++++++----------- 11 files changed, 45 insertions(+), 82 deletions(-) diff --git a/xCAT-test/integration/dhcp_isc_config_validation.t b/xCAT-test/integration/dhcp_isc_config_validation.t index 792739f48..7a80e209a 100644 --- a/xCAT-test/integration/dhcp_isc_config_validation.t +++ b/xCAT-test/integration/dhcp_isc_config_validation.t @@ -38,7 +38,6 @@ push @config, @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines( net => '192.0.2.0', prefix => 24, s390x_qemu_config_present => 1, - s390x_dpm_config_present => 1, ) }, "}\n"; my $configuration_root = -d '/etc/dhcp' ? '/etc/dhcp' : '/etc'; diff --git a/xCAT-test/integration/dhcp_kea_config_validation.t b/xCAT-test/integration/dhcp_kea_config_validation.t index acc7e5d2d..125189705 100644 --- a/xCAT-test/integration/dhcp_kea_config_validation.t +++ b/xCAT-test/integration/dhcp_kea_config_validation.t @@ -51,12 +51,6 @@ my $json = $backend->render_dhcp4_config( { name => 'path-prefix', data => 'pxelinux.cfg/s390x/' }, ], }, - { - name => 'xcat-s390x-dpm-192.168.122.0_24', - test => 'option[93].hex == 0x0020', - additional_only => JSON::true, - 'boot-file-name' => 'pxelinux.cfg/s390x/192.168.122.0_24.dpm', - }, { name => 'xcat-uefi-x64', test => "(option[93].hex == 0x0007 or option[93].hex == 0x0009 or option[93].hex == 0x0010) and not ((option[77].exists and (option[77].text == 'xNBA' or option[77].hex == 0x784e4241 or substring(option[77].hex,1,4) == 'xNBA')))", @@ -84,7 +78,6 @@ my $json = $backend->render_dhcp4_config( additional_client_classes => [ 'xcat-opal-v3-192.168.122.0-24', 'xcat-s390x-qemu-192.168.122.0_24', - 'xcat-s390x-dpm-192.168.122.0_24', ], option_data => [ { name => 'routers', data => '192.168.122.1' }, diff --git a/xCAT-test/unit/dhcp_boot_policy.t b/xCAT-test/unit/dhcp_boot_policy.t index 94e8477ff..a5d1e6610 100644 --- a/xCAT-test/unit/dhcp_boot_policy.t +++ b/xCAT-test/unit/dhcp_boot_policy.t @@ -221,7 +221,6 @@ my $s390x = xCAT::DHCP::BootPolicy->kea_s390x_network_classes( net => '10.0.0.0', prefix => 24, qemu_config_present => 1, - dpm_config_present => 1, ); is_deeply( $s390x, @@ -243,12 +242,6 @@ is_deeply( }, ], }, - { - name => 'xcat-s390x-dpm-10.0.0.0_24', - test => 'option[93].hex == 0x0020', - additional_only => 1, - 'boot-file-name' => 'pxelinux.cfg/s390x/10.0.0.0_24.dpm', - }, ], 's390x firmware receives its supported network configuration method', ); @@ -259,23 +252,6 @@ is_deeply( [], 's390x classes require a generated network configuration', ); -is_deeply( - xCAT::DHCP::BootPolicy->kea_s390x_network_classes( - net => '10.0.0.0', - prefix => 24, - dpm_config_present => 1, - ), - [ - { - name => 'xcat-s390x-dpm-10.0.0.0_24', - test => 'option[93].hex == 0x0020', - additional_only => 1, - 'boot-file-name' => 'pxelinux.cfg/s390x/10.0.0.0_24.dpm', - }, - ], - 's390x policies follow the configurations available on the network', -); - my @legacy_isc_config = ( "#xCAT generated dhcp configuration\n", "\n", diff --git a/xCAT-test/unit/dhcp_isc_client_arch.t b/xCAT-test/unit/dhcp_isc_client_arch.t index f87bf4294..d3b2fd85b 100644 --- a/xCAT-test/unit/dhcp_isc_client_arch.t +++ b/xCAT-test/unit/dhcp_isc_client_arch.t @@ -15,7 +15,6 @@ my $rendered = join '', @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines net => '192.0.2.0', prefix => 24, s390x_qemu_config_present => 1, - s390x_dpm_config_present => 1, ) }; like( @@ -40,8 +39,8 @@ like( ); like( $rendered, - qr/client-architecture = 00:1f \{ #QEMU s390x\n\s+option path-prefix = "pxelinux\.cfg\/s390x\/";\n\s+option conf-file = "192\.0\.2\.0_24";\n\s+\} else if option client-architecture = 00:20 \{ #IBM Z DPM\n\s+filename "pxelinux\.cfg\/s390x\/192\.0\.2\.0_24\.dpm";/, - 's390x firmware receives its supported network configuration method', + qr/client-architecture = 00:1f \{ #QEMU s390x\n\s+option path-prefix = "pxelinux\.cfg\/s390x\/";\n\s+option conf-file = "192\.0\.2\.0_24";/, + 'QEMU s390x receives its network configuration', ); my @riscv_ids = $rendered =~ /client-architecture = (00:1[9a-e])/g; @@ -59,13 +58,14 @@ my $fallback_pos = index($rendered, 'substring(filename,0,1) = null'); cmp_ok($aarch64_pos, '<', $tftp_pos, 'riscv64 follows the aarch64 branch'); cmp_ok($tftp_pos, '<', $http_pos, 'the TFTP branch precedes the HTTP branch'); +cmp_ok($http_pos, '<', $opal_pos, 'the HTTP branch precedes the OPAL branch'); cmp_ok($http_pos, '<', $fallback_pos, 'the HTTP branch is reachable before the fallback'); like($rendered, qr/filename "\/yaboot";\n\s*\}\n\z/, 'the policy ends with the existing yaboot fallback'); my $without_s390x = join '', @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines( next_server => '192.0.2.10', net => '192.0.2.0', prefix => 24, ) }; -unlike($without_s390x, qr/client-architecture = 00:(?:1f|20)/, +unlike($without_s390x, qr/client-architecture = 00:1f/, 'ISC does not advertise s390x without a generated network configuration'); done_testing(); diff --git a/xCAT-test/unit/dhcp_kea_plugin_intent.t b/xCAT-test/unit/dhcp_kea_plugin_intent.t index f1285ca90..530690d2d 100644 --- a/xCAT-test/unit/dhcp_kea_plugin_intent.t +++ b/xCAT-test/unit/dhcp_kea_plugin_intent.t @@ -141,10 +141,6 @@ make_path($s390x_config_dir); open(my $s390x_config, '>', "$s390x_config_dir/10.0.0.0_24") or die "Unable to create s390x test configuration: $!"; close($s390x_config); -open($s390x_config, '>', "$s390x_config_dir/10.0.0.0_24.dpm") - or die "Unable to create s390x DPM test configuration: $!"; -close($s390x_config); - { no warnings 'redefine'; local *xCAT::NetworkUtils::thishostisnot = sub { return 0; }; @@ -154,13 +150,9 @@ close($s390x_config); ); my %classes = map { $_->{name} => $_ } @{ $subnet->{client_classes} }; ok($classes{'xcat-s390x-qemu-10.0.0.0_24'}, 'the Kea subnet includes QEMU s390x boot policy'); - ok($classes{'xcat-s390x-dpm-10.0.0.0_24'}, 'the Kea subnet includes IBM Z DPM boot policy'); is_deeply( [ grep { /^xcat-s390x-/ } @{ $subnet->{additional_client_classes} } ], - [ - 'xcat-s390x-qemu-10.0.0.0_24', - 'xcat-s390x-dpm-10.0.0.0_24', - ], + ['xcat-s390x-qemu-10.0.0.0_24'], 'the s390x policy is evaluated only for its subnet', ); } diff --git a/xCAT-test/unit/genesis_openembedded.t b/xCAT-test/unit/genesis_openembedded.t index d7d502e2f..d595725df 100644 --- a/xCAT-test/unit/genesis_openembedded.t +++ b/xCAT-test/unit/genesis_openembedded.t @@ -872,6 +872,12 @@ like( $extension_class, qr/Restricted Genesis extensions must set LICENSE_FLAGS/ like( $extension_class, qr/"sha256":/, 'extension manifests record the image digest' ); +my $smoke_extension = read_file( + 'xCAT-genesis-builder/oe/meta-xcat-genesis/recipes-extensions/images/xcat-genesis-extension-smoke.bb' +); +like( $smoke_extension, qr/^XCAT_GENESIS_EXTENSION_NAME = "xcat-smoke"$/m, + 'open smoke extension exercises the build path' ); + my $preset = read_file( 'xCAT-genesis-builder/oe/meta-xcat-genesis/recipes-core/xcat-genesis-init/files/00-xcat-genesis.preset' ); diff --git a/xCAT-test/unit/genesis_openembedded_activation.t b/xCAT-test/unit/genesis_openembedded_activation.t index 2aaee8baa..774f73049 100644 --- a/xCAT-test/unit/genesis_openembedded_activation.t +++ b/xCAT-test/unit/genesis_openembedded_activation.t @@ -114,8 +114,8 @@ like( ); like( $mknb_pod, - qr/\bs390x\b/, - 'the mknb man page lists the s390x target', + qr/x86.*x86_64.*ppc64.*ppc64le.*armv7hf.*aarch64.*riscv64.*s390x/s, + 'the mknb man page lists every exact OpenEmbedded architecture', ); unlike( $mknb_pod, diff --git a/xCAT-test/unit/genesis_openembedded_console.t b/xCAT-test/unit/genesis_openembedded_console.t index de015dbfb..ae639bcf8 100644 --- a/xCAT-test/unit/genesis_openembedded_console.t +++ b/xCAT-test/unit/genesis_openembedded_console.t @@ -83,6 +83,19 @@ write_file( #include "console.h" #include +#include +#include +#include + +int xcat_test_uname(struct utsname *name) { + const char *architecture = getenv("XCAT_TEST_ARCH"); + + memset(name, 0, sizeof(*name)); + snprintf(name->machine, sizeof(name->machine), "%s", + architecture != NULL ? architecture : "x86_64"); + snprintf(name->release, sizeof(name->release), "test-kernel"); + return 0; +} int main(void) { struct console_state state; @@ -97,6 +110,7 @@ C is( system( $compiler, '-D_POSIX_C_SOURCE=200809L', + '-Duname=xcat_test_uname', '-std=c17', '-Wall', '-Wextra', '-Wpedantic', '-Werror', '-I', $source_dir, $identity_test_source, File::Spec->catfile( $source_dir, 'state.c' ), @@ -191,6 +205,7 @@ my %environment = ( XCAT_PROC_ROOT => $proc_root, XCAT_EXTENSION_DIR => $extensions, XCAT_PROVIDER_DIR => $providers, + XCAT_TEST_ARCH => 'x86_64', ); sub run_console { @@ -245,10 +260,7 @@ LPAR UUID: 93724168-fda3-429b-8b28-a5d245dcb3ff VM00 UUID: 82038f2a-1344-aaf7-1a85-2a7250be2076 SYSINFO write_file( $cmdline, "xcatd=192.0.2.10:3001\n" ); -( $status, $output ) = run_console(); -is( $status, 0, 'plain console accepts IBM Z identity' ); -like( $output, qr/^serial: not reported$/m, - 'console does not present the shared IBM Z machine serial as guest identity' ); +$environment{XCAT_TEST_ARCH} = 's390x'; my ( $probe_status, $probe_output ) = run_identity_probe(); is( $probe_status, 0, 'console loads IBM Z diagnostics' ); is( @@ -273,6 +285,8 @@ SYSINFO like( $probe_output, qr/^uuid=93724168-fda3-429b-8b28-a5d245dcb3ff$/m, 'console uses the LPAR UUID when no guest UUID is available' ); +unlink( File::Spec->catfile( $proc_root, 'sysinfo' ) ); +$environment{XCAT_TEST_ARCH} = 'x86_64'; write_file( File::Spec->catfile( $dmi_root, 'product_serial' ), "TEST-SERIAL-001\n" ); write_file( File::Spec->catfile( $dmi_root, 'product_uuid' ), diff --git a/xCAT-test/unit/genesis_openembedded_discovery.t b/xCAT-test/unit/genesis_openembedded_discovery.t index 0913e5259..b68a899d1 100644 --- a/xCAT-test/unit/genesis_openembedded_discovery.t +++ b/xCAT-test/unit/genesis_openembedded_discovery.t @@ -401,7 +401,7 @@ write_file( File::Spec->catfile( $device_tree, 'model' ), write_file( File::Spec->catfile( $device_tree, 'system-id' ), "IBM,02AB123\0" ); write_file( File::Spec->catfile( $proc_root, 'cpuinfo' ), - "processor : 0\ncpu : POWER9\nprocessor : 1\ncpu : POWER9\nplatform : PowerNV\n" ); + "cpu : POWER9\ncpu : POWER9\nplatform : PowerNV\n" ); $environment{XCAT_TEST_ARCH} = 'ppc64le'; $environment{XCAT_TEST_RESPONSE} = 'restart'; is( run_script( $discover_script, \%environment ), 0, @@ -415,8 +415,8 @@ like( $packet, qr{02AB123}, 'Power discovery reports the system serial' ); like( $packet, qr{PowerNV}, 'Power discovery reports the firmware platform' ); -like( $packet, qr{4}, - 'Power discovery keeps the existing processor count' ); +like( $packet, qr{2}, + 'Power discovery counts processor records' ); like( $packet, qr{9009-42a-02ab123-525400000002}, 'Power discovery creates a stable fallback UUID' ); diff --git a/xCAT-test/unit/mknb_exported_genesis.t b/xCAT-test/unit/mknb_exported_genesis.t index f9b0ae860..5f523a9bf 100644 --- a/xCAT-test/unit/mknb_exported_genesis.t +++ b/xCAT-test/unit/mknb_exported_genesis.t @@ -169,19 +169,13 @@ write_file( "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24", "# pxelinux.cfg xCAT Genesis s390x\nstale config\n", ); -write_file( - "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm", - "# pxelinux.cfg xCAT Genesis s390x\nstale DPM config\n", -); write_file("$tftpdir/pxelinux.cfg/s390x/default", "admin fallback\n"); ($removed, $remove_error) = xCAT_plugin::mknb::_remove_openembedded_genesis($tftpdir, 's390x'); is($remove_error, undef, 's390x boot artifacts can be retired cleanly'); -is($removed, 6, 's390x image and generated discovery configurations are retired'); +is($removed, 5, 's390x image and generated discovery configurations are retired'); ok(!-e "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24", 'retiring s390x removes the generated discovery configuration'); -ok(!-e "$tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm", - 'retiring s390x removes the generated DPM configuration'); is(read_file("$tftpdir/pxelinux.cfg/s390x/default"), "admin fallback\n", 'retiring s390x preserves administrator-owned configurations'); @@ -194,18 +188,12 @@ write_file( "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24", "# pxelinux.cfg xCAT Genesis s390x\nconfiguration\n", ); -write_file( - "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm", - "# pxelinux.cfg xCAT Genesis s390x\nDPM configuration\n", -); ($removed, $remove_error) = xCAT_plugin::mknb::_remove_openembedded_genesis($special_tftpdir, 's390x'); is($remove_error, undef, 's390x cleanup accepts a TFTP path with shell metacharacters'); -is($removed, 5, 's390x cleanup removes every generated artifact from that path'); +is($removed, 4, 's390x cleanup removes every generated artifact from that path'); ok(!-e "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24", 's390x cleanup does not expand the TFTP path as a glob'); -ok(!-e "$special_tftpdir/pxelinux.cfg/s390x/192.0.2.0_24.dpm", - 's390x cleanup removes DPM configurations from the literal path'); my $failed_kernel = "$tftpdir/xcat/genesis.kernel.aarch64"; make_path($failed_kernel); diff --git a/xCAT-test/unit/mknb_xcatd_address.t b/xCAT-test/unit/mknb_xcatd_address.t index c822d3651..d2c0ecdc5 100644 --- a/xCAT-test/unit/mknb_xcatd_address.t +++ b/xCAT-test/unit/mknb_xcatd_address.t @@ -536,18 +536,6 @@ unlike( qr/192\.168\.149\.100/, 's390x configurations do not use the later floating address', ); -my $s390x_dpm_path = "$s390x_qemu_path.dpm"; -is( - read_config($s390x_dpm_path), - "# pxelinux.cfg xCAT Genesis s390x\n" - . "DEFAULT xCAT\n" - . "label xCAT\n" - . " kernel=xcat/genesis.kernel.s390x\n" - . " initrd=xcat/genesis.fs.s390x.gz\n" - . " append=xcatd=192.168.148.10:3001 xcat.bootloader=s390-ccw console=ttysclp0\n", - 'the DPM configuration uses the IBM Z network-boot syntax', -); - write_text($s390x_qemu_path, "admin network configuration\n"); %xCAT::TableUtils::site_extra = ( dhcpinterfaces => 'eth0,eth1:noboot' ); $xCAT::NetworkUtils::nic_ips = { eth0 => '10.0.0.1', eth1 => '192.168.148.10' }; @@ -561,7 +549,15 @@ is( %xCAT::TableUtils::site_extra = (); $xCAT::NetworkUtils::nic_ips = undef; $responses = run_mknb('s390x'); -generation_succeeded($responses, 's390x configuration is restored after removing :noboot'); +ok( + scalar(grep { ref($_) eq 'HASH' && $_->{error} && "@{$_->{error}}" =~ /Refusing to replace unmanaged/ } @{$responses}), + 's390x refuses to replace an administrator-owned configuration', +); +is(read_config($s390x_qemu_path), "admin network configuration\n", + 'the administrator-owned configuration is unchanged'); +unlink($s390x_qemu_path); +$responses = run_mknb('s390x'); +generation_succeeded($responses, 's390x configuration is restored after removing the unmanaged file'); my $s390x_failure_root = "$tmpdir/tftpboot-s390x-failure"; make_path("$s390x_failure_root/pxelinux.cfg/s390x/192.168.144.0_20"); @@ -599,7 +595,6 @@ $xCAT::NetworkUtils::nic_ips = { eth0 => '10.0.0.1', eth1 => '192.168.148.10' }; $responses = run_mknb('s390x'); generation_succeeded($responses, 's390x configuration generation honors :noboot'); ok(!-e $s390x_qemu_path, 'a :noboot network gets no QEMU s390x configuration'); -ok(!-e $s390x_dpm_path, 'a :noboot network gets no IBM Z DPM configuration'); %xCAT::TableUtils::site_extra = (); $xCAT::NetworkUtils::nic_ips = undef;