From patchwork Fri Aug 9 07:52:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1144484 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 464ct33rgTz9s3Z for ; Fri, 9 Aug 2019 17:52:58 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A4C153C1D25 for ; Fri, 9 Aug 2019 09:52:54 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 255083C183A for ; Fri, 9 Aug 2019 09:52:52 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id D37F01A008A3 for ; Fri, 9 Aug 2019 09:52:50 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 88FFFB07B for ; Fri, 9 Aug 2019 07:52:49 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 9 Aug 2019 09:52:44 +0200 Message-Id: <20190809075244.17950-1-pvorel@suse.cz> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] tst_test.sh: Reduce false positives in reserved variable warnings X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" "Reserved variable TST_FOO used!" and "Private variable or function _tst_foo used!" reports some false positive. Filter out commented code and variables and functions not starting with searched prefix (foo_tst_bar() or $foo_tst_bar). NOTE: There are still some false positives (e.g. echo "echo TST_SHOULD_NOT_BE_FOUND"), but let's not complicate the regexp too much. Signed-off-by: Petr Vorel --- testcases/lib/tst_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index 31b3a3951..f779cc471 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -402,7 +402,7 @@ tst_run() local _tst_name if [ -n "$TST_TEST_PATH" ]; then - for _tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do case "$_tst_i" in DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);; @@ -417,7 +417,7 @@ tst_run() esac done - for _tst_i in $(grep _tst_ "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do tst_res TWARN "Private variable or function _tst_$_tst_i used!" done fi