Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ OBJ_TESTS = \
obj_memcheck\
obj_memcheck_register\
obj_memops\
obj_ndctl_bb\
obj_ndctl_sds\
obj_oid_thread\
obj_out_of_memory\
obj_persist_count\
Expand Down
1 change: 1 addition & 0 deletions src/test/obj_ndctl_bb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj_ndctl_bb
10 changes: 10 additions & 0 deletions src/test/obj_ndctl_bb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP

TARGET = obj_ndctl_bb
OBJS = obj_ndctl_bb.o

LIBPMEMOBJ=internal-debug

include ../Makefile.inc
LDFLAGS += $(call extract_funcs, obj_ndctl_bb.c)
30 changes: 30 additions & 0 deletions src/test/obj_ndctl_bb/TEST0
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP
#
#
# obj_ndctl_bb/TEST0 -- check if the badblocks-related code is not run when no PMem is in use.
# DAOS-18296
#

. ../unittest/unittest.sh

require_fs_type non-pmem
require_ndctl_enable
require_test_type short

setup

FILE=$DIR/testfile

# obj_ndctl_bb commands
CREATE=c
OPEN=o

expect_normal_exit obj_ndctl_bb $FILE $CREATE

expect_normal_exit obj_ndctl_bb $FILE $OPEN

check

pass
39 changes: 39 additions & 0 deletions src/test/obj_ndctl_bb/TEST1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP
#
#
# obj_ndctl_bb/TEST1 -- check if the executable works as intended. Sanity check.
#

. ../unittest/unittest.sh

require_real_pmem
require_ndctl_enable
require_test_type short

setup

TMP=tmp${UNITTEST_NUM}.log
rm -f $TMP

FILE=$DIR/testfile

# obj_ndctl_bb commands
CREATE=c
OPEN=o

expect_abnormal_exit obj_ndctl_bb $FILE $CREATE
cat $ERR_LOG_FILE >> $TMP

expect_normal_exit $PMEMPOOL$EXESUFFIX create obj $FILE

expect_abnormal_exit obj_ndctl_bb $FILE $OPEN
cat $ERR_LOG_FILE >> $TMP

# move combined error log in place
mv $TMP $ERR_LOG_FILE

check

pass
2 changes: 2 additions & 0 deletions src/test/obj_ndctl_bb/err1.log.match
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{obj_ndctl_bb.c:$(N) __wrap_badblocks_check_poolset} obj_ndctl_bb/TEST1: Error: assertion failure: 0
{obj_ndctl_bb.c:$(N) __wrap_badblocks_recovery_file_exists} obj_ndctl_bb/TEST1: Error: assertion failure: 0
60 changes: 60 additions & 0 deletions src/test/obj_ndctl_bb/obj_ndctl_bb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2026, Hewlett Packard Enterprise Development LP */

/*
* obj_ndctl_bb.c -- crashes whenever badblocks-related code is run
*/

#include <libpmemobj.h>

#include "set.h"

#include "unittest.h"

FUNC_MOCK(badblocks_recovery_file_exists, int, struct pool_set *set)
FUNC_MOCK_RUN_DEFAULT {
UT_ASSERT(0);
}
FUNC_MOCK_END

FUNC_MOCK(badblocks_check_poolset, int, struct pool_set *set, int create)
FUNC_MOCK_RUN_DEFAULT {
UT_ASSERT(0);
}
FUNC_MOCK_END

int
main(int argc, char *argv[])
{
START(argc, argv, "obj_ndctl_bb");
if (argc < 3) {
UT_FATAL("usage: %s <path> <c|o>\nc - create\no - open",
argv[0]);
}

const char *path = argv[1];
const char *cmd = argv[2];
PMEMobjpool *pop;

if (strlen(cmd) != 1) {
UT_FATAL("unknown command: %s", cmd);
}

switch (cmd[0]) {
case 'c':
pop = pmemobj_create(path, NULL, PMEMOBJ_MIN_POOL,
0600);
break;
case 'o':
pop = pmemobj_open(path, NULL);
break;
default:
UT_FATAL("unknown command: %s", cmd);
}

UT_ASSERTne(pop, NULL);

pmemobj_close(pop);

DONE(NULL);
}
1 change: 1 addition & 0 deletions src/test/obj_ndctl_sds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj_ndctl_sds
10 changes: 10 additions & 0 deletions src/test/obj_ndctl_sds/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP

TARGET = obj_ndctl_sds
OBJS = obj_ndctl_sds.o

LIBPMEMOBJ=internal-debug

include ../Makefile.inc
LDFLAGS += $(call extract_funcs, obj_ndctl_sds.c)
30 changes: 30 additions & 0 deletions src/test/obj_ndctl_sds/TEST0
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP
#
#
# obj_ndctl_sds/TEST0 -- check if the shutdown-state-related code is not run when no PMem is in use.
# DAOS-18296
#

. ../unittest/unittest.sh

require_fs_type non-pmem
require_ndctl_enable
require_test_type short

setup

FILE=$DIR/testfile

# obj_ndctl_sds commands
CREATE=c
OPEN=o

expect_normal_exit obj_ndctl_sds $FILE $CREATE

expect_normal_exit obj_ndctl_sds $FILE $OPEN

check

pass
41 changes: 41 additions & 0 deletions src/test/obj_ndctl_sds/TEST1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2026, Hewlett Packard Enterprise Development LP
#
#
# obj_ndctl_sds/TEST1 -- check if the executable works as intended. Sanity check.
#

. ../unittest/unittest.sh

require_real_pmem
require_ndctl_enable
require_test_type short

setup

TMP=tmp${UNITTEST_NUM}.log
rm -f $TMP

FILE=$DIR/testfile

# obj_ndctl_sds commands
CREATE=c
OPEN=o

expect_abnormal_exit obj_ndctl_sds $FILE $CREATE
cat $ERR_LOG_FILE >> $TMP

# The crashed process leaves $FILE in a half-baked state. Let's do it right.
rm -f $FILE
expect_normal_exit $PMEMPOOL$EXESUFFIX create obj $FILE

expect_abnormal_exit obj_ndctl_sds $FILE $OPEN
cat $ERR_LOG_FILE >> $TMP

# move combined error log in place
mv $TMP $ERR_LOG_FILE

check

pass
2 changes: 2 additions & 0 deletions src/test/obj_ndctl_sds/err1.log.match
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{obj_ndctl_sds.c:$(N) __wrap_shutdown_state_init} obj_ndctl_sds/TEST1: Error: assertion failure: 0
{obj_ndctl_sds.c:$(N) __wrap_shutdown_state_init} obj_ndctl_sds/TEST1: Error: assertion failure: 0
69 changes: 69 additions & 0 deletions src/test/obj_ndctl_sds/obj_ndctl_sds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2026, Hewlett Packard Enterprise Development LP */

/*
* obj_ndctl_sds.c -- crashes whenever shutdown-state-related code is run
*/

#include <libpmemobj.h>

#include "set.h"

#include "unittest.h"

FUNC_MOCK(shutdown_state_init, int, struct shutdown_state *sds,
struct pool_replica *rep)
FUNC_MOCK_RUN_DEFAULT {
UT_ASSERT(0);
}
FUNC_MOCK_END

FUNC_MOCK(shutdown_state_set_dirty, void, struct shutdown_state *sds,
struct pool_replica *rep)
FUNC_MOCK_RUN_DEFAULT {
UT_ASSERT(0);
}
FUNC_MOCK_END

FUNC_MOCK(shutdown_state_check, int, struct shutdown_state *curr_sds,
struct shutdown_state *pool_sds, struct pool_replica *rep)
FUNC_MOCK_RUN_DEFAULT {
UT_ASSERT(0);
}
FUNC_MOCK_END

int
main(int argc, char *argv[])
{
START(argc, argv, "obj_ndctl_sds");
if (argc < 3) {
UT_FATAL("usage: %s <path> <c|o>\nc - create\no - open",
argv[0]);
}

const char *path = argv[1];
const char *cmd = argv[2];
PMEMobjpool *pop;

if (strlen(cmd) != 1) {
UT_FATAL("unknown command: %s", cmd);
}

switch (cmd[0]) {
case 'c':
pop = pmemobj_create(path, NULL, PMEMOBJ_MIN_POOL,
0600);
break;
case 'o':
pop = pmemobj_open(path, NULL);
break;
default:
UT_FATAL("unknown command: %s", cmd);
}

UT_ASSERTne(pop, NULL);

pmemobj_close(pop);

DONE(NULL);
}
Loading