Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ead7c69

Browse files
committedApr 3, 2023
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 <tomasz.gromadzki@intel.com>
1 parent 7e92273 commit ead7c69

File tree

8 files changed

+51
-15
lines changed

8 files changed

+51
-15
lines changed
 

‎src/test/obj_pmalloc_mt/TEST0

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2015-2019, Intel Corporation
3+
# Copyright 2015-2023, Intel Corporation
44

55
#
66
# src/test/obj_pmalloc_mt/TEST0 -- multithreaded allocator test
@@ -16,6 +16,6 @@ configure_valgrind helgrind force-enable
1616
setup
1717

1818
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
19-
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile
19+
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile0
2020

2121
pass

‎src/test/obj_pmalloc_mt/TEST1

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2016-2019, Intel Corporation
3+
# Copyright 2016-2023, Intel Corporation
44

55
#
66
# src/test/obj_pmalloc_mt/TEST1 -- multithreaded allocator test
@@ -16,6 +16,6 @@ configure_valgrind helgrind force-disable
1616
setup
1717

1818
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
19-
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile
19+
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $DIR/testfile1
2020

2121
pass

‎src/test/obj_pmalloc_mt/TEST2

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2015-2019, Intel Corporation
3+
# Copyright 2015-2023, Intel Corporation
44

55
#
66
# src/test/obj_pmalloc_mt/TEST2 -- multithreaded allocator test
@@ -16,6 +16,6 @@ configure_valgrind helgrind force-enable
1616
setup
1717

1818
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
19-
./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile
19+
./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile2
2020

2121
pass

‎src/test/obj_pmalloc_mt/TEST3

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2015-2019, Intel Corporation
3+
# Copyright 2015-2023, Intel Corporation
44

55
#
66
# src/test/obj_pmalloc_mt/TEST3 -- multithreaded allocator test
@@ -16,6 +16,6 @@ configure_valgrind drd force-enable
1616
setup
1717

1818
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
19-
./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile
19+
./obj_pmalloc_mt$EXESUFFIX 4 64 4 $DIR/testfile3
2020

2121
pass

‎src/test/obj_pmalloc_mt/TEST8

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# Copyright 2023, Intel Corporation
4+
5+
#
6+
# src/test/obj_pmalloc_mt/TEST8 -- multithreaded allocator test
7+
# (short) w/ iterations
8+
#
9+
10+
. ../unittest/unittest.sh
11+
12+
require_fs_type pmem
13+
require_test_type short
14+
15+
setup
16+
17+
TEST_FILE_PATH=$DIR/testfile
18+
19+
rm -f $TEST_FILE_PATH
20+
21+
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
22+
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $TEST_FILE_PATH
23+
24+
rm $TEST_FILE_PATH
25+
26+
PMEM_IS_PMEM_FORCE=1 expect_normal_exit\
27+
./obj_pmalloc_mt$EXESUFFIX 32 1000 100 $TEST_FILE_PATH
28+
29+
pass
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{obj_pmalloc_mt.c:66 realloc_worker} obj_pmalloc_mt/TEST8: Error: assertion failure: ret (0xffffffffffffffff) == 0 (0x0)

‎src/test/obj_pmalloc_mt/obj_pmalloc_mt.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2015-2020, Intel Corporation */
2+
/* Copyright 2015-2023, Intel Corporation */
33

44
/*
55
* obj_pmalloc_mt.c -- multithreaded test of allocator
@@ -59,9 +59,12 @@ static void *
5959
realloc_worker(void *arg)
6060
{
6161
struct worker_args *a = arg;
62+
int ret;
6263

6364
for (unsigned i = 0; i < Ops_per_thread; ++i) {
64-
prealloc(a->pop, &a->r->offs[a->idx][i], REALLOC_SIZE, 0, 0);
65+
ret = prealloc(a->pop, &a->r->offs[a->idx][i],
66+
REALLOC_SIZE, 0, 0);
67+
UT_ASSERTeq(ret, 0);
6568
UT_ASSERTne(a->r->offs[a->idx][i], 0);
6669
}
6770

@@ -85,15 +88,17 @@ static void *
8588
mix_worker(void *arg)
8689
{
8790
struct worker_args *a = arg;
91+
int ret;
8892

8993
/*
9094
* The mix scenario is ran twice to increase the chances of run
9195
* contention.
9296
*/
9397
for (unsigned j = 0; j < MIX_RERUNS; ++j) {
9498
for (unsigned i = 0; i < Ops_per_thread; ++i) {
95-
pmalloc(a->pop, &a->r->offs[a->idx][i],
99+
ret = pmalloc(a->pop, &a->r->offs[a->idx][i],
96100
ALLOC_SIZE, 0, 0);
101+
UT_ASSERTeq(ret, 0);
97102
UT_ASSERTne(a->r->offs[a->idx][i], 0);
98103
}
99104

@@ -338,7 +343,8 @@ main(int argc, char *argv[])
338343

339344
if (!exists) {
340345
pop = pmemobj_create(argv[4], "TEST", (PMEMOBJ_MIN_POOL) +
341-
(MAX_THREADS * CHUNKSIZE * CHUNKS_PER_THREAD),
346+
(MAX_THREADS * CHUNKSIZE * CHUNKS_PER_THREAD) +
347+
(MAX_THREADS * MAX_OPS_PER_THREAD * REALLOC_SIZE),
342348
0666);
343349

344350
if (pop == NULL)

‎utils/docker/run-build.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# SPDX-License-Identifier: BSD-3-Clause
3-
# Copyright 2016-2022, Intel Corporation
3+
# Copyright 2016-2023, Intel Corporation
44

55
#
66
# run-build.sh - is called inside a Docker container; prepares the environment
@@ -27,11 +27,11 @@ make -j$(nproc) test
2727
echo ""
2828
echo "## Running make pcheck"
2929
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
30-
make -j2 pcheck TEST_BUILD=$TEST_BUILD
30+
make -j1 pcheck TEST_BUILD=$TEST_BUILD
3131
echo ""
3232
echo "## Running make pycheck"
3333
# do not change -j2 to -j$(nproc) in case of tests (make check/pycheck)
34-
make -j2 pycheck
34+
make -j1 pycheck
3535
echo ""
3636
echo "## Running make source"
3737
make -j$(nproc) DESTDIR=/tmp source

0 commit comments

Comments
 (0)
Please sign in to comment.