diff --git a/src/test/Makefile b/src/test/Makefile index 77f3ea4ba2b877c0555c801386b5caa00c678593..4c2eeb1d953c06c0dd920e141fa1271d1293e33a 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -44,6 +44,7 @@ TEST = blk_nblock\ log_basic\ log_recovery\ log_walker\ + obj_basic\ pmem_isa_proc\ pmem_is_pmem\ pmem_is_pmem_proc\ diff --git a/src/test/obj_basic/.gitignore b/src/test/obj_basic/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..cb670a5a3933bebc7bbbd37c19d31da26441573a --- /dev/null +++ b/src/test/obj_basic/.gitignore @@ -0,0 +1 @@ +obj_basic diff --git a/src/test/obj_basic/Makefile b/src/test/obj_basic/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f4db53311c6ff1e21c54e8ee748619e956b0996c --- /dev/null +++ b/src/test/obj_basic/Makefile @@ -0,0 +1,44 @@ +# +# 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 diff --git a/src/test/obj_basic/README b/src/test/obj_basic/README new file mode 100644 index 0000000000000000000000000000000000000000..c65a9fb15536b97cc2b19323b974b0f32c5681a8 --- /dev/null +++ b/src/test/obj_basic/README @@ -0,0 +1,16 @@ +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 diff --git a/src/test/obj_basic/TEST0 b/src/test/obj_basic/TEST0 new file mode 100755 index 0000000000000000000000000000000000000000..132fa2f879845936632391ee8885b1930a491bdc --- /dev/null +++ b/src/test/obj_basic/TEST0 @@ -0,0 +1,53 @@ +#!/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 diff --git a/src/test/obj_basic/TEST1 b/src/test/obj_basic/TEST1 new file mode 100755 index 0000000000000000000000000000000000000000..242d18a2c3226ef7d0d65ba11607c9b20b532d6e --- /dev/null +++ b/src/test/obj_basic/TEST1 @@ -0,0 +1,56 @@ +#!/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 diff --git a/src/test/obj_basic/obj_basic.c b/src/test/obj_basic/obj_basic.c new file mode 100644 index 0000000000000000000000000000000000000000..d83b7c1c48e37fb5b98d5238b67846dd34ad2c96 --- /dev/null +++ b/src/test/obj_basic/obj_basic.c @@ -0,0 +1,77 @@ +/* + * 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); +} diff --git a/src/test/obj_basic/out0.log.match b/src/test/obj_basic/out0.log.match new file mode 100644 index 0000000000000000000000000000000000000000..5527da1206326ff9a3247ee6d3f1993a9e0e48a6 --- /dev/null +++ b/src/test/obj_basic/out0.log.match @@ -0,0 +1,3 @@ +obj_basic/TEST0: START: obj_basic + ./obj_basic$(nW) $(nW)/testfile1 c +obj_basic/TEST0: Done diff --git a/src/test/obj_basic/out1.log.match b/src/test/obj_basic/out1.log.match new file mode 100644 index 0000000000000000000000000000000000000000..2e024169b7b3750bb0a9ac20bffc1fae0ce403bc --- /dev/null +++ b/src/test/obj_basic/out1.log.match @@ -0,0 +1,3 @@ +obj_basic/TEST1: START: obj_basic + ./obj_basic$(nW) $(nW)/testfile1 o +obj_basic/TEST1: Done