Commit fdd963be authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

test/keyring: extract common methods



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ibe047adeed323d5a6b913451b36f4c32f115ba9b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21762


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent b6562ed3
Loading
Loading
Loading
Loading

test/keyring/common.sh

0 → 100644
+24 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Intel Corporation.  All rights reserved.

source "$rootdir/test/nvmf/common.sh"

bperfsock="/var/tmp/bperf.sock"

bperf_cmd() { "$rootdir/scripts/rpc.py" -s "$bperfsock" "$@"; }

get_key() { bperf_cmd keyring_get_keys | jq ".[] | select(.name == \"$1\")"; }

get_refcnt() { get_key "$1" | jq -r '.refcnt'; }

prep_key() {
	local name key path

	name="$1" key="$2"
	path="${3-$(mktemp)}"

	format_interchange_psk "$key" > "$path"
	chmod 0600 "$path"

	echo "$path"
}
+1 −20
Original line number Diff line number Diff line
@@ -8,31 +8,12 @@ rootdir=$(readlink -f "$testdir/../..")
set -- "--transport=tcp" "$@"

source "$rootdir/test/common/autotest_common.sh"
source "$rootdir/test/nvmf/common.sh"
source "$testdir/common.sh"

subnqn="nqn.2016-06.io.spdk:cnode0"
hostnqn="nqn.2016-06.io.spdk:host0"
key0="00112233445566778899aabbccddeeff"
key1="112233445566778899aabbccddeeff00"
bperfsock="/var/tmp/bperf.sock"

bperf_cmd() { "$rootdir/scripts/rpc.py" -s "$bperfsock" "$@"; }

get_key() { bperf_cmd keyring_get_keys | jq ".[] | select(.name == \"$1\")"; }

get_refcnt() { get_key "$1" | jq -r '.refcnt'; }

prep_key() {
	local name key path

	name="$1" key="$2"
	path="$(mktemp)"

	format_interchange_psk "$key" > "$path"
	chmod 0600 "$path"

	echo "$path"
}

cleanup() {
	rm -f "$key0path" "$key1path"