From 5b3c4b87831b4f217ae6d969383f48c5ee78aff0 Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek Date: Tue, 28 Jan 2020 15:39:52 +0100 Subject: [PATCH] test/nvme: nvme_rpc add test for bdev_nvme_apply_firmware This patch introduces tests for basic RPC commands not used in other tests: bdev_nvme_apply_firmware Change-Id: I3a7aff1720108548b03d581fa7664d1ff5498be5 Signed-off-by: Tomasz Kulasek Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/533 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Shuhei Matsumoto --- autotest.sh | 1 + test/nvme/nvme_rpc.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 test/nvme/nvme_rpc.sh diff --git a/autotest.sh b/autotest.sh index b1eba74d0..f9e29a05d 100755 --- a/autotest.sh +++ b/autotest.sh @@ -182,6 +182,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then run_test "nvme_cli_cuse" test/nvme/spdk_nvme_cli_cuse.sh run_test "nvme_smartctl_cuse" test/nvme/spdk_smartctl_cuse.sh fi + run_test "nvme_rpc" test/nvme/nvme_rpc.sh # Only test hotplug without ASAN enabled. Since if it is # enabled, it catches SEGV earlier than our handler which # breaks the hotplug logic. diff --git a/test/nvme/nvme_rpc.sh b/test/nvme/nvme_rpc.sh new file mode 100755 index 000000000..0c3688ec5 --- /dev/null +++ b/test/nvme/nvme_rpc.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/scripts/common.sh +source $rootdir/test/common/autotest_common.sh + +rpc_py=$rootdir/scripts/rpc.py + +bdf=$(iter_pci_class_code 01 08 02 | head -1) + +$rootdir/app/spdk_tgt/spdk_tgt -m 0x3 & +spdk_tgt_pid=$! +trap 'kill -9 ${spdk_tgt_pid}; exit 1' SIGINT SIGTERM EXIT + +waitforlisten $spdk_tgt_pid + +$rpc_py bdev_nvme_attach_controller -b Nvme0 -t PCIe -a ${bdf} + +# 1) Test bdev_nvme_apply_firmware RPC +# NOTE: We don't want to do real firmware update on CI + +# Make sure that used firmware file doesn't exist +if [ -f non_existing_file ]; then + exit 1 +fi + +# a) Try to apply firmware from non existing file +$rpc_py bdev_nvme_apply_firmware non_existing_file Nvme0n1 || rv=$? +if [ -z "$rv" ]; then + exit 1 +fi + +$rpc_py bdev_nvme_detach_controller Nvme0 + +trap - SIGINT SIGTERM EXIT +killprocess $spdk_tgt_pid