test/json_config: Fix string notify_get_types is compared with

The $enabled_types consisted of a newline, two tabs and a trailing
space. In that form it was checked against a string that consisted
of array items returned in a form of:

foo
bar

The check initially was failing since plain [ was splitting these
strings into multiple words without proper quoting in place. This
could be seen in the build log:

  line 52: [: too many arguments

This is fixed by replacing [ with [[ and using proper quoting on the
rhs of the expression.

Additionally, $enabled_types is now converted to an array to make
the comparision more natural without worrying about the whitespaces.

Change-Id: I6e3e539f36567443b36327f3bcc083de387b8474
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1864
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Michal Berger 2020-04-15 12:16:41 +02:00 committed by Tomasz Zawadzki
parent 5fbd7a9e55
commit 8109f45e1d

View File

@ -45,12 +45,11 @@ function tgt_check_notification_types() {
timing_enter "${FUNCNAME[0]}" timing_enter "${FUNCNAME[0]}"
local ret=0 local ret=0
local enabled_types="bdev_register local enabled_types=("bdev_register" "bdev_unregister")
bdev_unregister "
get_types=$(tgt_rpc notify_get_types | jq -r '.[]') local get_types=($(tgt_rpc notify_get_types | jq -r '.[]'))
if [ $enabled_types != $get_types ]; then if [[ ${enabled_types[*]} != "${get_types[*]}" ]]; then
echo "ERROR: expected types:" $enabled_types ", but got:" $get_types echo "ERROR: expected types: ${enabled_types[*]}, but got: ${get_types[*]}"
ret=1 ret=1
fi fi