From patchwork Fri Apr 20 07:21:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 901694 X-Patchwork-Delegate: akodanev@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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S6jj6qg3z9s1t for ; Fri, 20 Apr 2018 17:21:42 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D13B23E6B1F for ; Fri, 20 Apr 2018 09:21:38 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id C7EB13E6AC7 for ; Fri, 20 Apr 2018 09:21:36 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id F050A1001980 for ; Fri, 20 Apr 2018 09:21:33 +0200 (CEST) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE152AD63; Fri, 20 Apr 2018 07:21:32 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 20 Apr 2018 09:21:21 +0200 Message-Id: <20180420072122.16897-1-pvorel@suse.cz> X-Mailer: git-send-email 2.16.3 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH v3 1/2] network/in6_02: Don't use default value for LHOST_IFACES 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" In case of LHOST_IFACES not being defined was 'eth0' used as default. Although eth0 is common iface, we cannot guarantee it, therefore skip testing it. Also check sscanf return value to catch whitespace only. Signed-off-by: Petr Vorel --- testcases/network/lib6/in6_02.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/testcases/network/lib6/in6_02.c b/testcases/network/lib6/in6_02.c index 7cb362666..e1a71d987 100644 --- a/testcases/network/lib6/in6_02.c +++ b/testcases/network/lib6/in6_02.c @@ -34,7 +34,7 @@ static struct { int nonzero; } n2i[] = { { "lo", 1 }, - { "eth0", 1 }, + { NULL, 1 }, { "hoser75", 0 }, { "6", 0 }, }; @@ -80,6 +80,11 @@ void n2itest(void) char ifname[IF_NAMESIZE], *pifn; for (i = 0; i < N2I_COUNT; ++i) { + if (n2i[i].name == NULL) { + tst_resm(TCONF, "LHOST_IFACES not defined or invalid, skip testing it"); + return; + } + TEST(if_nametoindex(n2i[i].name)); if (!TEST_RETURN != !n2i[i].nonzero) { tst_resm(TFAIL, "if_nametoindex(\"%s\") %ld " @@ -256,22 +261,17 @@ void setup(void) { TEST_PAUSE; - tst_resm(TINFO, "get interface name from LHOST_IFACES var"); - char *ifnames = getenv("LHOST_IFACES"); - - if (!ifnames) { - tst_resm(TWARN, "LHOST_IFACES not defined, default to eth0"); + if (!ifnames) return; - } static char name[256]; + int ret; - sscanf(ifnames, "%255s", name); - - if (!strcmp(name, n2i[1].name)) + ret = sscanf(ifnames, "%255s", name); + if (ret == -1) return; - tst_resm(TINFO, "change default 'eth0' name to '%s'", name); + tst_resm(TINFO, "get interface name from LHOST_IFACES: '%s'", name); n2i[1].name = name; }