From 2afe530932e820f690ba06a9a4e2e3fa4766649c Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 25 Jul 2023 08:47:28 -0400 Subject: [PATCH 1/2] test: introduce fault_injection test label (Bash) Signed-off-by: Jan Michalski --- src/test/obj_bucket/TEST0 | 3 ++- src/test/obj_heap/TEST1 | 3 ++- src/test/obj_lane/TEST0 | 3 ++- src/test/obj_pool/TEST20 | 3 ++- src/test/obj_tx_flow/TEST0 | 1 + src/test/obj_tx_lock/TEST0 | 3 ++- src/test/pmem_is_pmem_posix/TEST0 | 3 ++- src/test/pmem_is_pmem_posix/TEST4 | 3 ++- src/test/pmem_is_pmem_posix/TEST5 | 3 ++- src/test/unittest/unittest.sh | 27 +++++++++++++++++++++++++++ src/test/util_badblock/TEST11 | 3 ++- src/test/util_ctl/TEST0 | 3 ++- src/test/util_ctl/TEST1 | 3 ++- src/test/util_poolset/TEST4 | 3 ++- src/test/util_poolset_parse/TEST5 | 3 ++- src/test/util_ravl/TEST0 | 3 ++- 16 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/test/obj_bucket/TEST0 b/src/test/obj_bucket/TEST0 index 942d48efa63..819aaefd58a 100755 --- a/src/test/obj_bucket/TEST0 +++ b/src/test/obj_bucket/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2015-2019, Intel Corporation +# Copyright 2015-2023, Intel Corporation # # src/test/obj_bucket/TEST0 -- unit test for obj_bucket interface @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection # this is a volatile state test configure_valgrind pmemcheck force-disable diff --git a/src/test/obj_heap/TEST1 b/src/test/obj_heap/TEST1 index daba3673a80..63d07b12f09 100755 --- a/src/test/obj_heap/TEST1 +++ b/src/test/obj_heap/TEST1 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2019, Intel Corporation +# Copyright 2019-2023, Intel Corporation # # src/test/obj_heap/TEST1 -- unit test for inject fault malloc @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection setup diff --git a/src/test/obj_lane/TEST0 b/src/test/obj_lane/TEST0 index 6725ec6b676..73416659ce3 100755 --- a/src/test/obj_lane/TEST0 +++ b/src/test/obj_lane/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2015-2019, Intel Corporation +# Copyright 2015-2023, Intel Corporation # # src/test/obj_lane/TEST0 -- single thread unit test for lanes @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection setup diff --git a/src/test/obj_pool/TEST20 b/src/test/obj_pool/TEST20 index ab6ce1f66fa..b96614043da 100755 --- a/src/test/obj_pool/TEST20 +++ b/src/test/obj_pool/TEST20 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2015-2019, Intel Corporation +# Copyright 2015-2023, Intel Corporation # # src/test/obj_pool/TEST20 -- unit test for pmemobj_open @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection setup umask 0 diff --git a/src/test/obj_tx_flow/TEST0 b/src/test/obj_tx_flow/TEST0 index 0e3606d4d16..863380dc3dd 100755 --- a/src/test/obj_tx_flow/TEST0 +++ b/src/test/obj_tx_flow/TEST0 @@ -10,6 +10,7 @@ # this test verifies the correctness of the tx management functions only require_test_type medium +set_test_labels fault_injection configure_valgrind pmemcheck force-disable diff --git a/src/test/obj_tx_lock/TEST0 b/src/test/obj_tx_lock/TEST0 index d1d39191055..d25d5bd8d5f 100755 --- a/src/test/obj_tx_lock/TEST0 +++ b/src/test/obj_tx_lock/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2019, Intel Corporation +# Copyright 2016-2023, Intel Corporation # # src/test/obj_tx_lock/TEST0 -- unit test for pmemobj_tx_lock() @@ -10,6 +10,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection configure_valgrind drd force-disable diff --git a/src/test/pmem_is_pmem_posix/TEST0 b/src/test/pmem_is_pmem_posix/TEST0 index 8502fda888b..b4938e8f51c 100755 --- a/src/test/pmem_is_pmem_posix/TEST0 +++ b/src/test/pmem_is_pmem_posix/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2020, Intel Corporation +# Copyright 2016-2023, Intel Corporation # # src/test/pmem_is_pmem_posix/TEST0 -- unit test for pmem_is_pmem @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_fs_type none require_dax_devices 1 diff --git a/src/test/pmem_is_pmem_posix/TEST4 b/src/test/pmem_is_pmem_posix/TEST4 index c2a760decce..51572a64e4c 100755 --- a/src/test/pmem_is_pmem_posix/TEST4 +++ b/src/test/pmem_is_pmem_posix/TEST4 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2014-2020, Intel Corporation +# Copyright 2014-2023, Intel Corporation # # src/test/pmem_is_pmem_posix/TEST4 -- unit test for pmem_is_pmem @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_fs_type none require_dax_devices 1 diff --git a/src/test/pmem_is_pmem_posix/TEST5 b/src/test/pmem_is_pmem_posix/TEST5 index 7ab0abb6aa2..0d95e9782be 100755 --- a/src/test/pmem_is_pmem_posix/TEST5 +++ b/src/test/pmem_is_pmem_posix/TEST5 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2019-2020, Intel Corporation +# Copyright 2019-2023, Intel Corporation # # src/test/pmem_is_pmem_posix/TEST5 -- unit test for pmem_is_pmem @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_fs_type none require_dax_devices 1 diff --git a/src/test/unittest/unittest.sh b/src/test/unittest/unittest.sh index 500ddf4d0e5..d6b6e8502db 100644 --- a/src/test/unittest/unittest.sh +++ b/src/test/unittest/unittest.sh @@ -121,6 +121,7 @@ fi [ "$CHECK_TYPE" ] || CHECK_TYPE=auto [ "$CHECK_POOL" ] || CHECK_POOL=0 [ "$VERBOSE" ] || VERBOSE=0 +[ "$TEST_LABEL" ] || TEST_LABEL= [ -n "${SUFFIX+x}" ] || SUFFIX="😘⠏⠍⠙⠅ɗPMDKӜ⥺🙋" export UNITTEST_LOG_LEVEL GREP TEST FS BUILD CHECK_TYPE CHECK_POOL VERBOSE SUFFIX @@ -1788,6 +1789,15 @@ function setup() { fatal "error: required test type is not specified" fi + # if no label is set + if [ "$set_test_labels_done" != "1" ]; then + # but some label is required then the test is skipped + if [ "$TEST_LABEL" ]; then + verbose_msg "$UNITTEST_NAME: SKIP test-label $TEST_LABEL required" + exit 0 + fi + fi + # fs type "none" must be explicitly enabled if [ "$FS" = "none" -a "$req_fs_type" != "1" ]; then exit 0 @@ -2543,3 +2553,20 @@ function turn_on_checking_bad_blocks() expect_normal_exit "$PMEMPOOL feature -e CHECK_BAD_BLOCKS $FILE &>> $PREP_LOG_FILE" } + +# +# set_test_labels -- if a certain label is required the test will be run only if +# it is marked with the required label +# +function set_test_labels() { + set_test_labels_done=1 + # no label has been required + [ "$TEST_LABEL" == "" ] && return + # a label has been required + for label in $* + do + [ "$label" == "$TEST_LABEL" ] && return + done + verbose_msg "$UNITTEST_NAME: SKIP test-labels: $* ($TEST_LABEL required)" + exit 0 +} diff --git a/src/test/util_badblock/TEST11 b/src/test/util_badblock/TEST11 index 5b9c20b9f68..3b8fd004bd9 100755 --- a/src/test/util_badblock/TEST11 +++ b/src/test/util_badblock/TEST11 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2019, Intel Corporation +# Copyright 2019-2023, Intel Corporation # # src/test/util_badblock/TEST11 -- unit test for inject error malloc @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_fs_type non-pmem require_linked_with_ndctl ./util_badblock$EXESUFFIX diff --git a/src/test/util_ctl/TEST0 b/src/test/util_ctl/TEST0 index e70dafc4360..f721eea18ce 100755 --- a/src/test/util_ctl/TEST0 +++ b/src/test/util_ctl/TEST0 @@ -1,10 +1,11 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2019, Intel Corporation +# Copyright 2016-2023, Intel Corporation . ../unittest/unittest.sh require_test_type short +set_test_labels fault_injection setup diff --git a/src/test/util_ctl/TEST1 b/src/test/util_ctl/TEST1 index 464cee7b565..9df1d2a6bda 100755 --- a/src/test/util_ctl/TEST1 +++ b/src/test/util_ctl/TEST1 @@ -1,10 +1,11 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2019, Intel Corporation +# Copyright 2016-2023, Intel Corporation . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection configure_valgrind memcheck force-enable diff --git a/src/test/util_poolset/TEST4 b/src/test/util_poolset/TEST4 index 314fe4a86ed..e204b53d932 100755 --- a/src/test/util_poolset/TEST4 +++ b/src/test/util_poolset/TEST4 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2017-2019, Intel Corporation +# Copyright 2017-2023, Intel Corporation # # src/test/util_poolset/TEST4 -- unit test for util_pool_open() @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_fs_type any setup diff --git a/src/test/util_poolset_parse/TEST5 b/src/test/util_poolset_parse/TEST5 index 760559116b6..cf60648b570 100755 --- a/src/test/util_poolset_parse/TEST5 +++ b/src/test/util_poolset_parse/TEST5 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2019, Intel Corporation +# Copyright 2019-2023, Intel Corporation # # src/test/util_poolset_parse/TEST5 -- unit test for inject error malloc @@ -9,6 +9,7 @@ . ../unittest/unittest.sh require_test_type medium +set_test_labels fault_injection require_build_type debug require_fs_type any diff --git a/src/test/util_ravl/TEST0 b/src/test/util_ravl/TEST0 index e79e4cb283a..3b026aae34e 100755 --- a/src/test/util_ravl/TEST0 +++ b/src/test/util_ravl/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018-2020, Intel Corporation +# Copyright 2018-2023, Intel Corporation # # @@ -10,6 +10,7 @@ . ../unittest/unittest.sh require_fs_type none +set_test_labels fault_injection require_test_type medium setup From 4ceb80bde06417b9b2969b5e8627c807bc965dc0 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 25 Jul 2023 11:35:30 -0400 Subject: [PATCH 2/2] test: introduce fault_injection test label (Python) Signed-off-by: Jan Michalski --- src/test/RUNTESTS.py | 4 ++++ src/test/obj_critnib/TESTS.py | 3 ++- src/test/pmem2_config/TESTS.py | 3 ++- src/test/pmem2_map_from_existing/TESTS.py | 1 + src/test/pmem2_source/TESTS.py | 1 + src/test/pmem2_vm_reservation/TESTS.py | 2 ++ src/test/scope/TESTS.py | 3 +++ src/test/unittest/basetest.py | 1 + src/test/unittest/configurator.py | 3 +++ 9 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/test/RUNTESTS.py b/src/test/RUNTESTS.py index d73202423f5..da27e155918 100755 --- a/src/test/RUNTESTS.py +++ b/src/test/RUNTESTS.py @@ -90,6 +90,10 @@ def run_tests(self): if tc.test_type not in self.config.test_type: continue + if self.config.test_label != '' and \ + self.config.test_label not in tc.labels: + continue + if not tc.enabled: continue diff --git a/src/test/obj_critnib/TESTS.py b/src/test/obj_critnib/TESTS.py index 35872d57931..f9fd3f46a47 100755 --- a/src/test/obj_critnib/TESTS.py +++ b/src/test/obj_critnib/TESTS.py @@ -1,6 +1,6 @@ #!../env.py # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2020, Intel Corporation +# Copyright 2020-2023, Intel Corporation # import testframework as t @@ -10,6 +10,7 @@ @g.no_testdir() class TEST0(t.Test): test_type = t.Medium + labels = ['fault_injection'] def run(self, ctx): ctx.exec('obj_critnib') diff --git a/src/test/pmem2_config/TESTS.py b/src/test/pmem2_config/TESTS.py index b2878a44772..35354a954b8 100755 --- a/src/test/pmem2_config/TESTS.py +++ b/src/test/pmem2_config/TESTS.py @@ -1,6 +1,6 @@ #!../env.py # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2019-2020, Intel Corporation +# Copyright 2019-2023, Intel Corporation # @@ -32,6 +32,7 @@ class TEST0(Pmem2ConfigNoDir): class TEST1(Pmem2ConfigNoDir): """allocation of pmem2_config in case of missing memory in system""" + labels = ['fault_injection'] test_case = "test_alloc_cfg_enomem" diff --git a/src/test/pmem2_map_from_existing/TESTS.py b/src/test/pmem2_map_from_existing/TESTS.py index ab8044bbca2..d7f54c1bf89 100644 --- a/src/test/pmem2_map_from_existing/TESTS.py +++ b/src/test/pmem2_map_from_existing/TESTS.py @@ -34,6 +34,7 @@ class TEST2(Pmem2_from_existing): class TEST3(Pmem2_from_existing): """inject enomem in to allocation of map object""" + labels = ['fault_injection'] test_case = "test_map_allocation_enomem" diff --git a/src/test/pmem2_source/TESTS.py b/src/test/pmem2_source/TESTS.py index 675b187776c..e40b306cc31 100755 --- a/src/test/pmem2_source/TESTS.py +++ b/src/test/pmem2_source/TESTS.py @@ -55,6 +55,7 @@ class TEST3(PMEM2_SOURCE): class TEST4(PMEM2_SOURCE): """allocation of pmem2_source in case of missing memory in system""" + labels = ['fault_injection'] test_case = "test_alloc_src_enomem" diff --git a/src/test/pmem2_vm_reservation/TESTS.py b/src/test/pmem2_vm_reservation/TESTS.py index bb38c027b9e..57dca6771e7 100755 --- a/src/test/pmem2_vm_reservation/TESTS.py +++ b/src/test/pmem2_vm_reservation/TESTS.py @@ -167,11 +167,13 @@ class TEST13(PMEM2_VM_RESERVATION_DEVDAX): class TEST14(PMEM2_VM_RESERVATION): """create a vm reservation with with error injection""" + labels = ['fault_injection'] test_case = "test_vm_reserv_new_alloc_enomem" class TEST15(PMEM2_VM_RESERVATION_DEVDAX): """DevDax create a vm reservation with with error injection""" + labels = ['fault_injection'] test_case = "test_vm_reserv_new_alloc_enomem" diff --git a/src/test/scope/TESTS.py b/src/test/scope/TESTS.py index 42974f0e49c..bdd66f70775 100755 --- a/src/test/scope/TESTS.py +++ b/src/test/scope/TESTS.py @@ -76,16 +76,19 @@ def run(self, ctx): class TEST2(Common): """Check scope of libpmem library (*nix)""" + labels = ['fault_injection'] checked_lib = 'libpmem' class TEST5(Common): """Check scope of libpmemobj library (*nix)""" + labels = ['fault_injection'] checked_lib = 'libpmemobj' class TEST6(Common): """Check scope of libpmempool library (*nix)""" + labels = ['fault_injection'] checked_lib = 'libpmempool' diff --git a/src/test/unittest/basetest.py b/src/test/unittest/basetest.py index d96d1cd6fbe..da514e73abd 100644 --- a/src/test/unittest/basetest.py +++ b/src/test/unittest/basetest.py @@ -150,6 +150,7 @@ class BaseTest(metaclass=_TestCase): """ enabled = True force_disabled = False + labels = [] def __init__(self): self.ctx = None diff --git a/src/test/unittest/configurator.py b/src/test/unittest/configurator.py index 9df0a8c470a..cad2fecbf25 100644 --- a/src/test/unittest/configurator.py +++ b/src/test/unittest/configurator.py @@ -273,6 +273,9 @@ def ctx_choices(cls): parser.add_argument('--fail-on-skip', dest='fail_on_skip', action='store_const', const=True, help='Skipping tests also fail') + parser.add_argument('--test-label', dest='test_label', default='', + action='store', + help='Run only tests marked with the label') tracers = parser.add_mutually_exclusive_group() tracers.add_argument('--tracer', dest='tracer', help='run C binary '