Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,26 @@ def skip_if(self, cond, msg=None):
if cond:
self.skip(msg)

def skip_if_no_procinfo(self, msg=None):
'''Skip test if no processor topology information is available.

This method has effect only if called after the ``setup`` stage.

:arg msg: A message explaining why the test was skipped.
If not specified, a default message will be used.

.. versionadded:: 3.9.1
'''
if not self.current_partition:
return

proc = self.current_partition.processor
pname = self.current_partition.fullname
if msg is None:
msg = f'no topology information found for partition {pname!r}'

self.skip_if(not proc.info, msg)

def __str__(self):
return "%s(name='%s', prefix='%s')" % (type(self).__name__,
self.name, self.prefix)
Expand Down
34 changes: 33 additions & 1 deletion unittests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from reframe.core.containers import _STAGEDIR_MOUNT
from reframe.core.exceptions import (BuildError, PipelineError, ReframeError,
PerformanceError, SanityError,
ReframeSyntaxError)
SkipTestError, ReframeSyntaxError)


def _run(test, partition, prgenv):
Expand Down Expand Up @@ -1455,3 +1455,35 @@ def test_not_configured_container_platform(container_test, local_exec_ctx):

with pytest.raises(PipelineError):
_run(container_test(platform, 'ubuntu:18.04'), *local_exec_ctx)


def test_skip_if_no_topo(HelloTest, local_exec_ctx):
class MyTest(HelloTest):
skip_message = variable(str, type(None), value=None)

@run_after('setup')
def access_topo(self):
self.skip_if_no_procinfo(self.skip_message)

class EchoTest(rfm.RunOnlyRegressionTest):
valid_systems = ['*']
valid_prog_environs = ['*']
executable = 'echo'
sanity_patterns = sn.assert_true(1)

@run_before('setup')
def access_topo(self):
self.skip_if_no_procinfo()

# The test should be skipped, because the auto-detection has not run
t = MyTest()
with pytest.raises(SkipTestError, match='no topology.*information'):
_run(t, *local_exec_ctx)

# Re-run to test that the custom message is used
t.skip_message = 'custom message'
with pytest.raises(SkipTestError, match='custom message'):
_run(t, *local_exec_ctx)

# This test should run to completion without problems
_run(EchoTest(), *local_exec_ctx)