Skip to content

Commit

Permalink
test: introduce fault_injection test label (Bash)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Michalski <jan.michalski@intel.com>
  • Loading branch information
janekmi committed Jul 25, 2023
1 parent 0a39bd9 commit 2afe530
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 14 deletions.
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_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/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
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 2afe530

Please sign in to comment.