Skip to content
Snippets Groups Projects
Commit 0a8bccaa authored by Lukasz Dorau's avatar Lukasz Dorau
Browse files

obj: add pool descriptor's unit tests

parent 993aeb71
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ TEST = blk_nblock\ ...@@ -44,6 +44,7 @@ TEST = blk_nblock\
log_basic\ log_basic\
log_recovery\ log_recovery\
log_walker\ log_walker\
obj_basic\
pmem_isa_proc\ pmem_isa_proc\
pmem_is_pmem\ pmem_is_pmem\
pmem_is_pmem_proc\ pmem_is_pmem_proc\
......
obj_basic
#
# Copyright (c) 2015, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# src/test/obj_basic/Makefile -- build obj_basic unit test
#
TARGET = obj_basic
OBJS = obj_basic.o
LIBPMEM=y
LIBPMEMOBJ=y
include ../Makefile.inc
obj_basic.o: obj_basic.c
Linux NVM Library
This is src/test/obj_basic/README.
This directory contains a unit test for:
- pmemobj_create
- pmemobj_open
The program in obj_basic.c takes a file name and an operation encoded
by a character as arguments. For example:
./obj_basic file1 c
The following characters and operations can be used:
c - pmemobj_create
o - pmemobj_open
#!/bin/bash -e
#
# Copyright (c) 2015, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# src/test/obj_basic/TEST0 -- unit test for pmemobj_create
#
export UNITTEST_NAME=obj_basic/TEST0
export UNITTEST_NUM=0
# standard unit test setup
. ../unittest/unittest.sh
setup
rm -f $DIR/testfile1
expect_normal_exit ./obj_basic$EXESUFFIX $DIR/testfile1 c
rm $DIR/testfile1
check
pass
#!/bin/bash -e
#
# Copyright (c) 2015, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# src/test/obj_basic/TEST1 -- unit test for:
# - pmemobj_create
# - pmemobj_open
#
export UNITTEST_NAME=obj_basic/TEST1
export UNITTEST_NUM=1
# standard unit test setup
. ../unittest/unittest.sh
setup
rm -f $DIR/testfile1
expect_normal_exit ./obj_basic$EXESUFFIX $DIR/testfile1 c
expect_normal_exit ./obj_basic$EXESUFFIX $DIR/testfile1 o
rm $DIR/testfile1
check
pass
/*
* Copyright (c) 2015, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* obj_basic.c -- unit test for pmemobj_create and pmemobj_open
*
* usage: obj_basic file operation:...
*
* operations are 'c' or 'o'
*
*/
#include "unittest.h"
#define LAYOUT_NAME "basic"
int
main(int argc, char *argv[])
{
START(argc, argv, "obj_basic");
if (argc != 3)
FATAL("usage: %s file-name op:c|o", argv[0]);
const char *path = argv[1];
PMEMobjpool *pop = NULL;
if (strchr("co", argv[2][0]) == NULL || argv[2][1] != '\0')
FATAL("op must be c or o");
switch (argv[2][0]) {
case 'c':
if ((pop = pmemobj_create(path, LAYOUT_NAME,
PMEMOBJ_MIN_POOL,
S_IRWXU)) == NULL)
FATAL("!pmemobj_create: %s", path);
break;
case 'o':
if ((pop = pmemobj_open(path, LAYOUT_NAME)) == NULL)
FATAL("!pmemobj_open: %s", path);
break;
}
pmemobj_close(pop);
DONE(NULL);
}
obj_basic/TEST0: START: obj_basic
./obj_basic$(nW) $(nW)/testfile1 c
obj_basic/TEST0: Done
obj_basic/TEST1: START: obj_basic
./obj_basic$(nW) $(nW)/testfile1 o
obj_basic/TEST1: Done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment