From patchwork Fri Dec 7 12:35:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1009400 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43BBlN3vJdz9s1c for ; Fri, 7 Dec 2018 23:35:44 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D5D833E6FC7 for ; Fri, 7 Dec 2018 13:35:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 528453E6E62 for ; Fri, 7 Dec 2018 13:35:29 +0100 (CET) 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-2.smtp.seeweb.it (Postfix) with ESMTPS id A394760135E for ; Fri, 7 Dec 2018 13:35:28 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D2CE0AF71; Fri, 7 Dec 2018 12:35:27 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 7 Dec 2018 13:35:13 +0100 Message-Id: <20181207123516.30867-4-pvorel@suse.cz> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207123516.30867-1-pvorel@suse.cz> References: <20181207123516.30867-1-pvorel@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.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-2.smtp.seeweb.it Cc: Marcus Meissner , Petr Cervinka Subject: [LTP] [PATCH v2 3/6] net/dhcp: Move print_dhcp_log() into dhcp library 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Create default path for log file, but allow test to specify it. This is needed for AppArmor respected paths, which was already defined in 3e76b9896 ("net/dhcp: Use paths allowed by AppArmor for dnsmasq"). Also check if file exists. This is needed for dnsmasq --log-facility switch when AppArmor enabled, because according to dnsmasq(8) errors whilst reading configuration will still go to syslog. And then error report of cat of missing file is misleading. Signed-off-by: Petr Vorel --- testcases/network/dhcp/dhcp_lib.sh | 7 +++++++ testcases/network/dhcp/dhcpd_tests.sh | 7 +------ testcases/network/dhcp/dnsmasq_tests.sh | 5 ----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh index 08838a479..d46f86db7 100755 --- a/testcases/network/dhcp/dhcp_lib.sh +++ b/testcases/network/dhcp/dhcp_lib.sh @@ -38,6 +38,8 @@ stop_dhcp() dhcp_lib_setup() { + [ -z "$log" ] && log="$PWD/$(basename $0 '.sh').log" + if [ $TST_IPV6 ]; then ip_addr="fd00:1:1:2::12/64" ip_addr_check="fd00:1:1:2::100/64" @@ -89,6 +91,11 @@ dhcp_lib_cleanup() [ "$veth_loaded" = "no" ] && lsmod | grep -q '^veth ' && rmmod veth } +print_dhcp_log() +{ + [ -f "$log" ] && cat $log +} + test01() { local wicked diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh index ff46b825d..e8339932b 100755 --- a/testcases/network/dhcp/dhcpd_tests.sh +++ b/testcases/network/dhcp/dhcpd_tests.sh @@ -31,7 +31,7 @@ setup_dhcpd_conf() start_dhcpd() { touch tst_hdcpd.lease - dhcpd -lf tst_hdcpd.lease -$TST_IPVER $iface0 > tst_dhcpd.err 2>&1 + dhcpd -lf tst_hdcpd.lease -$TST_IPVER $iface0 > $log 2>&1 } start_dhcp() @@ -69,11 +69,6 @@ cleanup_dhcp() [ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF } -print_dhcp_log() -{ - cat tst_dhcpd.err -} - print_dhcp_version() { dhcpd --version 2>&1 diff --git a/testcases/network/dhcp/dnsmasq_tests.sh b/testcases/network/dhcp/dnsmasq_tests.sh index 24368fd33..284c3cce1 100755 --- a/testcases/network/dhcp/dnsmasq_tests.sh +++ b/testcases/network/dhcp/dnsmasq_tests.sh @@ -52,11 +52,6 @@ cleanup_dhcp() [ "$remove_lease_dir" = 1 ] && rm -r $lease_dir } -print_dhcp_log() -{ - cat $log -} - print_dhcp_version() { dnsmasq --version | head -2