test/unit: move unittest.sh and dependencies here.

All files called directly by the unittest.sh script are now located in
the test/unit directory.

Change-Id: I95cfb3d5b7c6ede59d7183c39466f32b7e676643
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/401717
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2018-02-27 16:07:35 -07:00 committed by Jim Harris
parent 45e919d210
commit 12e840b937
14 changed files with 166 additions and 161 deletions

View File

@ -24,4 +24,4 @@ script:
- ./scripts/check_format.sh
- ./configure --enable-werror
- make
- ./unittest.sh
- ./test/unit/unittest.sh

View File

@ -79,7 +79,7 @@ gmake
## Unit Tests
~~~{.sh}
./unittest.sh
./test/unit/unittest.sh
~~~
You will see several error messages when running the unit tests, but they are

View File

@ -89,7 +89,7 @@ fi
if [ $SPDK_TEST_UNITTEST -eq 1 ]; then
timing_enter unittest
run_test ./unittest.sh
run_test ./test/unit/unittest.sh
report_test_completion "unittest"
timing_exit unittest
fi

View File

@ -56,7 +56,7 @@ It's always a good idea to confirm your build worked by running the
unit tests.
~~~{.sh}
./unittest.sh
./test/unit/unittest.sh
~~~
You will see several error messages when running the unit tests, but they are

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = blobfs_async_ut blobfs_sync_ut mkfs
DIRS-y = mkfs
# TODO: do not check a hardcoded path here
ifneq (,$(wildcard /usr/local/include/fuse3))

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y = tree.c
DIRS-y = tree.c blobfs_async_ut blobfs_sync_ut
.PHONY: all clean $(DIRS-y)

View File

@ -31,7 +31,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -31,7 +31,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

158
test/unit/unittest.sh Executable file
View File

@ -0,0 +1,158 @@
#!/usr/bin/env bash
#
# Environment variables:
# $valgrind Specify the valgrind command line, if not
# then a default command line is used
set -xe
testdir=$(readlink -f $(dirname $0))
rootdir=$testdir/../..
# if ASAN is enabled, use it. If not use valgrind if installed but allow
# the env variable to override the default shown below.
if [ -z ${valgrind+x} ]; then
if grep -q '#undef SPDK_CONFIG_ASAN' $rootdir/config.h && hash valgrind; then
valgrind='valgrind --leak-check=full --error-exitcode=2'
else
valgrind=''
fi
fi
# setup local unit test coverage if cov is available
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' $rootdir/config.h; then
cov_avail="yes"
else
cov_avail="no"
fi
if [ "$cov_avail" = "yes" ]; then
# set unit test output dir if not specified in env var
if [ -z ${UT_COVERAGE+x} ]; then
UT_COVERAGE="ut_coverage"
fi
mkdir -p $UT_COVERAGE
export LCOV_OPTS="
--rc lcov_branch_coverage=1
--rc lcov_function_coverage=1
--rc genhtml_branch_coverage=1
--rc genhtml_function_coverage=1
--rc genhtml_legend=1
--rc geninfo_all_blocks=1
"
export LCOV="lcov $LCOV_OPTS --no-external"
# zero out coverage data
$LCOV -q -c -i -d . -t "Baseline" -o $UT_COVERAGE/ut_cov_base.info
fi
$valgrind $testdir/include/spdk/histogram_data.h/histogram_ut
$valgrind $testdir/lib/bdev/bdev.c/bdev_ut
$valgrind $testdir/lib/bdev/part.c/part_ut
$valgrind $testdir/lib/bdev/scsi_nvme.c/scsi_nvme_ut
$valgrind $testdir/lib/bdev/gpt/gpt.c/gpt_ut
$valgrind $testdir/lib/bdev/vbdev_lvol.c/vbdev_lvol_ut
if grep -q '#define SPDK_CONFIG_NVML 1' $rootdir/config.h; then
$valgrind $testdir/lib/bdev/pmem/bdev_pmem_ut
fi
$valgrind $testdir/lib/bdev/mt/bdev.c/bdev_ut
$valgrind $testdir/lib/blob/blob.c/blob_ut
$valgrind $testdir/lib/blobfs/tree.c/tree_ut
$valgrind $testdir/lib/blobfs/blobfs_async_ut/blobfs_async_ut
# blobfs_sync_ut hangs when run under valgrind, so don't use $valgrind
$testdir/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut
$valgrind $testdir/lib/event/subsystem.c/subsystem_ut
$valgrind $testdir/lib/net/sock.c/sock_ut
$valgrind $testdir/lib/nvme/nvme.c/nvme_ut
$valgrind $testdir/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut
$valgrind $testdir/lib/nvme/nvme_ctrlr_cmd.c/nvme_ctrlr_cmd_ut
$valgrind $testdir/lib/nvme/nvme_ns.c/nvme_ns_ut
$valgrind $testdir/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut
$valgrind $testdir/lib/nvme/nvme_qpair.c/nvme_qpair_ut
$valgrind $testdir/lib/nvme/nvme_pcie.c/nvme_pcie_ut
$valgrind $testdir/lib/nvme/nvme_quirks.c/nvme_quirks_ut
$valgrind $testdir/lib/ioat/ioat.c/ioat_ut
$valgrind $testdir/lib/json/json_parse.c/json_parse_ut
$valgrind $testdir/lib/json/json_util.c/json_util_ut
$valgrind $testdir/lib/json/json_write.c/json_write_ut
$valgrind $testdir/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut
$valgrind $testdir/lib/log/log.c/log_ut
$valgrind $testdir/lib/nvmf/ctrlr.c/ctrlr_ut
$valgrind $testdir/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut
$valgrind $testdir/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut
$valgrind $testdir/lib/nvmf/request.c/request_ut
$valgrind $testdir/lib/nvmf/subsystem.c/subsystem_ut
$valgrind $testdir/lib/scsi/dev.c/dev_ut
$valgrind $testdir/lib/scsi/lun.c/lun_ut
$valgrind $testdir/lib/scsi/scsi.c/scsi_ut
$valgrind $testdir/lib/scsi/scsi_bdev.c/scsi_bdev_ut
$valgrind $testdir/lib/lvol/lvol.c/lvol_ut
$valgrind $testdir/lib/iscsi/conn.c/conn_ut
$valgrind $testdir/lib/iscsi/param.c/param_ut
$valgrind $testdir/lib/iscsi/tgt_node.c/tgt_node_ut $testdir/lib/iscsi/tgt_node.c/tgt_node.conf
$valgrind $testdir/lib/iscsi/iscsi.c/iscsi_ut
$valgrind $testdir/lib/iscsi/init_grp.c/init_grp_ut $testdir/lib/iscsi/init_grp.c/init_grp.conf
$valgrind $testdir/lib/iscsi/portal_grp.c/portal_grp_ut $testdir/lib/iscsi/portal_grp.c/portal_grp.conf
$valgrind $testdir/lib/util/bit_array.c/bit_array_ut
$valgrind $testdir/lib/util/crc16.c/crc16_ut
$valgrind $testdir/lib/util/crc32_ieee.c/crc32_ieee_ut
$valgrind $testdir/lib/util/crc32c.c/crc32c_ut
$valgrind $testdir/lib/util/io_channel.c/io_channel_ut
$valgrind $testdir/lib/util/string.c/string_ut
if [ $(uname -s) = Linux ]; then
$valgrind $testdir/lib/vhost/vhost.c/vhost_ut
$valgrind $testdir/lib/vhost/vhost_scsi.c/vhost_scsi_ut
$valgrind $testdir/lib/vhost/vhost_blk.c/vhost_blk_ut
fi
# local unit test coverage
if [ "$cov_avail" = "yes" ]; then
$LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info
$LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info
$LCOV -q -a $UT_COVERAGE/ut_cov_total.info -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'app/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'examples/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'include/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'lib/vhost/rte_vhost/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'test/*' -o $UT_COVERAGE/ut_cov_unit.info
rm -f $UT_COVERAGE/ut_cov_base.info $UT_COVERAGE/ut_cov_test.info
genhtml $UT_COVERAGE/ut_cov_unit.info --output-directory $UT_COVERAGE
# git -C option not used for compatibility reasons
cd $rootdir
git clean -f "*.gcda"
cd -
fi
set +x
echo
echo
echo "====================="
echo "All unit tests passed"
echo "====================="
if [ "$cov_avail" = "yes" ]; then
echo "Note: coverage report is here: ./$UT_COVERAGE"
else
echo "WARN: lcov not installed or SPDK built without coverage!"
fi
if grep -q '#undef SPDK_CONFIG_ASAN' $rootdir/config.h && [ "$valgrind" = "" ]; then
echo "WARN: neither valgrind nor ASAN is enabled!"
fi
echo
echo

View File

@ -1,153 +0,0 @@
#!/usr/bin/env bash
#
# Environment variables:
# $valgrind Specify the valgrind command line, if not
# then a default command line is used
set -xe
# if ASAN is enabled, use it. If not use valgrind if installed but allow
# the env variable to override the default shown below.
if [ -z ${valgrind+x} ]; then
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && hash valgrind; then
valgrind='valgrind --leak-check=full --error-exitcode=2'
else
valgrind=''
fi
fi
# setup local unit test coverage if cov is available
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' config.h; then
cov_avail="yes"
else
cov_avail="no"
fi
if [ "$cov_avail" = "yes" ]; then
# set unit test output dir if not specified in env var
if [ -z ${UT_COVERAGE+x} ]; then
UT_COVERAGE="ut_coverage"
fi
mkdir -p $UT_COVERAGE
export LCOV_OPTS="
--rc lcov_branch_coverage=1
--rc lcov_function_coverage=1
--rc genhtml_branch_coverage=1
--rc genhtml_function_coverage=1
--rc genhtml_legend=1
--rc geninfo_all_blocks=1
"
export LCOV="lcov $LCOV_OPTS --no-external"
# zero out coverage data
$LCOV -q -c -i -d . -t "Baseline" -o $UT_COVERAGE/ut_cov_base.info
fi
$valgrind test/unit/include/spdk/histogram_data.h/histogram_ut
$valgrind test/unit/lib/bdev/bdev.c/bdev_ut
$valgrind test/unit/lib/bdev/part.c/part_ut
$valgrind test/unit/lib/bdev/scsi_nvme.c/scsi_nvme_ut
$valgrind test/unit/lib/bdev/gpt/gpt.c/gpt_ut
$valgrind test/unit/lib/bdev/vbdev_lvol.c/vbdev_lvol_ut
if grep -q '#define SPDK_CONFIG_NVML 1' config.h; then
$valgrind test/unit/lib/bdev/pmem/bdev_pmem_ut
fi
$valgrind test/unit/lib/bdev/mt/bdev.c/bdev_ut
$valgrind test/unit/lib/blob/blob.c/blob_ut
$valgrind test/unit/lib/blobfs/tree.c/tree_ut
$valgrind test/lib/blobfs/blobfs_async_ut/blobfs_async_ut
# blobfs_sync_ut hangs when run under valgrind, so don't use $valgrind
test/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut
$valgrind test/unit/lib/event/subsystem.c/subsystem_ut
$valgrind test/unit/lib/net/sock.c/sock_ut
$valgrind test/unit/lib/nvme/nvme.c/nvme_ut
$valgrind test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut
$valgrind test/unit/lib/nvme/nvme_ctrlr_cmd.c/nvme_ctrlr_cmd_ut
$valgrind test/unit/lib/nvme/nvme_ns.c/nvme_ns_ut
$valgrind test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut
$valgrind test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut
$valgrind test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut
$valgrind test/unit/lib/nvme/nvme_quirks.c/nvme_quirks_ut
$valgrind test/unit/lib/ioat/ioat.c/ioat_ut
$valgrind test/unit/lib/json/json_parse.c/json_parse_ut
$valgrind test/unit/lib/json/json_util.c/json_util_ut
$valgrind test/unit/lib/json/json_write.c/json_write_ut
$valgrind test/unit/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut
$valgrind test/unit/lib/log/log.c/log_ut
$valgrind test/unit/lib/nvmf/ctrlr.c/ctrlr_ut
$valgrind test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut
$valgrind test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut
$valgrind test/unit/lib/nvmf/request.c/request_ut
$valgrind test/unit/lib/nvmf/subsystem.c/subsystem_ut
$valgrind test/unit/lib/scsi/dev.c/dev_ut
$valgrind test/unit/lib/scsi/lun.c/lun_ut
$valgrind test/unit/lib/scsi/scsi.c/scsi_ut
$valgrind test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut
$valgrind test/unit/lib/lvol/lvol.c/lvol_ut
$valgrind test/unit/lib/iscsi/conn.c/conn_ut
$valgrind test/unit/lib/iscsi/param.c/param_ut
$valgrind test/unit/lib/iscsi/tgt_node.c/tgt_node_ut test/unit/lib/iscsi/tgt_node.c/tgt_node.conf
$valgrind test/unit/lib/iscsi/iscsi.c/iscsi_ut
$valgrind test/unit/lib/iscsi/init_grp.c/init_grp_ut test/unit/lib/iscsi/init_grp.c/init_grp.conf
$valgrind test/unit/lib/iscsi/portal_grp.c/portal_grp_ut test/unit/lib/iscsi/portal_grp.c/portal_grp.conf
$valgrind test/unit/lib/util/bit_array.c/bit_array_ut
$valgrind test/unit/lib/util/crc16.c/crc16_ut
$valgrind test/unit/lib/util/crc32_ieee.c/crc32_ieee_ut
$valgrind test/unit/lib/util/crc32c.c/crc32c_ut
$valgrind test/unit/lib/util/io_channel.c/io_channel_ut
$valgrind test/unit/lib/util/string.c/string_ut
if [ $(uname -s) = Linux ]; then
$valgrind test/unit/lib/vhost/vhost.c/vhost_ut
$valgrind test/unit/lib/vhost/vhost_scsi.c/vhost_scsi_ut
$valgrind test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut
fi
# local unit test coverage
if [ "$cov_avail" = "yes" ]; then
$LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info
$LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info
$LCOV -q -a $UT_COVERAGE/ut_cov_total.info -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'app/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'examples/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'include/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'lib/vhost/rte_vhost/*' -o $UT_COVERAGE/ut_cov_unit.info
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'test/*' -o $UT_COVERAGE/ut_cov_unit.info
rm -f $UT_COVERAGE/ut_cov_base.info $UT_COVERAGE/ut_cov_test.info
genhtml $UT_COVERAGE/ut_cov_unit.info --output-directory $UT_COVERAGE
git clean -f "*.gcda"
fi
set +x
echo
echo
echo "====================="
echo "All unit tests passed"
echo "====================="
if [ "$cov_avail" = "yes" ]; then
echo "Note: coverage report is here: ./$UT_COVERAGE"
else
echo "WARN: lcov not installed or SPDK built without coverage!"
fi
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && [ "$valgrind" = "" ]; then
echo "WARN: neither valgrind nor ASAN is enabled!"
fi
echo
echo