From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] netns_helper: Make iproute version check work correctly
Date: Tue, 9 Feb 2021 15:56:27 +0100 [thread overview]
Message-ID: <YCKim8Pvg+ZTrHXI@rei> (raw)
In-Reply-To: <1612772078-29651-1-git-send-email-zhufy.jy@cn.fujitsu.com>
Hi!
> diff --git a/testcases/kernel/containers/netns/netns_helper.h b/testcases/kernel/containers/netns/netns_helper.h
> index 8b87645..8337051 100644
> --- a/testcases/kernel/containers/netns/netns_helper.h
> +++ b/testcases/kernel/containers/netns/netns_helper.h
> @@ -37,6 +37,7 @@ static void check_iproute(unsigned int spe_ipver)
> FILE *ipf;
> int n;
> unsigned int ipver = 0;
> + char ver;
>
> ipf = popen("ip -V", "r");
> if (ipf == NULL)
> @@ -44,7 +45,14 @@ static void check_iproute(unsigned int spe_ipver)
> "Failed while opening pipe for iproute check");
>
> n = fscanf(ipf, "ip utility, iproute2-ss%u", &ipver);
> + pclose(ipf);
> if (n < 1) {
> + ipf = popen("ip -V", "r");
> + n = fscanf(ipf, "ip utility, iproute2-%s", &ver);
> + if (n >= 1) {
> + pclose(ipf);
> + return;
> + }
Can we please instead read the whole string after the dash (-), skip
the 'ss' prefix when present and then convert the string into an
itneger?
There is absolutely no reason to run the command twice.
> static int dummy(void *arg)
> diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
> index a5b77a0..bec43ac 100755
> --- a/testcases/kernel/containers/netns/netns_helper.sh
> +++ b/testcases/kernel/containers/netns/netns_helper.sh
> @@ -50,6 +50,15 @@ tst_check_iproute()
> local cur_ipver="$(ip -V)"
> local spe_ipver="$1"
>
> + echo $cur_ipver | grep "ip utility, iproute2-ss" > /dev/null
> + ret1=$?
> + echo $cur_ipver | grep "ip utility, iproute2-" > /dev/null
> + ret2=$?
> +
> + if [ $ret1 -ne 0 -a $ret2 -eq 0 ]; then
> + return
> + fi
How is this supposed to fix the problem?
This just skips the test if we haven't found one of the strings in the
version, right? Which is wrong anyway.
> cur_ipver=${cur_ipver##*s}
But the version here is still wrong if the original string haven't
contained the ss. We would end up with cur_ipver with iproute2-123456,
which will be used in the numerical comparsion.
> if [ -z "$cur_ipver" -o -z "$spe_ipver" ]; then
> --
> 1.8.3.1
>
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-02-09 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 8:14 [LTP] [PATCH] netns_helper: Make iproute version check work correctly Feiyu Zhu
2021-02-09 14:56 ` Cyril Hrubis [this message]
2021-02-09 15:55 ` Cyril Hrubis
2021-02-10 8:07 ` Petr Vorel
2021-02-10 13:38 ` 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=YCKim8Pvg+ZTrHXI@rei \
--to=chrubis@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.