2018-02-27 23:07:35 +00:00
|
|
|
#!/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))
|
2018-03-19 21:02:59 +00:00
|
|
|
rootdir=$(readlink -f $(dirname $0)/../..)
|
2018-02-27 23:07:35 +00:00
|
|
|
|
2018-07-06 15:53:45 +00:00
|
|
|
cd "$rootdir"
|
|
|
|
|
2018-09-28 12:29:04 +00:00
|
|
|
|
2018-02-27 23:07:35 +00:00
|
|
|
# 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
|
2018-09-28 12:29:04 +00:00
|
|
|
if grep -q '#undef SPDK_CONFIG_ASAN' $rootdir/include/spdk/config.h && hash valgrind; then
|
2018-02-27 23:07:35 +00:00
|
|
|
valgrind='valgrind --leak-check=full --error-exitcode=2'
|
|
|
|
else
|
|
|
|
valgrind=''
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# setup local unit test coverage if cov is available
|
2018-09-28 12:29:04 +00:00
|
|
|
if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' $rootdir/include/spdk/config.h; then
|
2018-02-27 23:07:35 +00:00
|
|
|
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
|
2019-02-16 15:51:45 +00:00
|
|
|
|
|
|
|
# workaround for valgrind v3.13 on arm64
|
|
|
|
if [ $(uname -m) = "aarch64" ]; then
|
|
|
|
export LD_HWCAP_MASK=1
|
|
|
|
fi
|
|
|
|
|
2018-02-27 23:07:35 +00:00
|
|
|
$valgrind $testdir/include/spdk/histogram_data.h/histogram_ut
|
|
|
|
|
|
|
|
$valgrind $testdir/lib/bdev/bdev.c/bdev_ut
|
2018-05-08 11:30:29 +00:00
|
|
|
$valgrind $testdir/lib/bdev/bdev_raid.c/bdev_raid_ut
|
2019-10-29 15:36:10 +00:00
|
|
|
$valgrind $testdir/lib/bdev/bdev_zone.c/bdev_zone_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
$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
|
2019-08-21 08:38:53 +00:00
|
|
|
$valgrind $testdir/lib/bdev/vbdev_zone_block.c/vbdev_zone_block_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
2018-09-28 12:29:04 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_CRYPTO 1' $rootdir/include/spdk/config.h; then
|
2018-03-07 23:44:06 +00:00
|
|
|
$valgrind $testdir/lib/bdev/crypto.c/crypto_ut
|
|
|
|
fi
|
|
|
|
|
2019-02-19 22:52:08 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_REDUCE 1' $rootdir/include/spdk/config.h; then
|
|
|
|
$valgrind $testdir/lib/bdev/compress.c/compress_ut
|
|
|
|
fi
|
|
|
|
|
2018-09-28 12:29:04 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_PMDK 1' $rootdir/include/spdk/config.h; then
|
2018-02-27 23:07:35 +00:00
|
|
|
$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
|
2019-08-28 08:06:50 +00:00
|
|
|
$valgrind $testdir/lib/blobfs/blobfs_bdev.c/blobfs_bdev_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
$valgrind $testdir/lib/event/subsystem.c/subsystem_ut
|
2018-08-21 20:52:42 +00:00
|
|
|
$valgrind $testdir/lib/event/app.c/app_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
2018-06-21 22:40:18 +00:00
|
|
|
$valgrind $testdir/lib/sock/sock.c/sock_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
$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
|
2018-06-11 22:13:55 +00:00
|
|
|
$valgrind $testdir/lib/nvme/nvme_ctrlr_ocssd_cmd.c/nvme_ctrlr_ocssd_cmd_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
$valgrind $testdir/lib/nvme/nvme_ns.c/nvme_ns_ut
|
|
|
|
$valgrind $testdir/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut
|
2018-06-07 09:16:52 +00:00
|
|
|
$valgrind $testdir/lib/nvme/nvme_ns_ocssd_cmd.c/nvme_ns_ocssd_cmd_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
$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
|
2019-05-24 04:01:05 +00:00
|
|
|
$valgrind $testdir/lib/nvme/nvme_tcp.c/nvme_tcp_ut
|
2018-10-11 23:21:05 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_RDMA 1' $rootdir/include/spdk/config.h; then
|
2018-10-03 21:02:54 +00:00
|
|
|
$valgrind $testdir/lib/nvme/nvme_rdma.c/nvme_rdma_ut
|
|
|
|
fi
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
$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
|
2018-10-11 23:21:05 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_RDMA 1' $rootdir/include/spdk/config.h; then
|
|
|
|
$valgrind $testdir/lib/nvmf/rdma.c/rdma_ut
|
|
|
|
fi
|
2018-02-27 23:07:35 +00:00
|
|
|
$valgrind $testdir/lib/nvmf/subsystem.c/subsystem_ut
|
2018-09-19 04:04:40 +00:00
|
|
|
$valgrind $testdir/lib/nvmf/tcp.c/tcp_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
$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
|
2019-05-14 06:01:35 +00:00
|
|
|
$valgrind $testdir/lib/scsi/scsi_pr.c/scsi_pr_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
$valgrind $testdir/lib/lvol/lvol.c/lvol_ut
|
|
|
|
|
2019-03-29 15:04:48 +00:00
|
|
|
$valgrind $testdir/lib/notify/notify.c/notify_ut
|
|
|
|
|
2018-02-27 23:07:35 +00:00
|
|
|
$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
|
|
|
|
|
2018-09-21 14:37:54 +00:00
|
|
|
if grep -q '#define SPDK_CONFIG_REDUCE 1' $rootdir/config.h; then
|
|
|
|
$valgrind $testdir/lib/reduce/reduce.c/reduce_ut
|
|
|
|
fi
|
2018-09-12 01:01:43 +00:00
|
|
|
|
2018-06-11 18:22:27 +00:00
|
|
|
$valgrind $testdir/lib/thread/thread.c/thread_ut
|
|
|
|
|
2018-06-27 01:55:05 +00:00
|
|
|
$valgrind $testdir/lib/util/base64.c/base64_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
$valgrind $testdir/lib/util/bit_array.c/bit_array_ut
|
2019-01-08 11:10:50 +00:00
|
|
|
$valgrind $testdir/lib/util/cpuset.c/cpuset_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
$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/string.c/string_ut
|
2018-11-27 05:23:38 +00:00
|
|
|
$valgrind $testdir/lib/util/dif.c/dif_ut
|
2018-02-27 23:07:35 +00:00
|
|
|
|
|
|
|
if [ $(uname -s) = Linux ]; then
|
|
|
|
$valgrind $testdir/lib/vhost/vhost.c/vhost_ut
|
|
|
|
|
2018-10-29 14:25:26 +00:00
|
|
|
$valgrind $testdir/lib/ftl/ftl_rwb.c/ftl_rwb_ut
|
|
|
|
$valgrind $testdir/lib/ftl/ftl_ppa/ftl_ppa_ut
|
|
|
|
$valgrind $testdir/lib/ftl/ftl_band.c/ftl_band_ut
|
2019-02-01 15:36:47 +00:00
|
|
|
$valgrind $testdir/lib/ftl/ftl_reloc.c/ftl_reloc_ut
|
2019-02-06 14:18:05 +00:00
|
|
|
$valgrind $testdir/lib/ftl/ftl_wptr/ftl_wptr_ut
|
2019-02-22 11:14:53 +00:00
|
|
|
$valgrind $testdir/lib/ftl/ftl_md/ftl_md_ut
|
2019-03-22 15:45:46 +00:00
|
|
|
$valgrind $testdir/lib/ftl/ftl_io.c/ftl_io_ut
|
2018-10-29 14:25:26 +00:00
|
|
|
fi
|
|
|
|
|
2019-04-22 09:28:02 +00:00
|
|
|
if [ -e $testdir/lib/nvmf/fc.c/fc_ut ]; then
|
|
|
|
$valgrind $testdir/lib/nvmf/fc.c/fc_ut
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e $testdir/lib/nvmf/fc_ls.c/fc_ls_ut ]; then
|
|
|
|
$valgrind $testdir/lib/nvmf/fc_ls.c/fc_ls_ut
|
|
|
|
fi
|
|
|
|
|
2018-02-27 23:07:35 +00:00
|
|
|
# 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
|
2018-03-19 21:02:59 +00:00
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/app/*" -o $UT_COVERAGE/ut_cov_unit.info
|
2018-03-19 22:15:14 +00:00
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/dpdk/*" -o $UT_COVERAGE/ut_cov_unit.info
|
2018-03-19 21:02:59 +00:00
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/examples/*" -o $UT_COVERAGE/ut_cov_unit.info
|
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/include/*" -o $UT_COVERAGE/ut_cov_unit.info
|
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/lib/vhost/rte_vhost/*" -o $UT_COVERAGE/ut_cov_unit.info
|
|
|
|
$LCOV -q -r $UT_COVERAGE/ut_cov_unit.info "$rootdir/test/*" -o $UT_COVERAGE/ut_cov_unit.info
|
2018-02-27 23:07:35 +00:00
|
|
|
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
|
2019-11-04 15:48:58 +00:00
|
|
|
cd $rootdir
|
|
|
|
git clean -f "*.gcda"
|
|
|
|
cd -
|
2018-02-27 23:07:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
set +x
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "====================="
|
|
|
|
echo "All unit tests passed"
|
|
|
|
echo "====================="
|
|
|
|
if [ "$cov_avail" = "yes" ]; then
|
2018-07-06 15:53:45 +00:00
|
|
|
echo "Note: coverage report is here: $rootdir/$UT_COVERAGE"
|
2018-02-27 23:07:35 +00:00
|
|
|
else
|
|
|
|
echo "WARN: lcov not installed or SPDK built without coverage!"
|
|
|
|
fi
|
2018-09-28 12:29:04 +00:00
|
|
|
if grep -q '#undef SPDK_CONFIG_ASAN' $rootdir/include/spdk/config.h && [ "$valgrind" = "" ]; then
|
2018-02-27 23:07:35 +00:00
|
|
|
echo "WARN: neither valgrind nor ASAN is enabled!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|