diff --git a/src/test/RUNTESTS.py b/src/test/RUNTESTS.py index ed7ee26dc01..d73202423f5 100755 --- a/src/test/RUNTESTS.py +++ b/src/test/RUNTESTS.py @@ -106,9 +106,13 @@ def run_tests(self): try: t = tc() if t.enabled: - self.msg.print('{}: SETUP\t({}/{})' - .format(t, t.test_type, c)) - t._execute(c) + if t.force_disabled: + self._test_disabled(t, c) + continue + else: + self.msg.print('{}: SETUP\t({}/{})' + .format(t, t.test_type, c)) + t._execute(c) else: continue @@ -153,6 +157,12 @@ def _test_passed(self, tc): self.msg.print('{}: {}PASS{} {}' .format(tc, futils.Color.GREEN, futils.Color.END, tm)) + def _test_disabled(self, tc, context): + """Print message specific for disabled test""" + self.msg.print('{}: {}DISABLED{}\t({}/{})' + .format(tc, futils.Color.YELLOW, futils.Color.END, + tc.test_type, context)) + def _import_testfiles(): """ diff --git a/src/test/pmem2_badblock/TESTS.py b/src/test/pmem2_badblock/TESTS.py index 6c3839f870a..d342f5a05d7 100755 --- a/src/test/pmem2_badblock/TESTS.py +++ b/src/test/pmem2_badblock/TESTS.py @@ -68,7 +68,8 @@ def run_test(self, ctx, filepath): # XXX - https://github.com/pmem/pmdk/issues/5636 -class DISABLE_TEST0(PMEM2_BADBLOCK_COUNT): +@t.DISABLED() +class TEST0(PMEM2_BADBLOCK_COUNT): """ compares the number of bad blocks returned by pmem2 and ndctl on fsdax """ @@ -80,8 +81,9 @@ def run(self, ctx): # XXX - https://github.com/pmem/pmdk/issues/5636 +@t.DISABLED() @t.require_devdax(t.DevDax('devdax1')) -class DISABLE_TEST1(PMEM2_BADBLOCK_COUNT): +class TEST1(PMEM2_BADBLOCK_COUNT): """ compares the number of bad blocks returned by pmem2 and ndctl on devdax """ @@ -93,7 +95,8 @@ def run(self, ctx): # XXX - https://github.com/pmem/pmdk/issues/5636 -class DISABLE_TEST2(PMEM2_BADBLOCK): +@t.DISABLED() +class TEST2(PMEM2_BADBLOCK): """test mcsafe read operation with encountered badblock""" test_case = "test_pmem2_src_mcsafe_badblock_read" @@ -103,7 +106,8 @@ def run(self, ctx): # XXX - https://github.com/pmem/pmdk/issues/5636 -class DISABLE_TEST3(PMEM2_BADBLOCK): +@t.DISABLED() +class TEST3(PMEM2_BADBLOCK): """test mcsafe write operation with encountered badblock""" test_case = "test_pmem2_src_mcsafe_badblock_write" @@ -113,8 +117,9 @@ def run(self, ctx): # XXX - https://github.com/pmem/pmdk/issues/5636 +@t.DISABLED() @t.require_devdax(t.DevDax('devdax1')) -class DISABLE_TEST4(PMEM2_BADBLOCK): +class TEST4(PMEM2_BADBLOCK): """test mcsafe read operation with encountered badblock on devdax""" test_case = "test_pmem2_src_mcsafe_badblock_read" @@ -124,8 +129,9 @@ def run(self, ctx): # XXX - https://github.com/pmem/pmdk/issues/5636 +@t.DISABLED() @t.require_devdax(t.DevDax('devdax1')) -class DISABLE_TEST5(PMEM2_BADBLOCK): +class TEST5(PMEM2_BADBLOCK): """test mcsafe write operation with encountered badblock on devdax""" test_case = "test_pmem2_src_mcsafe_badblock_write" diff --git a/src/test/unittest/basetest.py b/src/test/unittest/basetest.py index a9727728731..d96d1cd6fbe 100644 --- a/src/test/unittest/basetest.py +++ b/src/test/unittest/basetest.py @@ -143,9 +143,13 @@ class BaseTest(metaclass=_TestCase): Attributes: enabled (bool): True if test is meant to be executed, False otherwise. Defaults to True. + force_disabled (bool): True if the test is explicitle excluded from + execution e.g. in case the test fails permanently. + Defaults to False. ctx (Context): context affiliated with the test """ enabled = True + force_disabled = False def __init__(self): self.ctx = None diff --git a/src/test/unittest/futils.py b/src/test/unittest/futils.py index d79f9e6c95a..9630b42b5e7 100644 --- a/src/test/unittest/futils.py +++ b/src/test/unittest/futils.py @@ -79,6 +79,7 @@ class Color: """ RED = '\33[91m' GREEN = '\33[92m' + YELLOW = '\33[93m' END = '\33[0m' diff --git a/src/test/unittest/utils.py b/src/test/unittest/utils.py index b43400ab64a..3c792a6e545 100644 --- a/src/test/unittest/utils.py +++ b/src/test/unittest/utils.py @@ -23,3 +23,16 @@ def wrapped(tc): return tc return wrapped + + +def DISABLED(**kwargs): + """ + DISABLE a given test. + + Used as a test class (tc) decorator. + """ + + def wrapped(tc): + tc.force_disabled = True + + return wrapped