From 46867a45d28ecb667d08df8d8cb497fffc10814d Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 1 Feb 2018 09:54:56 +0000 Subject: [PATCH] [device/bcache] stub a unit test --- include/.symlinks.in | 1 + lib/device/bcache.h | 1 + test/unit/Makefile.in | 3 ++- test/unit/bcache_t.c | 38 ++++++++++++++++++++++++++++++++++++++ test/unit/run.c | 1 + test/unit/units.h | 1 + 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/unit/bcache_t.c diff --git a/include/.symlinks.in b/include/.symlinks.in index a1b5c1e05..3d5075058 100644 --- a/include/.symlinks.in +++ b/include/.symlinks.in @@ -14,6 +14,7 @@ @top_srcdir@/lib/config/defaults.h @top_srcdir@/lib/datastruct/btree.h @top_srcdir@/lib/datastruct/str_list.h +@top_srcdir@/lib/device/bcache.h @top_srcdir@/lib/device/dev-cache.h @top_srcdir@/lib/device/dev-ext-udev-constants.h @top_srcdir@/lib/device/dev-type.h diff --git a/lib/device/bcache.h b/lib/device/bcache.h index 322774469..0747b5ac5 100644 --- a/lib/device/bcache.h +++ b/lib/device/bcache.h @@ -16,6 +16,7 @@ #define BCACHE_H #include +#include #include "libdevmapper.h" diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in index 3de30f2e7..8127ec006 100644 --- a/test/unit/Makefile.in +++ b/test/unit/Makefile.in @@ -16,6 +16,7 @@ top_builddir = @top_builddir@ VPATH = $(srcdir) UNITS = \ + bcache_t.c \ bitset_t.c\ config_t.c\ dmlist_t.c\ @@ -37,7 +38,7 @@ SOURCES = $(UNITS) endif ifeq ("$(TESTING)", "yes") -LDLIBS += -ldevmapper @CUNIT_LIBS@ +LDLIBS += $(LVMINTERNAL_LIBS) -ldevmapper -laio @CUNIT_LIBS@ CFLAGS += @CUNIT_CFLAGS@ check: unit diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c new file mode 100644 index 000000000..da274a9d9 --- /dev/null +++ b/test/unit/bcache_t.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2018 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "units.h" +#include "bcache.h" + +int bcache_init(void) +{ + return 0; +} + +int bcache_fini(void) +{ + return 0; +} + +static void test_create(void) +{ + struct bcache *cache = bcache_create(8, 16); + CU_ASSERT_PTR_NOT_NULL(cache); + bcache_destroy(cache); +} + +CU_TestInfo bcache_list[] = { + { (char*)"create", test_create }, + CU_TEST_INFO_NULL +}; diff --git a/test/unit/run.c b/test/unit/run.c index 7372138d5..82090ba55 100644 --- a/test/unit/run.c +++ b/test/unit/run.c @@ -13,6 +13,7 @@ .pTests = n##_list } CU_SuiteInfo suites[] = { + USE(bcache), USE(bitset), USE(config), USE(dmlist), diff --git a/test/unit/units.h b/test/unit/units.h index 9eaa82f25..319e7ceb9 100644 --- a/test/unit/units.h +++ b/test/unit/units.h @@ -23,6 +23,7 @@ int n ## _init(void); \ int n ## _fini(void); +DECL(bcache); DECL(bitset); DECL(config); DECL(dmlist);