From 6b19775bd9a790416a612391421ce41768dc93d2 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 9 Jun 2020 08:28:44 -0400 Subject: [PATCH] test/common: fail the tests if get_nvme_bdfs() returns no devices Usual way to call get_nvme_bdfs() is to iterate over resulting bdfs. When no bdfs are returned, most of the scripts do no not execute tests at all and assume success. Instead of adding error checking for each and every script for no bdfs, this patch makes get_nvme_bdfs() exit with test failure. This assumes that there will never be a test that expects no devices to be present. Signed-off-by: Tomasz Zawadzki Change-Id: I1e41a885c76ce6cc248fb076bc4f4efd4695ff3c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2836 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Maciej Wawryk Reviewed-by: Karol Latecki --- test/common/autotest_common.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 17a80794a..2fb9e1862 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -1240,7 +1240,12 @@ function opal_revert_cleanup() { # uio-pci-generic or vfio-pci function get_nvme_bdfs() { xtrace_disable - jq -r .config[].params.traddr <<< $($rootdir/scripts/gen_nvme.sh --json) + bdfs=$(jq -r .config[].params.traddr <<< $($rootdir/scripts/gen_nvme.sh --json)) + if [[ -z $bdfs ]]; then + echo "No devices to test on!" + exit 1 + fi + echo "$bdfs" xtrace_restore }