test/common: Allow rpc_cmd() to execute multiple commands
This allows to pass to rpc_cmd() sets of commands via stdin. E.g.: rpc_cmd <<-CMDS bdev_malloc_create -b Malloc0 32 512 bdev_malloc_create -b Malloc1 32 512 bdev_malloc_create -b Malloc2 32 512 CMDS Since rpc.py is already running in a server mode, this is slightly faster than grouping commands and running scripts/rpc.py directly. Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I29fbcf3f2751400980d35b4de2cce2da1cd2bf2a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7087 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
9aa3c063da
commit
08d4dce28c
@ -445,17 +445,32 @@ function get_config_params() {
|
||||
|
||||
function rpc_cmd() {
|
||||
xtrace_disable
|
||||
local rsp rc
|
||||
local rsp rc=1
|
||||
local stdin cmd cmds_number=0 status_number=0 status
|
||||
|
||||
if (($#)); then
|
||||
cmds_number=1
|
||||
echo "$@" >&$RPC_PIPE_INPUT
|
||||
elif [[ ! -t 0 ]]; then
|
||||
mapfile -t stdin <&0
|
||||
cmds_number=${#stdin[@]}
|
||||
printf '%s\n' "${stdin[@]}" >&$RPC_PIPE_INPUT
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "$@" >&$RPC_PIPE_INPUT
|
||||
while read -t 5 -ru $RPC_PIPE_OUTPUT rsp; do
|
||||
if [[ $rsp == "**STATUS="* ]]; then
|
||||
break
|
||||
status[${rsp#*=}]=$rsp
|
||||
if ((++status_number == cmds_number)); then
|
||||
break
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
echo "$rsp"
|
||||
done
|
||||
|
||||
rc=${rsp#*=}
|
||||
rc=${!status[*]}
|
||||
xtrace_restore
|
||||
[[ $rc == 0 ]]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user