From 8109f45e1d73dd14a7a15242f68d4b8a008b9d65 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 15 Apr 2020 12:16:41 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1864 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Shuhei Matsumoto --- test/json_config/json_config.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/json_config/json_config.sh b/test/json_config/json_config.sh index e51910cb7..e269fc50e 100755 --- a/test/json_config/json_config.sh +++ b/test/json_config/json_config.sh @@ -45,12 +45,11 @@ function tgt_check_notification_types() { timing_enter "${FUNCNAME[0]}" local ret=0 - local enabled_types="bdev_register - bdev_unregister " + local enabled_types=("bdev_register" "bdev_unregister") - get_types=$(tgt_rpc notify_get_types | jq -r '.[]') - if [ $enabled_types != $get_types ]; then - echo "ERROR: expected types:" $enabled_types ", but got:" $get_types + local get_types=($(tgt_rpc notify_get_types | jq -r '.[]')) + if [[ ${enabled_types[*]} != "${get_types[*]}" ]]; then + echo "ERROR: expected types: ${enabled_types[*]}, but got: ${get_types[*]}" ret=1 fi