[PATCH 06/10] nvme/039: create authenticated connections

Chaitanya Kulkarni chaitanyak at nvidia.com
Mon Dec 13 15:01:57 PST 2021


On 11/22/21 11:49 PM, Hannes Reinecke wrote:
> Signed-off-by: Hannes Reinecke <hare at suse.de>
> ---
>   tests/nvme/039     | 83 ++++++++++++++++++++++++++++++++++++++++++++++
>   tests/nvme/039.out |  7 ++++
>   2 files changed, 90 insertions(+)
>   create mode 100644 tests/nvme/039
>   create mode 100644 tests/nvme/039.out
> 
> diff --git a/tests/nvme/039 b/tests/nvme/039
> new file mode 100644
> index 0000000..4fbe7de
> --- /dev/null
> +++ b/tests/nvme/039
> @@ -0,0 +1,83 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs
> +#
> +# Create authenticated connections
> +
> +. tests/nvme/rc
> +
> +DESCRIPTION="Create authenticated connections"
> +QUICK=1
> +
> +requires() {
> +	_nvme_requires
> +	_have_modules loop
> +	_require_nvme_trtype_is_fabrics
> +	_require_nvme_cli_auth
> +}
> +
> +
> +test() {
> +	local port
> +	local subsys="blktests-subsystem-1"
> +	local hostid="$(uuidgen)"
> +	local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
> +	local scratch="/tmp/blktest-ns1.img"
> +	local hostkey
> +	local ctrldev
> +
> +	echo "Running ${TEST_NAME}"
> +
> +	hostkey="$(nvme gen-dhchap-key -n ${subsys} 2> /dev/null)"
> +	if [ $? -ne 0 ] ; then
> +		echo "nvme gen-dhchap-key command missing"
> +		return 1
> +	fi
> +
> +	_setup_nvmet
> +
> +	truncate -s 512M "${scratch}"
> +
> +	port="$(_create_nvmet_port "${nvme_trtype}")"
> +
> +	_create_nvmet_subsystem "${subsys}" "${scratch}"
> +	_add_nvmet_subsys_to_port "${port}" "${subsys}"
> +	_create_nvmet_host "${subsys}" "${hostnqn}" "${hostkey}"
> +

Starting from _setup_nvmet() to _create_nvmet_host() seems to be 
duplicated in most of the cases (39/40/41/42/43).

Let's avoid the code duplication by creating a helper in nvme/rc ?



More information about the Linux-nvme mailing list