2015-11-04 11:02:40 -07:00
|
|
|
#!/usr/bin/env bash
|
2017-01-24 15:44:19 -07:00
|
|
|
#
|
|
|
|
# Environment variables:
|
2017-07-11 09:56:52 -07:00
|
|
|
# $valgrind Specify the valgrind command line, if not
|
|
|
|
# then a default command line is used
|
2015-11-04 11:02:40 -07:00
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
2017-07-11 09:56:52 -07: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
|
|
|
|
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && hash valgrind; then
|
|
|
|
valgrind='valgrind --leak-check=full --error-exitcode=2'
|
|
|
|
else
|
|
|
|
valgrind=''
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-05-08 13:57:23 -07:00
|
|
|
# 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
|
|
|
|
|
2017-12-21 15:17:20 -07:00
|
|
|
$valgrind test/unit/include/spdk/histogram_data.h/histogram_ut
|
|
|
|
|
2017-06-29 15:33:56 -07:00
|
|
|
$valgrind test/unit/lib/bdev/bdev.c/bdev_ut
|
2018-02-26 13:22:38 -07:00
|
|
|
$valgrind test/unit/lib/bdev/part.c/part_ut
|
2017-06-19 13:07:20 -07:00
|
|
|
$valgrind test/unit/lib/bdev/scsi_nvme.c/scsi_nvme_ut
|
2017-07-23 00:32:54 +08:00
|
|
|
$valgrind test/unit/lib/bdev/gpt/gpt.c/gpt_ut
|
2017-09-14 16:53:36 +02:00
|
|
|
$valgrind test/unit/lib/bdev/vbdev_lvol.c/vbdev_lvol_ut
|
2017-06-19 13:07:20 -07:00
|
|
|
|
2017-10-09 09:20:36 +02:00
|
|
|
if grep -q '#define SPDK_CONFIG_NVML 1' config.h; then
|
|
|
|
$valgrind test/unit/lib/bdev/pmem/bdev_pmem_ut
|
|
|
|
fi
|
|
|
|
|
2017-09-11 08:43:25 -07:00
|
|
|
$valgrind test/unit/lib/bdev/mt/bdev.c/bdev_ut
|
|
|
|
|
2017-06-21 14:31:29 -07:00
|
|
|
$valgrind test/unit/lib/blob/blob.c/blob_ut
|
2017-08-03 22:54:41 +08:00
|
|
|
$valgrind test/unit/lib/blobfs/tree.c/tree_ut
|
2017-03-20 11:26:50 -07:00
|
|
|
|
2017-05-03 21:54:47 +08:00
|
|
|
$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
|
2017-03-22 13:35:00 -07:00
|
|
|
|
2017-09-08 15:12:02 -07:00
|
|
|
$valgrind test/unit/lib/event/subsystem.c/subsystem_ut
|
|
|
|
|
2018-02-08 11:29:37 -07:00
|
|
|
$valgrind test/unit/lib/net/sock.c/sock_ut
|
|
|
|
|
2017-06-19 13:58:25 -07:00
|
|
|
$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
|
2015-12-03 14:30:38 -07:00
|
|
|
|
2017-06-21 14:27:05 -07:00
|
|
|
$valgrind test/unit/lib/ioat/ioat.c/ioat_ut
|
2016-05-09 13:16:32 -07:00
|
|
|
|
2017-06-19 13:35:44 -07:00
|
|
|
$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
|
2016-05-09 15:27:37 -07:00
|
|
|
|
2017-06-19 13:44:20 -07:00
|
|
|
$valgrind test/unit/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut
|
2016-05-19 13:29:37 -07:00
|
|
|
|
2017-06-23 16:13:05 -07:00
|
|
|
$valgrind test/unit/lib/log/log.c/log_ut
|
2016-07-21 15:08:23 -07:00
|
|
|
|
2017-07-13 14:18:08 -07:00
|
|
|
$valgrind test/unit/lib/nvmf/ctrlr.c/ctrlr_ut
|
2017-06-27 11:26:19 -07:00
|
|
|
$valgrind test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut
|
|
|
|
$valgrind test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut
|
2017-06-19 14:07:24 -07:00
|
|
|
$valgrind test/unit/lib/nvmf/request.c/request_ut
|
|
|
|
$valgrind test/unit/lib/nvmf/subsystem.c/subsystem_ut
|
2016-07-27 09:32:00 -07:00
|
|
|
|
2017-06-19 13:22:05 -07:00
|
|
|
$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
|
2016-09-14 17:12:15 -07:00
|
|
|
|
2017-09-14 16:53:36 +02:00
|
|
|
$valgrind test/unit/lib/lvol/lvol.c/lvol_ut
|
|
|
|
|
2018-01-10 11:17:31 +09:00
|
|
|
$valgrind test/unit/lib/iscsi/conn.c/conn_ut
|
2017-06-23 17:05:41 -07:00
|
|
|
$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
|
2017-11-15 09:10:00 +09:00
|
|
|
$valgrind test/unit/lib/iscsi/init_grp.c/init_grp_ut test/unit/lib/iscsi/init_grp.c/init_grp.conf
|
2018-01-19 17:57:27 +09:00
|
|
|
$valgrind test/unit/lib/iscsi/portal_grp.c/portal_grp_ut test/unit/lib/iscsi/portal_grp.c/portal_grp.conf
|
2017-03-29 13:04:05 -07:00
|
|
|
|
2017-05-16 16:51:12 -07:00
|
|
|
$valgrind test/unit/lib/util/bit_array.c/bit_array_ut
|
2017-12-15 00:39:14 -05:00
|
|
|
$valgrind test/unit/lib/util/crc16.c/crc16_ut
|
2017-07-21 14:44:43 -07:00
|
|
|
$valgrind test/unit/lib/util/crc32_ieee.c/crc32_ieee_ut
|
|
|
|
$valgrind test/unit/lib/util/crc32c.c/crc32c_ut
|
2017-06-19 12:52:01 -07:00
|
|
|
$valgrind test/unit/lib/util/io_channel.c/io_channel_ut
|
|
|
|
$valgrind test/unit/lib/util/string.c/string_ut
|
2017-05-03 16:57:59 -07:00
|
|
|
|
2017-07-28 09:24:52 -07:00
|
|
|
if [ $(uname -s) = Linux ]; then
|
|
|
|
$valgrind test/unit/lib/vhost/vhost.c/vhost_ut
|
2017-08-28 18:16:12 +02:00
|
|
|
$valgrind test/unit/lib/vhost/vhost_scsi.c/vhost_scsi_ut
|
2017-08-31 22:20:47 +02:00
|
|
|
$valgrind test/unit/lib/vhost/vhost_blk.c/vhost_blk_ut
|
2017-07-28 09:24:52 -07:00
|
|
|
fi
|
|
|
|
|
2017-05-08 13:57:23 -07: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
|
2017-05-18 10:55:27 -07:00
|
|
|
$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
|
2017-05-08 13:57:23 -07: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 clean -f "*.gcda"
|
|
|
|
fi
|
|
|
|
|
2017-05-03 16:57:59 -07:00
|
|
|
set +x
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "====================="
|
|
|
|
echo "All unit tests passed"
|
|
|
|
echo "====================="
|
2017-05-08 13:57:23 -07:00
|
|
|
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
|
2017-07-11 09:56:52 -07:00
|
|
|
if grep -q '#undef SPDK_CONFIG_ASAN' config.h && [ "$valgrind" = "" ]; then
|
|
|
|
echo "WARN: neither valgrind nor ASAN is enabled!"
|
|
|
|
fi
|
|
|
|
|
2017-05-03 16:57:59 -07:00
|
|
|
echo
|
|
|
|
echo
|