net/host: update to new api
PATCH v2 1/1 net/host: update to new api
Fix awk field separator parsing.
Clean test by removing loop and stderr redirection
Signed-off-by Kory Maincent <[email protected]>
---
Changes since v1:
- Remove tst_setup, loop test and stderr redirection
- Remove RHOST and rename rhost
testcases/network/tcp_cmds/host/host01.sh | 94 +++++------------------ 1 file changed, 18 insertions(+), 76 deletions(-)
testcases/network/tcp_cmds/host/host01.sh +18 -76
@@ -1,87 +1,29 @@ #!/bin/sh # -# Copyright (c) International Business Machines Corp., 2000 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# -# -# -# FILE : host -# -# PURPOSE: To test the basic functionality of the `host` command. -# -# SETUP: If "RHOST" is not exported, then the local hostname is used. -# -# HISTORY: -# 06/06/03 Manoj Iyer [email protected] -# - Modified to use LTP tests APIs -# 03/01 Robbie Williamson ([email protected]) -# -Ported -# -# -#----------------------------------------------------------------------- - -do_setup() -{ - NUMLOOPS=${NUMLOOPS:-1} - SLEEPTIME=${SLEEPTIME:-0} +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) K?ry Maincent <[email protected]> 2020 +# Copyright (c) Manoj Iyer <[email protected]> 2003 +# Copyright (c) Robbie Williamson <[email protected]> 2001 +# Copyright (c) International Business Machines Corp., 2000 - tst_setup +TST_TESTFUNC="do_test" +TST_NEEDS_CMDS="awk host hostname" - exists awk host hostname - - RHOST=${RHOST:-`hostname`} - -} - -#----------------------------------------------------------------------- -# -# FUNCTION: do_test -# -#----------------------------------------------------------------------- +. tst_net.sh do_test() { + local test_host=$(hostname) + local test_host_addr - tst_resm TINFO "test basic functionality of the \`$TC' command." - - while [ $TST_COUNT -lt $NUMLOOPS ]; do - - if rhost_addr=$(host $RHOST); then - rhost_addr=$(echo "$rhost_addr" | awk -F, '{print $NF}') >/dev/null 2>&1 - if ! host $rhost_addr >/dev/null 2>&1; then - end_testcase "reverse lookup with host failed" - fi - - else - end_testcase "host $RHOST on local machine failed" - fi - - incr_tst_count - sleep $SLEEPTIME - - done + tst_res TINFO "test basic functionality of the host command." + if test_host_addr=$(host $test_host); then + test_host_addr=$(echo "$test_host_addr" | awk '{print $NF}') >/dev/null + EXPECT_PASS host $test_host_addr \>/dev/null + else + tst_brk TFAIL "host $test_host on local machine failed" + fi } -#----------------------------------------------------------------------- -# FUNCTION: MAIN -#----------------------------------------------------------------------- -. net_cmdlib.sh - -read_opts $* -do_setup -do_test -end_testcase +tst_run
Signature · 1 line
2.17.1
PATCH v2 1/1 net/host: update to new api
Hi Kory,
Quoted 2 lines
Fix awk field separator parsing.
Clean test by removing loop and stderr redirection
Marged slightly adjusted version (using tabs and shorter variable names).
Thanks!
Kind regards,
Petr