From patchwork Wed May 2 13:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 907546 X-Patchwork-Delegate: chrubis@suse.cz 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=213.254.12.146; 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 [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40bfgr268dz9ry1 for ; Wed, 2 May 2018 23:46:16 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 890CE3E70BE for ; Wed, 2 May 2018 15:46:13 +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 7A20E3E709C for ; Wed, 2 May 2018 15:46:11 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id C6FA01A00F6E for ; Wed, 2 May 2018 15:46:10 +0200 (CEST) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E062DACCD for ; Wed, 2 May 2018 13:46:09 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Wed, 2 May 2018 15:45:53 +0200 Message-Id: <20180502134553.5429-1-pvorel@suse.cz> X-Mailer: git-send-email 2.16.3 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_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] [RFC PATCH 1/1] tst_test.sh: TCONF on basename error when setting TST_ID X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" 'basename $0' fails when loaded in command line with bash (at least) as $0 is invalid ('-bash'): $ unset TST_ID; export TST_NO_DEFAULT_RUN=1; . tst_test.sh -bash: tst_ansi_color.sh: No such file or directory basename: invalid option -- 'b' Try 'basename --help' for more information. It's better to TCONF than be without TST_ID. NOTE: Sourcing tst_test.sh can be needed for network scripts: users might want to set network variables with tst_net.sh, which itself sources tst_test.sh. Signed-off-by: Petr Vorel --- testcases/lib/tst_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index 8d49d34b6..39744d29e 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -377,7 +377,8 @@ tst_run() } if [ -z "$TST_ID" ]; then - filename=$(basename $0) + filename=$(basename $0) || \ + tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix it with setting TST_ID before sourcing tst_test.sh" TST_ID=${filename%%.*} fi export TST_ID="$TST_ID"