From patchwork Tue Jun 19 20:23:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10475407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F5B8601D7 for ; Tue, 19 Jun 2018 20:24:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F79A286B2 for ; Tue, 19 Jun 2018 20:24:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2486028BE8; Tue, 19 Jun 2018 20:24:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2033286B2 for ; Tue, 19 Jun 2018 20:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030414AbeFSUYm (ORCPT ); Tue, 19 Jun 2018 16:24:42 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43081 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757240AbeFSUYJ (ORCPT ); Tue, 19 Jun 2018 16:24:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1529439849; x=1560975849; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CybRuskoOwq1T6IFz1OdSv5Sv7Y5u9ia59jPKbCHKdc=; b=k7+3y0NsOtf+tFINctyZ182R3KAbUumrtbQsaR/75AjIZGgz0j7AhFLW ArvgyNnqyAmGpO7PZxHqPyk0NaMI75b2x05W6tyeMo1FxTkEYB2pppGKG i+KWRmDjjvHzZPj2OPaB5XPbRS59gww3vfv323jI68XdGOIL+AZ7X7JD8 D/d+ZbZUQZLhFNd31UBqdZJ3Tj7EkW2R0EcGDOPCs1u3/GaTSUPMkfS04 5mEOBS+EkPiz7EsxT9vXhLAp594AN3DCClpfRODPAn0bC/u8qb/iLC3AV Y0GhV0wVDPiLXFLSkSnR8LrhF+KhiJSX9muq/vj30Boz0eZ1OhaVpALFL g==; X-IronPort-AV: E=Sophos;i="5.51,244,1526313600"; d="scan'208";a="81403676" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2018 04:23:55 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 19 Jun 2018 13:13:47 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Jun 2018 13:23:55 -0700 From: Bart Van Assche To: Omar Sandoval Cc: linux-block@vger.kernel.org, Bart Van Assche Subject: [PATCH 3/9] check, tests/meta/012: Use array["index"] instead of array[index] Date: Tue, 19 Jun 2018 13:23:47 -0700 Message-Id: <20180619202353.23631-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619202353.23631-1-bart.vanassche@wdc.com> References: <20180619202353.23631-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This causes shellcheck to stop complaining about these array element accesses. Signed-off-by: Bart Van Assche Reviewed-by: Johannes Thumshirn --- check | 46 +++++++++++++++++++++++----------------------- tests/meta/012 | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/check b/check index 5e1ba7bc8401..5f53fa105f72 100755 --- a/check +++ b/check @@ -156,11 +156,11 @@ declare -A TEST_RUN _read_last_test_run() { local seqres="${RESULTS_DIR}/${TEST_NAME}" - LAST_TEST_RUN[date]="" - LAST_TEST_RUN[status]="" - LAST_TEST_RUN[reason]="" - LAST_TEST_RUN[exit_status]="" - LAST_TEST_RUN[runtime]="" + LAST_TEST_RUN["date"]="" + LAST_TEST_RUN["status"]="" + LAST_TEST_RUN["reason"]="" + LAST_TEST_RUN["exit_status"]="" + LAST_TEST_RUN["runtime"]="" if [[ ! -e $seqres ]]; then return @@ -247,9 +247,9 @@ _output_test_run() { fi if [[ -v TEST_DEV ]]; then - _output_status "$TEST_NAME => $(basename "$TEST_DEV")" "${TEST_RUN[status]}ed" + _output_status "$TEST_NAME => $(basename "$TEST_DEV")" "${TEST_RUN["status"]}ed" else - _output_status "$TEST_NAME" "${TEST_RUN[status]}ed" + _output_status "$TEST_NAME" "${TEST_RUN["status"]}ed" fi ( @@ -306,14 +306,14 @@ _call_test() { _read_last_test_run _output_last_test_run - TEST_RUN[date]="$(date "+%F %T")" + TEST_RUN["date"]="$(date "+%F %T")" mkdir -p "$(dirname "$seqres")" # Remove leftovers from last time. rm -f "${seqres}" "${seqres}."* if [[ -w /dev/kmsg ]]; then - local dmesg_marker="run blktests $TEST_NAME at ${TEST_RUN[date]}" + local dmesg_marker="run blktests $TEST_NAME at ${TEST_RUN["date"]}" echo "$dmesg_marker" >> /dev/kmsg else local dmesg_marker="" @@ -328,35 +328,35 @@ _call_test() { TIMEFORMAT="%Rs" pushd . >/dev/null || return { time "$test_func" >"${seqres}.out" 2>&1; } 2>"${seqres}.runtime" - TEST_RUN[exit_status]=$? + TEST_RUN["exit_status"]=$? popd >/dev/null || return - TEST_RUN[runtime]="$(cat "${seqres}.runtime")" + TEST_RUN["runtime"]="$(cat "${seqres}.runtime")" rm -f "${seqres}.runtime" _cleanup if ! diff "tests/${TEST_NAME}.out" "${seqres}.out" >/dev/null; then mv "${seqres}.out" "${seqres}.out.bad" - TEST_RUN[status]=fail - TEST_RUN[reason]=output - elif [[ ${TEST_RUN[exit_status]} -ne 0 ]]; then - TEST_RUN[status]=fail - TEST_RUN[reason]="exit" + TEST_RUN["status"]=fail + TEST_RUN["reason"]=output + elif [[ ${TEST_RUN["exit_status"]} -ne 0 ]]; then + TEST_RUN["status"]=fail + TEST_RUN["reason"]="exit" elif ! _check_dmesg "$dmesg_marker"; then - TEST_RUN[status]=fail - TEST_RUN[reason]=dmesg + TEST_RUN["status"]=fail + TEST_RUN["reason"]=dmesg else - TEST_RUN[status]=pass + TEST_RUN["status"]=pass fi rm -f "${seqres}.out" _write_test_run _output_test_run - if [[ ${TEST_RUN[status]} = pass ]]; then + if [[ ${TEST_RUN["status"]} = pass ]]; then return 0 else - case "${TEST_RUN[reason]}" in + case "${TEST_RUN["reason"]}" in output) diff -u "tests/${TEST_NAME}.out" "${seqres}.out.bad" | awk " { @@ -369,7 +369,7 @@ _call_test() { }" ;; exit) - echo " exited with status ${TEST_RUN[exit_status]}" + echo " exited with status ${TEST_RUN["exit_status"]}" ;; dmesg) echo " something found in dmesg:" @@ -432,7 +432,7 @@ _run_test() { _run_group() { local tests=("$@") - local group="${tests[0]%/*}" + local group="${tests["0"]%/*}" # shellcheck disable=SC1090 . "tests/${group}/group" diff --git a/tests/meta/012 b/tests/meta/012 index fcf8fbdde2aa..ab8c2a73eaa5 100755 --- a/tests/meta/012 +++ b/tests/meta/012 @@ -22,8 +22,8 @@ DESCRIPTION="record pid and random junk" test() { echo "Running ${TEST_NAME}" sleep 1 - TEST_RUN[pid]=$$ - TEST_RUN[random]="$(od -N $((4 * (RANDOM % 4))) -An -vtx1 /dev/urandom | tr -d ' \n')" + TEST_RUN["pid"]=$$ + TEST_RUN["random"]="$(od -N $((4 * (RANDOM % 4))) -An -vtx1 /dev/urandom | tr -d ' \n')" TEST_RUN[$$]=hello echo "Test complete" }