Skip to content

Commit 5fc5283

Browse files
committed
test: verify prealloc result to avoid skipping wrong function execution
Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
1 parent cb4ed17 commit 5fc5283

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
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/obj_pmalloc_mt.c

+8-3
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

0 commit comments

Comments
 (0)