2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-08 12:40:45 +00:00

test(genesis): cover s390x identity

This commit is contained in:
Vinícius Ferrão
2026-09-04 12:44:44 -03:00
parent cb09b5033d
commit d140b941ad
2 changed files with 130 additions and 1 deletions
@@ -19,11 +19,14 @@ my $root = tempdir( CLEANUP => 1 );
my $binary = File::Spec->catfile( $root, 'xcat-genesis-console' );
my $header_test_source = File::Spec->catfile( $root, 'header-test.c' );
my $header_test_binary = File::Spec->catfile( $root, 'header-test' );
my $identity_test_source = File::Spec->catfile( $root, 'identity-test.c' );
my $identity_test_binary = File::Spec->catfile( $root, 'identity-test' );
my $compiler = $ENV{CC} || 'cc';
is(
system(
$compiler, '-D_POSIX_C_SOURCE=200809L', '-DXCAT_CONSOLE_PLAIN_ONLY',
'-DXCAT_CONSOLE_TEST',
'-std=c17', '-Wall', '-Wextra', '-Wpedantic', '-Werror',
@plain_sources, '-o', $binary
) >> 8,
@@ -75,6 +78,36 @@ is(
is( system($header_test_binary) >> 8, 0,
'narrow terminals leave no writable header context' );
write_file(
$identity_test_source,
<<'C'
#include "console.h"
#include <stdio.h>
int main(void) {
struct console_state state;
xcat_load_console_state(&state);
printf("uuid=%s\nfirmware=%s\nboot=%s\n", state.uuid, state.firmware,
state.boot_method);
return 0;
}
C
);
is(
system(
$compiler, '-D_POSIX_C_SOURCE=200809L', '-DXCAT_CONSOLE_TEST',
'-std=c17', '-Wall', '-Wextra', '-Wpedantic', '-Werror',
'-I', $source_dir, $identity_test_source,
File::Spec->catfile( $source_dir, 'state.c' ),
File::Spec->catfile( $source_dir, 'support.c' ),
'-o', $identity_test_binary
) >> 8,
0,
'identity probe builds with strict warnings'
);
my $cmdline = File::Spec->catfile( $root, 'cmdline' );
my $uptime = File::Spec->catfile( $root, 'uptime' );
my $os_release_real = File::Spec->catfile( $root, 'os-release.real' );
@@ -170,6 +203,15 @@ sub run_console {
return ( $? >> 8, $output );
}
sub run_identity_probe {
local %ENV = ( %ENV, %environment );
open( my $stream, '-|', $identity_test_binary )
or die "Unable to run $identity_test_binary: $!";
my $output = do { local $/; <$stream> };
close($stream);
return ( $? >> 8, $output );
}
my ( $status, $output ) = run_console();
is( $status, 0, 'plain console renders a status snapshot' );
like( $output,
@@ -193,6 +235,52 @@ unlike( $output, qr/extensions:|providers:|Linux /,
'inventory details stay off the main page' );
unlike( $output, qr/\e/, 'plain output has no terminal escapes' );
unlink(
File::Spec->catfile( $dmi_root, 'product_serial' ),
File::Spec->catfile( $dmi_root, 'product_uuid' ),
);
write_file( File::Spec->catfile( $proc_root, 'sysinfo' ), <<'SYSINFO' );
Plant: 02
Sequence Code: 0000000012345
LPAR UUID: 93724168-fda3-429b-8b28-a5d245dcb3ff
VM00 UUID: 82038f2a-1344-aaf7-1a85-2a7250be2076
SYSINFO
$environment{XCAT_TEST_ARCH} = 's390x';
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' );
my ( $probe_status, $probe_output ) = run_identity_probe();
is( $probe_status, 0, 'console loads IBM Z diagnostics' );
is(
$probe_output,
"uuid=82038f2a-1344-aaf7-1a85-2a7250be2076\n"
. "firmware=not reported\nboot=not reported\n",
'console does not infer the boot path from the architecture',
);
write_file( $cmdline,
"xcatd=192.0.2.10:3001 xcat.bootloader=s390-ccw\n" );
( $probe_status, $probe_output ) = run_identity_probe();
is(
$probe_output,
"uuid=82038f2a-1344-aaf7-1a85-2a7250be2076\n"
. "firmware=s390-ccw BIOS\nboot=QEMU TFTP loader\n",
'console reports the marked QEMU network boot path',
);
write_file( File::Spec->catfile( $proc_root, 'sysinfo' ), <<'SYSINFO' );
LPAR UUID: 93724168-fda3-429b-8b28-a5d245dcb3ff
SYSINFO
( $probe_status, $probe_output ) = run_identity_probe();
like( $probe_output,
qr/^uuid=93724168-fda3-429b-8b28-a5d245dcb3ff$/m,
'console uses the LPAR UUID when no guest UUID is available' );
delete $environment{XCAT_TEST_ARCH};
write_file( File::Spec->catfile( $dmi_root, 'product_serial' ),
"TEST-SERIAL-001\n" );
write_file( File::Spec->catfile( $dmi_root, 'product_uuid' ),
"11111111-2222-3333-4444-555555555555\n" );
my $cmdline_without_xcat = $ipv4_network_state;
$cmdline_without_xcat =~ s/^XCATDEST=.*\n//m;
write_file( $genesis_env, $cmdline_without_xcat );
@@ -121,6 +121,7 @@ write_file( File::Spec->catfile( $dmi_dir, 'product_uuid' ),
"00112233-4455-6677-8899-aabbccddeeff\n" );
write_file( File::Spec->catfile( $proc_root, 'cpuinfo' ), <<'CPU' );
processor : 0
vendor_id : Test Vendor
model name : Test CPU & Controller
processor : 1
CPU
@@ -400,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' ),
"cpu : POWER9\ncpu : POWER9\nplatform : PowerNV\n" );
"processor : 0\ncpu : POWER9\nprocessor : 1\ncpu : POWER9\nplatform : PowerNV\n" );
$environment{XCAT_TEST_ARCH} = 'ppc64le';
$environment{XCAT_TEST_RESPONSE} = 'restart';
is( run_script( $discover_script, \%environment ), 0,
@@ -420,6 +421,46 @@ like( $packet,
qr{<uuid>9009-42a-02ab123-525400000002</uuid>},
'Power discovery creates a stable fallback UUID' );
unlink(
File::Spec->catfile( $device_tree, 'model' ),
File::Spec->catfile( $device_tree, 'system-id' ),
);
write_file( File::Spec->catfile( $proc_root, 'sysinfo' ), <<'SYSINFO' );
Manufacturer: IBM
Type: 3931
Model: 701 A01
Sequence Code: 0000000012345
Plant: 02
LPAR Name: LP4KVM09
LPAR UUID: 93724168-fda3-429b-8b28-a5d245dcb3ff
VM00 Name: GENESIS1
VM00 Control Program: KVM/Linux
VM00 UUID: 82038f2a-1344-aaf7-1a85-2a7250be2076
SYSINFO
write_file( File::Spec->catfile( $proc_root, 'cpuinfo' ),
"vendor_id : IBM/S390\nprocessor 0: version = 00\nprocessor 1: version = 00\n" );
$environment{XCAT_TEST_ARCH} = 's390x';
is( run_script( $discover_script, \%environment ), 0,
's390x discovery accepts proc sysinfo identity' );
$packet = read_file($packet_file);
like( $packet, qr{<arch>s390x</arch>},
's390x discovery keeps the canonical architecture' );
like( $packet, qr{<nodetype>virtual</nodetype>},
's390x discovery identifies a hypervisor guest' );
like( $packet, qr{<mtm>3931-A01</mtm>},
's390x discovery reports the machine type and model' );
unlike( $packet, qr{<serial>},
's390x discovery does not treat the shared machine serial as guest identity' );
like( $packet, qr{<platform>KVM/Linux</platform>},
's390x discovery reports the closest hypervisor' );
like( $packet, qr{<cpucount>2</cpucount>},
's390x discovery counts processor records' );
like( $packet, qr{<cputype>IBM/S390</cputype>},
's390x discovery reports the CPU vendor' );
like( $packet,
qr{<uuid>82038f2a-1344-aaf7-1a85-2a7250be2076</uuid>},
's390x discovery uses the closest guest UUID' );
unlink($response_file);
is( run_script( $callback_script, \%environment, "restart (eth0)" ), 0,
'callback accepts a restart response' );