All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] net/host: update to new api
Date: Mon, 16 Nov 2020 19:41:43 +0100	[thread overview]
Message-ID: <20201116184143.GA171432@pevik> (raw)
In-Reply-To: <20201116101840.15433-1-kory.maincent@bootlin.com>

Hi Kory,

thanks for your patch.
...
>  do_test()
>  {

> -    tst_resm TINFO "test basic functionality of the \`$TC' command."
> +    tst_res TINFO "test basic functionality of the host command."

> -    while [ $TST_COUNT -lt $NUMLOOPS ]; do
> +    while [ $TST_COUNT -le $NUMLOOPS ]; do
IMHO there is no need to have loop like this.
If required, we'd just add -iN parameter to it in the runtest file (where N is
<1,max int), but IMHO it's enough to test host only once.

>          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
> -
> +            rhost_addr=$(echo "$rhost_addr" | awk '{print $NF}') >/dev/null 2>&1
> +            EXPECT_PASS host $rhost_addr \>/dev/null 2>&1
We need to redirect also second > and &:
EXPECT_PASS host $rhost_addr \>/dev/null 2\>\&1

>          else
> -            end_testcase "host $RHOST on local machine failed"
> +            tst_brk TFAIL "host $RHOST on local machine failed"
>          fi

> -        incr_tst_count
> +        TST_COUNT=$((TST_COUNT + 1))
>          sleep $SLEEPTIME
Also sleep time is not really needed.

...

Can I merge this simplified variant?

Kind regards,
Petr

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) K?ry Maincent <kory.maincent@bootlin.com> 2020
# Copyright (c) Manoj Iyer <manjo@mail.utexas.edu> 2003
# Copyright (c) Robbie Williamson <robbiew@us.ibm.com> 2001
# Copyright (c) International Business Machines  Corp., 2000

TST_TESTFUNC="do_test"
TST_NEEDS_CMDS="awk host hostname"

. tst_net.sh

do_test()
{
	local rhost=${RHOST:-$(hostname)}
	local rhost_addr

    tst_res TINFO "test basic functionality of the host command"

	if rhost_addr=$(host $rhost); then
		rhost_addr=$(echo "$rhost_addr" | awk '{print $NF}')
		EXPECT_PASS host $rhost_addr \>/dev/null 2\>\&1
	else
		tst_brk TFAIL "host $rhost on local machine failed"
	fi
}

tst_run

  reply	other threads:[~2020-11-16 18:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 10:18 [LTP] [PATCH] net/host: update to new api Kory Maincent
2020-11-16 18:41 ` Petr Vorel [this message]
2020-11-16 18:48   ` Petr Vorel
2020-11-17  8:33     ` =?unknown-8bit?q?K=C3=B6ry?= Maincent
2020-11-17  9:39   ` Alexey Kodanev
2020-11-17 11:30     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201116184143.GA171432@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.