From f5cae4f8fc4ef67ec5e26dffeb3b3c540949f554 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 25 Jan 2021 05:37:06 +0100 Subject: [PATCH] test: Add unit tests for architecture bijective mapping property The architectures need to have the bijective property when converting back and forth from the Debian arch name to the GNU triplet. Enforce this in the test suite to make it easier to guarantee this when adding new architectures to the tables. --- scripts/t/Dpkg_Arch.t | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t index a3a9e6fee..4f26778aa 100644 --- a/scripts/t/Dpkg_Arch.t +++ b/scripts/t/Dpkg_Arch.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 16836; +use Test::More tests => 17914; use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch debarch_eq debarch_is debarch_is_wildcard @@ -24,9 +24,12 @@ use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch debarch_to_abiattrs debarch_to_cpubits debarch_list_parse debtuple_to_debarch gnutriplet_to_debarch + debtuple_to_gnutriplet gnutriplet_to_debtuple get_host_gnu_type get_valid_arches)); +my @valid_arches = get_valid_arches(); + sub get_valid_wildcards { my %wildcards; @@ -37,7 +40,7 @@ sub get_valid_wildcards any-any-any-any ); - foreach my $archname (get_valid_arches()) { + foreach my $archname (@valid_arches) { my @tuple = debarch_to_debtuple($archname); my @wildcards_arch = ( @@ -174,7 +177,17 @@ is(gnutriplet_to_debarch(undef), undef, 'undef gnutriplet'); is(gnutriplet_to_debarch('unknown-unknown-unknown'), undef, 'unknown gnutriplet'); is(gnutriplet_to_debarch('x86_64-linux-gnu'), 'amd64', 'known gnutriplet'); -is(scalar get_valid_arches(), 539, 'expected amount of known architectures'); +foreach my $arch (@valid_arches) { + my @tuple = debarch_to_debtuple($arch); + is(debtuple_to_debarch(@tuple), $arch, + "bijective arch $arch to tuple @tuple"); + + my $triplet = debtuple_to_gnutriplet(@tuple); + is_deeply([ gnutriplet_to_debtuple($triplet) ], \@tuple, + "bijective triplet $triplet to tuple @tuple"); +} + +is(scalar @valid_arches, 539, 'expected amount of known architectures'); { local $ENV{CC} = 'false'; -- 2.30.1