[SV 62173] Fix archive tests for non-GNU systems

Original patch from Dmitry Goncharov <dgoncharov@users.sf.net>

Fix the ar flags to match the default values in make.  If the
U option is supported, add it to the end not the beginning,
since ARFLAGS now starts with a "-".

* tests/test_driver.pl: Add defaults for global variables.
(get_osname): Preserve $osname if it's set from $^O
* tests/scripts/features/archive: Set the default arflags.
If "U" is available add it to the end of the flags.
This commit is contained in:
Paul Smith 2022-04-23 16:30:02 -04:00
parent 9755d4c09c
commit 88ceff8b2f
2 changed files with 12 additions and 10 deletions

View file

@ -35,16 +35,17 @@ my $ar = get_config('AR') || 'ar';
my $redir = '2>&1';
$redir = '' if $osname eq 'VMS';
my $arflags = 'rv';
# This is the value from src/default.c
my $arflags = $ostype eq 'aix' ? '-Xany -rv' : '-rv';
my $arvar = "AR=$ar";
# Newer versions of binutils can be built with --enable-deterministic-archives
# which forces all timestamps (among other things) to always be 0, defeating
# GNU make's archive support. See if ar supports the U option to disable it.
unlink('libxx.a');
$_ = `$ar U$arflags libxx.a a1.o $redir`;
$_ = `$ar ${arflags}U libxx.a a1.o $redir`;
if ($? == 0) {
$arflags = 'Urv';
$arflags = "${arflags}U";
$arvar = "$arvar ARFLAGS=$arflags";
}

View file

@ -47,6 +47,10 @@ $tests_run = 0;
# The number of tests in this category that have passed
$tests_passed = 0;
$port_type = undef;
$osname = undef;
$vos = undef;
$pathsep = undef;
# Yeesh. This whole test environment is such a hack!
$test_passed = 1;
@ -331,6 +335,8 @@ sub get_osname
{
# Set up an initial value. In perl5 we can do it the easy way.
$osname = defined($^O) ? $^O : '';
$vos = 0;
$pathsep = "/";
# find the type of the port. We do this up front to have a single
# point of change if it needs to be tweaked.
@ -366,10 +372,7 @@ sub get_osname
$port_type = 'UNIX';
}
if ($osname eq 'VMS')
{
$vos = 0;
$pathsep = "/";
if ($osname eq 'VMS') {
return;
}
@ -399,7 +402,7 @@ sub get_osname
$vos = 1;
$pathsep = ">";
} else {
} elsif ($osname eq '') {
# the following is regrettably gnarly, but it seems to be the only way
# to not get ugly error messages if uname can't be found.
# Hmmm, BSD/OS 2.0's uname -a is excessively verbose. Let's try it
@ -414,8 +417,6 @@ sub get_osname
$osname = "(something posixy)";
}
}
$vos = 0;
$pathsep = "/";
}
if (! $short_filenames) {