test runner: add options to check installation dir and print purpose
This commit is contained in:
committed by
Tamara Dahlgren
parent
cf4a0cbc01
commit
dfb02e6d45
@@ -1670,7 +1670,8 @@ def test_process():
|
||||
def test(self):
|
||||
pass
|
||||
|
||||
def run_test(self, exe, options=[], expected=[], status=None):
|
||||
def run_test(self, exe, options=[], expected=[], status=None,
|
||||
installed=False, purpose=''):
|
||||
"""Run the test and confirm obtain the expected results
|
||||
|
||||
Args:
|
||||
@@ -1679,11 +1680,22 @@ def run_test(self, exe, options=[], expected=[], status=None):
|
||||
expected (list of str): list of expected output strings
|
||||
status (int or None): the expected process status if int or None
|
||||
if the test is expected to succeed
|
||||
installed (bool): the executable should be in the install prefix
|
||||
purpose (str): message to display before running test
|
||||
"""
|
||||
result = 'fail with status {0}'.format(status) if status else 'succeed'
|
||||
tty.debug('test: {0}: expect to {1}'.format(exe, result))
|
||||
|
||||
if purpose:
|
||||
tty.msg(purpose)
|
||||
|
||||
runner = which(exe)
|
||||
assert runner is not None
|
||||
assert runner is not None, "Failed to find executable '%s'" % exe
|
||||
|
||||
if installed:
|
||||
msg = "Executable '%s' expected in prefix" % exe
|
||||
msg += ", found in %s instead" % runner.path
|
||||
assert self.spec.prefix in runner.path, msg
|
||||
|
||||
try:
|
||||
output = runner(*options, output=str.split, error=str.split)
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack import *
|
||||
|
||||
import os
|
||||
|
||||
import llnl.util.tty as tty
|
||||
|
||||
|
||||
class Patchelf(AutotoolsPackage):
|
||||
"""PatchELF is a small utility to modify the dynamic linker and RPATH of
|
||||
@@ -24,21 +20,20 @@ class Patchelf(AutotoolsPackage):
|
||||
version('0.8', sha256='14af06a2da688d577d64ff8dac065bb8903bbffbe01d30c62df7af9bf4ce72fe')
|
||||
|
||||
def test(self):
|
||||
patchelf = which('patchelf')
|
||||
assert patchelf is not None
|
||||
# Check patchelf in prefix and reports correct version
|
||||
purpose_str = 'test patchelf is in prefix and reports correct version'
|
||||
self.run_test('patchelf',
|
||||
options=['--version'],
|
||||
expected=['patchelf %s' % self.spec.version],
|
||||
installed=True,
|
||||
purpose=purpose_str)
|
||||
|
||||
tty.msg('test: Ensuring use of the installed executable')
|
||||
patchelf_dir = os.path.dirname(patchelf.path)
|
||||
assert patchelf_dir == self.prefix.bin
|
||||
|
||||
tty.msg('test: Checking version')
|
||||
output = patchelf('--version', output=str.split, error=str.split)
|
||||
assert output.strip() == 'patchelf {0}'.format(self.spec.version)
|
||||
|
||||
tty.msg('test: Ensuring the rpath is changed')
|
||||
# Check the rpath is changed
|
||||
currdir = os.getcwd()
|
||||
hello_file = os.path.join(currdir, 'data', 'hello')
|
||||
patchelf('--set-rpath', currdir, hello_file)
|
||||
output = patchelf('--print-rpath', hello_file,
|
||||
output=str.split, error=str.split)
|
||||
assert output.strip() == currdir
|
||||
self.run_test('patchelf', ['--set-rpath', currdir, hello_file],
|
||||
purpose='test that patchelf can change rpath')
|
||||
self.run_test('patchelf',
|
||||
options=['--print-rpath', hello_file],
|
||||
expected=[currdir],
|
||||
purpose='test that patchelf actually changed rpath')
|
||||
|
||||
Reference in New Issue
Block a user