From 83620f4e096a407493f19ce5f4878484d114dac9 Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Fri, 14 Oct 2016 15:41:03 +0800 Subject: [PATCH] test: Add test case for nvme bdev construction. Change-Id: Iff256c9df8bc6954a18291caa7cc452e7bbe78fc Signed-off-by: Cunyin Chang --- test/iscsi_tgt/rpc_config/rpc_config.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/iscsi_tgt/rpc_config/rpc_config.py b/test/iscsi_tgt/rpc_config/rpc_config.py index c1655c4261..67e5436282 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.py +++ b/test/iscsi_tgt/rpc_config/rpc_config.py @@ -393,6 +393,30 @@ def verify_add_delete_ip_address(rpc_py): (faked_ip, x["name"])) print "verify_add_delete_ip_address passed." +def verify_add_nvme_bdev_rpc_methods(rpc_py): + rpc = spdk_rpc(rpc_py) + test_pass = 0 + output = check_output("lspci -mm -n | awk '{if ($2 == \"\\\"0108\\\"\") print $0}' | grep p02", shell=True) + for out in output.split("\n"): + if out != '': + ctrlr_address = "0000:{}".format(out.split(" ")[0]) + output = rpc.construct_nvme_bdev(ctrlr_address) + if output.strip()=='': + print "add nvme device passed first time" + test_pass = 1 + verify(test_pass == 1, 1, "add nvme device passed first time") + test_pass = 0 + try: + output = rpc.construct_nvme_bdev(ctrlr_address) + except Exception as e: + print "add nvme device passed second time" + test_pass = 1 + pass + else: + pass + verify(test_pass == 1, 1, "add nvme device passed second time") + print "verify_add_nvme_bdev_rpc_methods passed." + if __name__ == "__main__": rpc_py = sys.argv[1] @@ -407,6 +431,7 @@ if __name__ == "__main__": verify_target_nodes_rpc_methods(rpc_py, rpc_param) verify_scsi_devices_rpc_methods(rpc_py) verify_iscsi_connection_rpc_methods(rpc_py) + verify_add_nvme_bdev_rpc_methods(rpc_py) except RpcException as e: print "{}. Exiting with status {}".format(e.message, e.retval) raise e