From 2fc7c140b229f9cc0c03b4869c2bbdf51d91c1cb Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Fri, 31 Mar 2023 09:52:12 -0400 Subject: [PATCH] test: verify prealloc result to avoid skipping wrong function execution prealloc might fail in case of pool reopen after transaction abort Signed-off-by: Tomasz Gromadzki --- src/test/obj_pmalloc_mt/TEST0 | 4 ++-- src/test/obj_pmalloc_mt/TEST1 | 4 ++-- src/test/obj_pmalloc_mt/TEST2 | 4 ++-- src/test/obj_pmalloc_mt/TEST3 | 4 ++-- src/test/obj_pmalloc_mt/TEST8 | 29 ++++++++++++++++++++++++ src/test/obj_pmalloc_mt/err8.log.match | 1 + src/test/obj_pmalloc_mt/obj_pmalloc_mt.c | 14 ++++++++---- utils/docker/run-build.sh | 2 +- 8 files changed, 49 insertions(+), 13 deletions(-) create mode 100755 src/test/obj_pmalloc_mt/TEST8 create mode 100644 src/test/obj_pmalloc_mt/err8.log.match diff --git a/src/test/obj_pmalloc_mt/TEST0 b/src/test/obj_pmalloc_mt/TEST0 index 6e77e951bd8..fd065e9193c 100755 --- a/src/test/obj_pmalloc_mt/TEST0 +++ b/src/test/obj_pmalloc_mt/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_pmalloc_mt/TEST0 -- multithreaded allocator test @@ -16,6 +16,6 @@ configure_valgrind helgrind force-enable setup PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ - ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile + ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile0 pass diff --git a/src/test/obj_pmalloc_mt/TEST1 b/src/test/obj_pmalloc_mt/TEST1 index 672a2e27136..9c55955adb9 100755 --- a/src/test/obj_pmalloc_mt/TEST1 +++ b/src/test/obj_pmalloc_mt/TEST1 @@ -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_pmalloc_mt/TEST1 -- multithreaded allocator test @@ -16,6 +16,6 @@ configure_valgrind helgrind force-disable setup PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ - ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile + ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile1 pass diff --git a/src/test/obj_pmalloc_mt/TEST2 b/src/test/obj_pmalloc_mt/TEST2 index 68fb8b4543b..2abd46e192a 100755 --- a/src/test/obj_pmalloc_mt/TEST2 +++ b/src/test/obj_pmalloc_mt/TEST2 @@ -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_pmalloc_mt/TEST2 -- multithreaded allocator test @@ -16,6 +16,6 @@ configure_valgrind helgrind force-enable setup PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ - ./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile + ./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile2 pass diff --git a/src/test/obj_pmalloc_mt/TEST3 b/src/test/obj_pmalloc_mt/TEST3 index b1fe2f4db84..7f230ae0e14 100755 --- a/src/test/obj_pmalloc_mt/TEST3 +++ b/src/test/obj_pmalloc_mt/TEST3 @@ -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_pmalloc_mt/TEST3 -- multithreaded allocator test @@ -16,6 +16,6 @@ configure_valgrind drd force-enable setup PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ - ./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile + ./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile3 pass diff --git a/src/test/obj_pmalloc_mt/TEST8 b/src/test/obj_pmalloc_mt/TEST8 new file mode 100755 index 00000000000..fc8a6ee3484 --- /dev/null +++ b/src/test/obj_pmalloc_mt/TEST8 @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2023, Intel Corporation + +# +# src/test/obj_pmalloc_mt/TEST8 -- multithreaded allocator test +# (short) w/ iterations +# + +. ../unittest/unittest.sh + +require_fs_type pmem +require_test_type short + +setup + +TEST_FILE_PATH=$DIR/testfile + +rm -f $TEST_FILE_PATH + +PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ + ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $TEST_FILE_PATH + +rm $TEST_FILE_PATH + +PMEM_IS_PMEM_FORCE=1 expect_normal_exit\ + ./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $TEST_FILE_PATH + +pass diff --git a/src/test/obj_pmalloc_mt/err8.log.match b/src/test/obj_pmalloc_mt/err8.log.match new file mode 100644 index 00000000000..27e8de85bb8 --- /dev/null +++ b/src/test/obj_pmalloc_mt/err8.log.match @@ -0,0 +1 @@ +{obj_pmalloc_mt.c:66 realloc_worker} obj_pmalloc_mt/TEST8: Error: assertion failure: ret (0xffffffffffffffff) == 0 (0x0) diff --git a/src/test/obj_pmalloc_mt/obj_pmalloc_mt.c b/src/test/obj_pmalloc_mt/obj_pmalloc_mt.c index c356d3a7c8c..4eca2f1844f 100644 --- a/src/test/obj_pmalloc_mt/obj_pmalloc_mt.c +++ b/src/test/obj_pmalloc_mt/obj_pmalloc_mt.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2015-2020, Intel Corporation */ +/* Copyright 2015-2023, Intel Corporation */ /* * obj_pmalloc_mt.c -- multithreaded test of allocator @@ -59,9 +59,12 @@ static void * realloc_worker(void *arg) { struct worker_args *a = arg; + int ret; for (unsigned i = 0; i < Ops_per_thread; ++i) { - prealloc(a->pop, &a->r->offs[a->idx][i], REALLOC_SIZE, 0, 0); + ret = prealloc(a->pop, &a->r->offs[a->idx][i], + REALLOC_SIZE, 0, 0); + UT_ASSERTeq(ret, 0); UT_ASSERTne(a->r->offs[a->idx][i], 0); } @@ -85,6 +88,7 @@ static void * mix_worker(void *arg) { struct worker_args *a = arg; + int ret; /* * The mix scenario is ran twice to increase the chances of run @@ -92,8 +96,9 @@ mix_worker(void *arg) */ for (unsigned j = 0; j < MIX_RERUNS; ++j) { for (unsigned i = 0; i < Ops_per_thread; ++i) { - pmalloc(a->pop, &a->r->offs[a->idx][i], + ret = pmalloc(a->pop, &a->r->offs[a->idx][i], ALLOC_SIZE, 0, 0); + UT_ASSERTeq(ret, 0); UT_ASSERTne(a->r->offs[a->idx][i], 0); } @@ -338,7 +343,8 @@ main(int argc, char *argv[]) if (!exists) { pop = pmemobj_create(argv[4], "TEST", (PMEMOBJ_MIN_POOL) + - (MAX_THREADS * CHUNKSIZE * CHUNKS_PER_THREAD), + (MAX_THREADS * CHUNKSIZE * CHUNKS_PER_THREAD) + + (MAX_THREADS * MAX_OPS_PER_THREAD * REALLOC_SIZE), 0666); if (pop == NULL) diff --git a/utils/docker/run-build.sh b/utils/docker/run-build.sh index 1426bb77d64..e846795798e 100755 --- a/utils/docker/run-build.sh +++ b/utils/docker/run-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2022, Intel Corporation +# Copyright 2016-2023, Intel Corporation # # run-build.sh - is called inside a Docker container; prepares the environment