-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: introduce a test reproducing the #5583
Ref: #5583 Signed-off-by: Jan Michalski <[email protected]>
- Loading branch information
Showing
13 changed files
with
701 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj_ulog_advanced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
|
||
# | ||
# src/test/obj_ulog_advanced/Makefile -- build obj_ulog_advanced test | ||
# | ||
TARGET = obj_ulog_advanced | ||
OBJS = obj_ulog_advanced.o | ||
|
||
BUILD_STATIC_DEBUG=n | ||
BUILD_STATIC_NONDEBUG=n | ||
|
||
# required for proper mock integration | ||
LIBPMEMOBJ=internal-debug | ||
|
||
include ../Makefile.inc | ||
LDFLAGS += $(call extract_funcs, obj_ulog_advanced.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
|
||
# | ||
# src/test/obj_ulog_advanced/TEST0 -- a kick-start test | ||
# | ||
# Since this directory contains both Bash-based and Python-based tests and match | ||
# files are used by some of them both groups cannot have overlapping numbering. | ||
# Hence the real Bash-based tests' numbering starts where the Python-based tests' | ||
# numbering ends. However, the Bash-based test framework relies on the existence | ||
# of this TEST0 file to keep looking for other Bash-based tests. | ||
# | ||
|
||
. ../unittest/unittest.sh | ||
|
||
. ./common.sh | ||
|
||
require_fs_type any | ||
require_build_type $COMMON_BUILD_TYPE | ||
require_test_type short | ||
|
||
setup | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
|
||
# | ||
# src/test/obj_ulog_advanced/TEST8 -- a test employing pmreorder WITHOUT error | ||
# injection | ||
# | ||
# Please see the source code for the details of the tested scenario. | ||
# | ||
|
||
. ../unittest/unittest.sh | ||
|
||
. ./common.sh | ||
|
||
common_require | ||
|
||
setup | ||
|
||
ERROR_INJECT=0 # an error is NOT being injected | ||
common_setup $ERROR_INJECT | ||
|
||
common_init | ||
common_record | ||
common_replay_and_check $ERROR_INJECT | ||
|
||
check | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
|
||
# | ||
# src/test/obj_ulog_advanced/TEST9 -- a test employing pmreorder WITH error | ||
# injection | ||
# | ||
# Please see the source code for the details of the tested scenario. | ||
# | ||
|
||
. ../unittest/unittest.sh | ||
|
||
. ./common.sh | ||
|
||
common_require | ||
|
||
setup | ||
|
||
ERROR_INJECT=1 # an error is being injected | ||
common_setup $ERROR_INJECT | ||
|
||
common_init | ||
common_record | ||
common_replay_and_check $ERROR_INJECT | ||
|
||
check | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!../env.py | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
# | ||
|
||
|
||
import testframework as t | ||
from testframework import granularity as g | ||
from os import path | ||
|
||
|
||
SIGABRT_EXIT_CODE = 134 | ||
|
||
|
||
@g.require_granularity(g.ANY) | ||
# The 'debug' build is chosen arbitrarily to ensure these tests are run only | ||
# once. No dynamic libraries are used nor .static_* builds are available. | ||
@t.require_build('debug') | ||
class OBJ_ULOG_ADVANCED(t.Test): | ||
test_type = t.Short | ||
test_case = 'test_init_publish_abort_and_verify' | ||
error_inject = False | ||
|
||
def run(self, ctx): | ||
testfile = path.join(ctx.testdir, f'testfile{self.testnum}') | ||
stderr_file = f'err{self.testnum}.log' | ||
error_inject = 1 if self.error_inject else 0 | ||
# The verify will abort the process when the injected error will be | ||
# discovered. | ||
expected_exitcode = SIGABRT_EXIT_CODE if self.error_inject else 0 | ||
ctx.exec('obj_ulog_advanced', self.test_case, testfile, self.slot_num, | ||
error_inject, expected_exitcode=expected_exitcode, | ||
stderr_file=stderr_file) | ||
|
||
|
||
class TEST0(OBJ_ULOG_ADVANCED): | ||
# The number of slots not fully populating a single persistent redo log. | ||
# Please see the source code for details. | ||
slot_num = 30 | ||
|
||
|
||
class TEST1(OBJ_ULOG_ADVANCED): | ||
# The number of slots exactly populating a single persistent redo log. | ||
# Please see the source code for details. | ||
slot_num = 40 | ||
|
||
|
||
class TEST2(OBJ_ULOG_ADVANCED): | ||
# The number of slots between the one used by TEST1 and TEST3. | ||
slot_num = 50 | ||
|
||
|
||
class TEST3(OBJ_ULOG_ADVANCED): | ||
# The number of slots exactly populating a persistent shadow log without | ||
# triggering its growth. Please see the source code for details. | ||
slot_num = 60 | ||
|
||
|
||
class TEST4(OBJ_ULOG_ADVANCED): | ||
# The number of slots populating more than a single persistent redo log. | ||
# It should trigger a persistent shadow log growth. | ||
# Please see the source code for details. | ||
slot_num = 70 | ||
|
||
|
||
# Note: Since the injected error value translates to 40 slots and it ought to | ||
# be smaller than the number of populated slots, the error injection only takes | ||
# effect when the number of populated slots is > 40. | ||
|
||
class TEST5(TEST2): | ||
# For details on the injected error please see the source code. | ||
error_inject = True | ||
|
||
|
||
class TEST6(TEST3): | ||
# For details on the injected error please see the source code. | ||
error_inject = True | ||
|
||
|
||
class TEST7(TEST4): | ||
# For details on the injected error please see the source code. | ||
error_inject = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024, Intel Corporation | ||
|
||
# | ||
# src/test/obj_ulog_advanced/common.sh -- common bits and pieces | ||
# | ||
|
||
# The 'debug' build is chosen arbitrarily to ensure these tests are run only | ||
# once. No dynamic libraries are used nor .static_* builds are available. | ||
COMMON_BUILD_TYPE=debug | ||
|
||
function common_require() { | ||
require_fs_type any | ||
require_build_type $COMMON_BUILD_TYPE | ||
require_test_type medium | ||
require_pmemcheck_version_ge 1 0 | ||
require_pmemcheck_version_lt 2 0 | ||
require_pmreorder | ||
} | ||
|
||
function common_setup() { | ||
ERROR_INJECT=$1 | ||
|
||
export PMEMOBJ_LOG_LEVEL=10 | ||
|
||
BIN="./obj_ulog_advanced$EXESUFFIX" | ||
TESTFILE=$DIR/testfile | ||
ERR_LOG_FILE=err$UNITTEST_NUM.log | ||
# This value was labourly calculated. Please see the source file for | ||
# details. | ||
SLOTS_NUM=60 | ||
PMEMCHECK_CMD="$BIN test_publish $TESTFILE $SLOTS_NUM $ERROR_INJECT" | ||
PMREORDER_CMD="$BIN test_verify $SLOTS_NUM" | ||
} | ||
|
||
function common_init() { | ||
expect_normal_exit $BIN test_init $TESTFILE | ||
} | ||
|
||
function common_record() { | ||
pmreorder_create_store_log $TESTFILE "$PMEMCHECK_CMD" | ||
} | ||
|
||
function common_replay_and_check() { | ||
ERROR_INJECT=$1 | ||
|
||
# skip reordering and checking stores outside of the markers | ||
DEFAULT_ENGINE=NoReorderNoCheck | ||
# The accumulative reordering is sufficient considering the nature of | ||
# the scenario at hand where the key risk is that not all stores | ||
# will be executed. The order of these stores is irrelevant. | ||
# Please see the source code for the details of the tested scenario. | ||
# Note: ReorderFull is too time-consuming for this scenario. | ||
EXTENDED_MACROS="PMREORDER_PUBLISH=ReorderAccumulative" | ||
|
||
if [ $ERROR_INJECT -eq 0 ]; then | ||
pmreorder_expect_success $DEFAULT_ENGINE "$EXTENDED_MACROS" "$PMREORDER_CMD" | ||
else | ||
pmreorder_expect_failure $DEFAULT_ENGINE "$EXTENDED_MACROS" "$PMREORDER_CMD" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{$(nW).c:$(N) verify} obj_ulog_advanced/TEST$(N): Error: assertion failure: rootp->slots[i] (0x0) == exp (0x1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{$(nW).c:$(N) verify} obj_ulog_advanced/TEST$(N): Error: assertion failure: rootp->slots[i] (0x0) == exp (0x1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{$(nW).c:$(N) verify} obj_ulog_advanced/TEST$(N): Error: assertion failure: rootp->slots[i] (0x0) == exp (0x1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{$(nW).c:$(N) verify} obj_ulog_advanced/TEST$(N): Error: assertion failure: rootp->slots[i] (0x0) == exp (0x1) |
Oops, something went wrong.