3 # Environment variables:
4 # $valgrind Specify the valgrind command line, if not
5 # then a default command line is used
9 # if ASAN is enabled, use it. If not use valgrind if installed but allow
10 # the env variable to override the default shown below.
11 if [ -z ${valgrind+x} ]; then
12 if grep -q '#undef SPDK_CONFIG_ASAN' config.h && hash valgrind; then
13 valgrind='valgrind --leak-check=full --error-exitcode=2'
19 # setup local unit test coverage if cov is available
20 if hash lcov && grep -q '#define SPDK_CONFIG_COVERAGE 1' config.h; then
25 if [ "$cov_avail" = "yes" ]; then
26 # set unit test output dir if not specified in env var
27 if [ -z ${UT_COVERAGE+x} ]; then
28 UT_COVERAGE="ut_coverage"
32 --rc lcov_branch_coverage=1
33 --rc lcov_function_coverage=1
34 --rc genhtml_branch_coverage=1
35 --rc genhtml_function_coverage=1
37 --rc geninfo_all_blocks=1
39 export LCOV="lcov $LCOV_OPTS --no-external"
40 # zero out coverage data
41 $LCOV -q -c -i -d . -t "Baseline" -o $UT_COVERAGE/ut_cov_base.info
44 $valgrind test/unit/lib/bdev/bdev.c/bdev_ut
45 $valgrind test/unit/lib/bdev/scsi_nvme.c/scsi_nvme_ut
46 $valgrind test/unit/lib/bdev/gpt/gpt.c/gpt_ut
48 $valgrind test/unit/lib/blob/blob.c/blob_ut
49 $valgrind test/unit/lib/blobfs/tree.c/tree_ut
51 $valgrind test/lib/blobfs/blobfs_async_ut/blobfs_async_ut
52 # blobfs_sync_ut hangs when run under valgrind, so don't use $valgrind
53 test/lib/blobfs/blobfs_sync_ut/blobfs_sync_ut
55 $valgrind test/unit/lib/nvme/nvme.c/nvme_ut
56 $valgrind test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut
57 $valgrind test/unit/lib/nvme/nvme_ctrlr_cmd.c/nvme_ctrlr_cmd_ut
58 $valgrind test/unit/lib/nvme/nvme_ns.c/nvme_ns_ut
59 $valgrind test/unit/lib/nvme/nvme_ns_cmd.c/nvme_ns_cmd_ut
60 $valgrind test/unit/lib/nvme/nvme_qpair.c/nvme_qpair_ut
61 $valgrind test/unit/lib/nvme/nvme_pcie.c/nvme_pcie_ut
62 $valgrind test/unit/lib/nvme/nvme_quirks.c/nvme_quirks_ut
64 $valgrind test/unit/lib/ioat/ioat.c/ioat_ut
66 $valgrind test/unit/lib/json/json_parse.c/json_parse_ut
67 $valgrind test/unit/lib/json/json_util.c/json_util_ut
68 $valgrind test/unit/lib/json/json_write.c/json_write_ut
70 $valgrind test/unit/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut
72 $valgrind test/unit/lib/log/log.c/log_ut
74 $valgrind test/unit/lib/nvmf/ctrlr.c/ctrlr_ut
75 $valgrind test/unit/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut
76 $valgrind test/unit/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut
77 $valgrind test/unit/lib/nvmf/request.c/request_ut
78 $valgrind test/unit/lib/nvmf/subsystem.c/subsystem_ut
80 $valgrind test/unit/lib/scsi/dev.c/dev_ut
81 $valgrind test/unit/lib/scsi/lun.c/lun_ut
82 $valgrind test/unit/lib/scsi/scsi.c/scsi_ut
83 $valgrind test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut
85 $valgrind test/unit/lib/iscsi/param.c/param_ut
86 $valgrind test/unit/lib/iscsi/tgt_node.c/tgt_node_ut test/unit/lib/iscsi/tgt_node.c/tgt_node.conf
87 $valgrind test/unit/lib/iscsi/iscsi.c/iscsi_ut
89 $valgrind test/unit/lib/util/bit_array.c/bit_array_ut
90 $valgrind test/unit/lib/util/crc32_ieee.c/crc32_ieee_ut
91 $valgrind test/unit/lib/util/crc32c.c/crc32c_ut
92 $valgrind test/unit/lib/util/io_channel.c/io_channel_ut
93 $valgrind test/unit/lib/util/string.c/string_ut
95 if [ $(uname -s) = Linux ]; then
96 $valgrind test/unit/lib/vhost/vhost.c/vhost_ut
99 # local unit test coverage
100 if [ "$cov_avail" = "yes" ]; then
101 $LCOV -q -d . -c -t "$(hostname)" -o $UT_COVERAGE/ut_cov_test.info
102 $LCOV -q -a $UT_COVERAGE/ut_cov_base.info -a $UT_COVERAGE/ut_cov_test.info -o $UT_COVERAGE/ut_cov_total.info
103 $LCOV -q -a $UT_COVERAGE/ut_cov_total.info -o $UT_COVERAGE/ut_cov_unit.info
104 $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'app/*' -o $UT_COVERAGE/ut_cov_unit.info
105 $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'examples/*' -o $UT_COVERAGE/ut_cov_unit.info
106 $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'include/*' -o $UT_COVERAGE/ut_cov_unit.info
107 $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'lib/vhost/rte_vhost/*' -o $UT_COVERAGE/ut_cov_unit.info
108 $LCOV -q -r $UT_COVERAGE/ut_cov_unit.info 'test/*' -o $UT_COVERAGE/ut_cov_unit.info
109 rm -f $UT_COVERAGE/ut_cov_base.info $UT_COVERAGE/ut_cov_test.info
110 genhtml $UT_COVERAGE/ut_cov_unit.info --output-directory $UT_COVERAGE
111 git clean -f "*.gcda"
118 echo "====================="
119 echo "All unit tests passed"
120 echo "====================="
121 if [ "$cov_avail" = "yes" ]; then
122 echo "Note: coverage report is here: ./$UT_COVERAGE"
124 echo "WARN: lcov not installed or SPDK built without coverage!"
126 if grep -q '#undef SPDK_CONFIG_ASAN' config.h && [ "$valgrind" = "" ]; then
127 echo "WARN: neither valgrind nor ASAN is enabled!"