diff --git a/xCAT-test/unit/debian_arch_map.t b/xCAT-test/unit/debian_arch_map.t index 08c140cec..a98df8224 100644 --- a/xCAT-test/unit/debian_arch_map.t +++ b/xCAT-test/unit/debian_arch_map.t @@ -16,6 +16,11 @@ use xCAT::Utils; # --- what debootstrap and the package lists are given ---------------------- is(xCAT::Utils->debian_arch('x86_64'), 'amd64', 'Debian calls x86_64 amd64'); +# genimage passes this value to debootstrap --arch and reads it to pick the apt mirror, and +# debootstrap knows i386, not xCAT's x86. +is(xCAT::Utils->debian_arch('x86'), 'i386', + 'debian_arch: the 32-bit x86 token becomes i386'); + is(xCAT::Utils->debian_arch('ppc64el'), 'ppc64el', 'the Debian name for POWER LE is unchanged'); is(xCAT::Utils->debian_arch('ppc64le'), 'ppc64le', diff --git a/xCAT-test/unit/ubuntu_genimage_apt_mirror.t b/xCAT-test/unit/ubuntu_genimage_apt_mirror.t index 172ab8b47..c3ad36a43 100644 --- a/xCAT-test/unit/ubuntu_genimage_apt_mirror.t +++ b/xCAT-test/unit/ubuntu_genimage_apt_mirror.t @@ -14,6 +14,8 @@ use Test::More; # evaluated here, so this test tracks the script rather than a copy of it. my $repo_root = File::Spec->rel2abs( File::Spec->catdir( $FindBin::Bin, '..', '..' ) ); +use lib "$FindBin::Bin/../../perl-xCAT"; +require xCAT::Utils; my $genimage_path = File::Spec->catfile( $repo_root, 'xCAT-server', 'share', 'xcat', 'netboot', 'ubuntu', 'genimage' ); @@ -29,6 +31,14 @@ my ($pick) = $src =~ /^\s*(my \$mirror = \(defined \$aptmirror\[0\].*?;)\s*$/ms; ok( defined $pick, 'found the mirror override in genimage' ) or done_testing(), exit; +# genimage does not read osimage.osarch directly: it converts it first, so the value the selection +# sees is whatever xCAT::Utils::debian_arch returns. Driving the xCAT token through that conversion +# is what catches a token the map does not know. +sub choose_osarch { + my ( $osarch, $site ) = @_; + return choose( xCAT::Utils->debian_arch($osarch), $site ); +} + sub choose { my ( $uarch, $site ) = @_; my $set = defined $site ? "('$site')" : "()"; @@ -57,4 +67,14 @@ is( choose( 'amd64', 'http://mirror.example.invalid/ubuntu' ), is( choose( 'riscv64', '' ), 'http://ports.ubuntu.com/ubuntu-ports', 'an empty site.ubuntu_apt_mirror does not blank the mirror' ); +# The architecture reaches the selection as an xCAT osarch value, not as a Debian one. +is( choose_osarch('x86_64'), 'http://archive.ubuntu.com/ubuntu', + 'osarch x86_64 reaches the archive' ); +is( choose_osarch('x86'), 'http://archive.ubuntu.com/ubuntu', + 'osarch x86 reaches the archive, which is where i386 lives' ); +is( choose_osarch('riscv64'), 'http://ports.ubuntu.com/ubuntu-ports', + 'osarch riscv64 reaches the ports archive' ); +is( choose_osarch('ppc64el'), 'http://ports.ubuntu.com/ubuntu-ports', + 'osarch ppc64el reaches the ports archive' ); + done_testing();