Skip to content

Commit

Permalink
Merge pull request #5821 from janekmi/test-label
Browse files Browse the repository at this point in the history
test: introduce fault_injection test label
  • Loading branch information
janekmi committed Jul 26, 2023
2 parents 0a39bd9 + 4ceb80b commit 242fec6
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/test/RUNTESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/test/obj_bucket/TEST0
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/test/obj_critnib/TESTS.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')
3 changes: 2 additions & 1 deletion src/test/obj_heap/TEST1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection

setup

Expand Down
3 changes: 2 additions & 1 deletion src/test/obj_lane/TEST0
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection

setup

Expand Down
3 changes: 2 additions & 1 deletion src/test/obj_pool/TEST20
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection

setup
umask 0
Expand Down
1 change: 1 addition & 0 deletions src/test/obj_tx_flow/TEST0
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/test/obj_tx_lock/TEST0
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -10,6 +10,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection

configure_valgrind drd force-disable

Expand Down
3 changes: 2 additions & 1 deletion src/test/pmem2_config/TESTS.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!../env.py
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2020, Intel Corporation
# Copyright 2019-2023, Intel Corporation
#


Expand Down Expand Up @@ -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"


Expand Down
1 change: 1 addition & 0 deletions src/test/pmem2_map_from_existing/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
1 change: 1 addition & 0 deletions src/test/pmem2_source/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
2 changes: 2 additions & 0 deletions src/test/pmem2_vm_reservation/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
3 changes: 2 additions & 1 deletion src/test/pmem_is_pmem_posix/TEST0
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection
require_fs_type none
require_dax_devices 1

Expand Down
3 changes: 2 additions & 1 deletion src/test/pmem_is_pmem_posix/TEST4
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection
require_fs_type none
require_dax_devices 1

Expand Down
3 changes: 2 additions & 1 deletion src/test/pmem_is_pmem_posix/TEST5
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection
require_fs_type none
require_dax_devices 1

Expand Down
3 changes: 3 additions & 0 deletions src/test/scope/TESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
1 change: 1 addition & 0 deletions src/test/unittest/basetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BaseTest(metaclass=_TestCase):
"""
enabled = True
force_disabled = False
labels = []

def __init__(self):
self.ctx = None
Expand Down
3 changes: 3 additions & 0 deletions src/test/unittest/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down
27 changes: 27 additions & 0 deletions src/test/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion src/test/util_badblock/TEST11
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/test/util_ctl/TEST0
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/test/util_ctl/TEST1
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/test/util_poolset/TEST4
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection
require_fs_type any

setup
Expand Down
3 changes: 2 additions & 1 deletion src/test/util_poolset_parse/TEST5
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,7 @@
. ../unittest/unittest.sh

require_test_type medium
set_test_labels fault_injection
require_build_type debug
require_fs_type any

Expand Down
3 changes: 2 additions & 1 deletion src/test/util_ravl/TEST0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2020, Intel Corporation
# Copyright 2018-2023, Intel Corporation
#

#
Expand All @@ -10,6 +10,7 @@
. ../unittest/unittest.sh

require_fs_type none
set_test_labels fault_injection
require_test_type medium

setup
Expand Down

0 comments on commit 242fec6

Please sign in to comment.