Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: verify prealloc result to avoid skipping wrong function execution #5568

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions src/test/obj_pmalloc_mt/obj_pmalloc_mt.c
Original file line number Diff line number Diff line change
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