From 980965523663cb78124da60cc8362e4f604888aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 26 Aug 2026 19:34:18 -0300 Subject: [PATCH] test(build): cover source RPM architecture selection --- xCAT-test/unit/buildcore_source_only.t | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/xCAT-test/unit/buildcore_source_only.t b/xCAT-test/unit/buildcore_source_only.t index b59c3971a..1c3b4ee65 100644 --- a/xCAT-test/unit/buildcore_source_only.t +++ b/xCAT-test/unit/buildcore_source_only.t @@ -86,6 +86,32 @@ SH }; } +sub deliver_genesis { + my ($source_only) = @_; + my $root = tempdir( CLEANUP => 1 ); + make_path( "$root/rpmbuild/RPMS/noarch", "$root/rpmbuild/SRPMS", + "$root/dest", "$root/src" ); + for my $arch (qw(x86_64 ppc64)) { + _touch("$root/rpmbuild/RPMS/noarch/xCAT-genesis-scripts-$arch-2.19.0-snap1.noarch.rpm"); + _touch("$root/rpmbuild/SRPMS/xCAT-genesis-scripts-$arch-2.19.0-snap1.src.rpm"); + _touch("$root/src/xCAT-genesis-scripts-$arch-2.19.0-snap0.src.rpm"); + } + + my ( $said, $status ) = run_helper( $root, 'deliver-genesis', <<"SH" ); +SRCONLY=$source_only +source=$root/rpmbuild +DESTDIR=$root/dest +SRCDIR=$root/src +xcat_deliver_genesis_packages +SH + return { + said => $said, + status => $status, + delivered => [ sort map { s{.*/}{}r } glob("$root/dest/*") ], + sources => [ sort map { s{.*/}{}r } glob("$root/src/*") ], + }; +} + sub deliver_tarball { my ($source_only) = @_; my $root = tempdir( CLEANUP => 1 ); @@ -172,6 +198,20 @@ is_deeply( $source_arch->{delivered}, ['xCAT-2-snap0.riscv64.rpm'], is_deeply( $source_arch->{sources}, ['xCAT-2.19.0-snap1.src.rpm'], 'a source-only architecture build delivers the new source package' ); +my $source_genesis = deliver_genesis('1'); +is( $source_genesis->{status}, 0, + 'source-only Genesis delivery exits cleanly' ); +is_deeply( $source_genesis->{delivered}, [], + 'source-only Genesis delivery publishes no binary packages' ); +is_deeply( + $source_genesis->{sources}, + [ + 'xCAT-genesis-scripts-ppc64-2.19.0-snap1.src.rpm', + 'xCAT-genesis-scripts-x86_64-2.19.0-snap1.src.rpm', + ], + 'source-only delivery preserves both architecture-specific Genesis SRPMs', +); + my $normal_tarball = deliver_tarball('0'); is( $normal_tarball->{status}, 0, 'normal tarball delivery exits cleanly' ); ok( $normal_tarball->{tarball}, 'a normal build creates the binary tarball' ); @@ -196,4 +236,26 @@ my $source_embed = deliver_embed_link('1'); is( $source_embed->{status}, 0, 'source-only embedded-link delivery exits cleanly' ); ok( !$source_embed->{link}, 'a source-only build creates no embedded-package link' ); +my ( $binary_arches, $binary_arches_status ) = run_helper( + tempdir( CLEANUP => 1 ), + 'binary-arches', + "SRCONLY=0\nxcat_rpm_build_arches x86_64 ppc64 ppc64le s390x aarch64\n", +); +is( $binary_arches_status, 0, 'normal architecture selection exits cleanly' ); +is( + $binary_arches, + "x86_64\nppc64\nppc64le\ns390x\naarch64\n", + 'a binary build keeps every target architecture', +); + +my ( $source_xcat_arches, $source_xcat_arches_status ) = run_helper( + tempdir( CLEANUP => 1 ), + 'source-arches', + "SRCONLY=true\nxcat_rpm_build_arches x86_64 ppc64 ppc64le s390x aarch64\n", +); +is( $source_xcat_arches_status, 0, + 'source architecture selection exits cleanly' ); +is( $source_xcat_arches, "x86_64\n", + 'a source-only xCAT or xCATsn build creates its target-independent SRPM once' ); + done_testing();