Skip to content

Commit

Permalink
test: verify prealloc result to avoid skipping wrong function execution
Browse files Browse the repository at this point in the history
prealloc might fail in case of pool reopen after transaction abort

Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Apr 3, 2023
1 parent 7e92273 commit 880f9f8
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/test/obj_pmalloc_mt/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_pmalloc_mt/TEST0 -- multithreaded allocator test
Expand All @@ -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
4 changes: 2 additions & 2 deletions src/test/obj_pmalloc_mt/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 2016-2019, Intel Corporation
# Copyright 2016-2023, Intel Corporation

#
# src/test/obj_pmalloc_mt/TEST1 -- multithreaded allocator test
Expand All @@ -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
4 changes: 2 additions & 2 deletions src/test/obj_pmalloc_mt/TEST2
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_pmalloc_mt/TEST2 -- multithreaded allocator test
Expand All @@ -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
4 changes: 2 additions & 2 deletions src/test/obj_pmalloc_mt/TEST3
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_pmalloc_mt/TEST3 -- multithreaded allocator test
Expand All @@ -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
29 changes: 29 additions & 0 deletions src/test/obj_pmalloc_mt/TEST8
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 2023, Intel Corporation

#
# src/test/obj_pmalloc_mt/TEST8 -- multithreaded allocator test
# (long - several iteration) w/ statistics
#

. ../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
1 change: 1 addition & 0 deletions src/test/obj_pmalloc_mt/err8.log.match
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{obj_pmalloc_mt.c:66 realloc_worker} obj_pmalloc_mt/TEST8: Error: assertion failure: ret (0xffffffffffffffff) == 0 (0x0)
14 changes: 10 additions & 4 deletions src/test/obj_pmalloc_mt/obj_pmalloc_mt.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}

Expand All @@ -85,15 +88,17 @@ 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
* contention.
*/
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);
}

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions utils/docker/run-build.sh
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-2022, Intel Corporation
# Copyright 2016-2023, Intel Corporation

#
# run-build.sh - is called inside a Docker container; prepares the environment
Expand All @@ -27,11 +27,11 @@ make -j$(nproc) test
echo ""
echo "## Running make pcheck"
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pcheck TEST_BUILD=$TEST_BUILD
make -j1 pcheck TEST_BUILD=$TEST_BUILD
echo ""
echo "## Running make pycheck"
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
make -j2 pycheck
make -j1 pycheck
echo ""
echo "## Running make source"
make -j$(nproc) DESTDIR=/tmp source
Expand Down

0 comments on commit 880f9f8

Please sign in to comment.