binutils: convert to new stand-alone test process (#37690)

This commit is contained in:
Tamara Dahlgren 2023-05-29 02:59:09 -07:00 committed by GitHub
parent 37e95713f4
commit 9278c0df21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details. # Spack Project Developers. See the top-level COPYRIGHT file for details.
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import re import re
import spack.build_systems.autotools import spack.build_systems.autotools
@ -192,31 +193,36 @@ def flag_handler(self, name, flags):
iflags.append("-Wl,-z,notext") iflags.append("-Wl,-z,notext")
return (iflags, None, flags) return (iflags, None, flags)
def test(self): def test_binaries(self):
spec_vers = str(self.spec.version) binaries = [
"ar",
"c++filt",
"coffdump",
"dlltool",
"elfedit",
"gprof",
"ld",
"nm",
"objdump",
"ranlib",
"readelf",
"size",
"strings",
]
checks = { # Since versions can have mixed separator characters after the minor
"ar": spec_vers, # version, just check the first two components
"c++filt": spec_vers, version = str(self.spec.version.up_to(2))
"coffdump": spec_vers, for _bin in binaries:
"dlltool": spec_vers, reason = "checking version of {0} is {1}".format(_bin, version)
"elfedit": spec_vers, with test_part(self, "test_binaries_{0}".format(_bin), purpose=reason):
"gprof": spec_vers, installed_exe = join_path(self.prefix.bin, _bin)
"ld": spec_vers, if not os.path.exists(installed_exe):
"nm": spec_vers, raise SkipTest("{0} is not installed".format(_bin))
"objdump": spec_vers,
"ranlib": spec_vers,
"readelf": spec_vers,
"size": spec_vers,
"strings": spec_vers,
}
for exe in checks: exe = which(installed_exe)
expected = checks[exe] out = exe("--version", output=str.split, error=str.split)
reason = "test: ensuring version of {0} is {1}".format(exe, expected) assert version in out
self.run_test(
exe, "--version", expected, installed=True, purpose=reason, skip_missing=True
)
class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder): class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):