test: add unit test framework for bdev.c
No actual tests in this patch - just getting the framework in place including necessary stub functions to get the bdev.c unit test file to link. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ic54001de814740a2049c7bbc6846d98c5a62a8b3 Reviewed-on: https://review.gerrithub.io/367625 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
ff88449d6e
commit
4ee51dcbc7
@ -149,6 +149,12 @@ spdk_mempool_put(struct spdk_mempool *mp, void *ele)
|
||||
free(ele);
|
||||
}
|
||||
|
||||
size_t
|
||||
spdk_mempool_count(const struct spdk_mempool *mp)
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
|
||||
bool
|
||||
spdk_process_is_primary(void)
|
||||
{
|
||||
@ -223,3 +229,9 @@ spdk_pci_addr_fmt(char *bdf, size_t sz, const struct spdk_pci_addr *addr)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_env_get_core_count(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
DIRS-y = scsi_nvme.c
|
||||
DIRS-y = bdev.c scsi_nvme.c
|
||||
|
||||
.PHONY: all clean $(DIRS-y)
|
||||
|
||||
|
1
test/unit/lib/bdev/bdev.c/.gitignore
vendored
Normal file
1
test/unit/lib/bdev/bdev.c/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
bdev_ut
|
55
test/unit/lib/bdev/bdev.c/Makefile
Normal file
55
test/unit/lib/bdev/bdev.c/Makefile
Normal file
@ -0,0 +1,55 @@
|
||||
#
|
||||
# BSD LICENSE
|
||||
#
|
||||
# Copyright (c) 2016 FUJITSU LIMITED, All rights reserved.
|
||||
#
|
||||
# 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 the copyright holder 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.
|
||||
#
|
||||
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
|
||||
|
||||
SPDK_LIB_LIST = log cunit
|
||||
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/test
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/bdev
|
||||
LIBS += $(SPDK_LIB_LINKER_ARGS)
|
||||
LIBS += -lcunit
|
||||
|
||||
APP = bdev_ut
|
||||
C_SRCS = bdev_ut.c
|
||||
|
||||
all: $(APP)
|
||||
|
||||
$(APP): $(OBJS) $(SPDK_LIB_FILES)
|
||||
$(LINK_C)
|
||||
|
||||
clean:
|
||||
$(CLEAN_C) $(APP)
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
|
135
test/unit/lib/bdev/bdev.c/bdev_ut.c
Normal file
135
test/unit/lib/bdev/bdev.c/bdev_ut.c
Normal file
@ -0,0 +1,135 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "spdk_cunit.h"
|
||||
|
||||
#include "lib/test_env.c"
|
||||
#include "bdev.c"
|
||||
|
||||
void *
|
||||
spdk_io_channel_get_ctx(struct spdk_io_channel *ch)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb,
|
||||
spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
spdk_io_device_unregister(void *io_device)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
spdk_thread_send_msg(const struct spdk_thread *thread, spdk_thread_fn fn, void *ctx)
|
||||
{
|
||||
}
|
||||
|
||||
struct spdk_io_channel *
|
||||
spdk_get_io_channel(void *io_device)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_put_io_channel(struct spdk_io_channel *ch)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx,
|
||||
spdk_channel_for_each_cpl cpl)
|
||||
{
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
spdk_io_channel_get_thread(struct spdk_io_channel *ch)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io,
|
||||
int *sc, int *sk, int *asc, int *ascq)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
null_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
null_clean(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_test(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
unsigned int num_failures;
|
||||
|
||||
if (CU_initialize_registry() != CUE_SUCCESS) {
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
suite = CU_add_suite("bdev", null_init, null_clean);
|
||||
if (suite == NULL) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (
|
||||
CU_add_test(suite, "bdev", bdev_test) == NULL
|
||||
) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
num_failures = CU_get_number_of_failures();
|
||||
CU_cleanup_registry();
|
||||
return num_failures;
|
||||
}
|
@ -30,6 +30,7 @@ if [ "$cov_avail" = "yes" ]; then
|
||||
$LCOV -q -c -i -d . -t "Baseline" -o $UT_COVERAGE/ut_cov_base.info
|
||||
fi
|
||||
|
||||
$valgrind test/unit/lib/bdev/bdev.c/bdev_ut
|
||||
$valgrind test/unit/lib/bdev/scsi_nvme.c/scsi_nvme_ut
|
||||
|
||||
$valgrind test/unit/lib/blob/blob.c/blob_ut
|
||||
|
Loading…
Reference in New Issue
Block a user