From: Alexey Kodanev <alexey.kodanev@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] network/in6_02: Rewrite to the new library
Date: Wed, 18 Apr 2018 16:50:22 +0300 [thread overview]
Message-ID: <4961ba79-c603-5073-b1f8-65a135afcec4@oracle.com> (raw)
In-Reply-To: <20180417124207.4561-1-pvorel@suse.cz>
On 04/17/2018 03:42 PM, Petr Vorel wrote:
...
> +
> + for (i = 0; i < ARRAY_SIZE(test_case); ++i) {
> + TEST(if_nametoindex(test_case[i].name));
> + if (!TEST_RETURN != !test_case[i].nonzero) {
> + tst_res(TFAIL, "if_nametoindex(\"%s\") %ld [should be %szero]",
> + test_case[i].name, TEST_RETURN, test_case[i].nonzero ? "non"
> + : "");
> return;
> }
> if (TEST_RETURN) {
> pifn = if_indextoname(TEST_RETURN, ifname);
> - if (!pifn || strcmp(n2i[i].name, pifn)) {
> - tst_resm(TFAIL, "if_nametoindex(\"%s\") %ld "
> - "doesn't match if_indextoname(%ld) "
> - "\"%s\"", n2i[i].name, TEST_RETURN,
> - TEST_RETURN, pifn ? pifn : "");
> + if (!pifn || strcmp(test_case[i].name, pifn)) {
> + tst_res(TFAIL,
> + "if_nametoindex(\"%s\") %ld doesn't match if_indextoname(%ld) \"%s\"",
Hi Petr,
It would better to replace all occurrence of \" with '. Or even without it,
if it is inside parenthesis.
> + test_case[i].name, TEST_RETURN, TEST_RETURN, pifn ? pifn
> + : "");
> return;
> }
> }
> - tst_resm(TINFO, "if_nametoindex(\"%s\") %ld",
> - n2i[i].name, TEST_RETURN);
> + tst_res(TINFO, "if_nametoindex(\"%s\") %ld",
> + test_case[i].name, TEST_RETURN);
> }
>
> - tst_resm(TPASS, "if_nametoindex() tests succeed");
> + tst_res(TPASS, "if_nametoindex() test succeed");
> }
>
> -int sub_i2ntest(unsigned int if_index)
> +int sub_if_indextoname_test(unsigned int if_index)
Should the functions be static in this test?
> {
> char ifname[IF_NAMESIZE];
> unsigned int idx;
> @@ -112,41 +93,42 @@ int sub_i2ntest(unsigned int if_index)
> TEST((ifname == if_indextoname(if_index, ifname)));
> if (!TEST_RETURN) {
> if (TEST_ERRNO != ENXIO) {
> - tst_resm(TFAIL, "if_indextoname(%d) returns %ld "
> - "but errno %d != ENXIO", if_index, TEST_RETURN,
> - TEST_ERRNO);
> + tst_res(TFAIL,
> + "if_indextoname(%d) returns %ld but errno %d != ENXIO",
> + if_index, TEST_RETURN, TEST_ERRNO);
> return 0;
> }
> - tst_resm(TINFO, "if_indextoname(%d) returns NULL", if_index);
> + tst_res(TINFO, "if_indextoname(%d) returns NULL", if_index);
> return 1;
> }
> /* else, a valid interface-- double check name */
> idx = if_nametoindex(ifname);
> if (idx != if_index) {
> - tst_resm(TFAIL, "if_indextoname(%u) returns \"%s\" but "
> - "doesn't if_nametoindex(\"%s\") returns %u",
> - if_index, ifname, ifname, idx);
> + tst_res(TFAIL,
> + "if_indextoname(%u) returns \"%s\" but doesn't if_nametoindex(\"%s\") returns %u",
> + if_index, ifname, ifname, idx);
> return 0;
> }
> - tst_resm(TINFO, "if_indextoname(%d) returns \"%s\"", if_index, ifname);
> + tst_res(TINFO, "if_indextoname(%d) returns \"%s\"", if_index, ifname);
> return 1;
> }
>
...
> +
> +static void do_test(unsigned int i)
> +{
> + (*testfunc[i])();
It can be just testfunc[i]()
Thanks,
Alexey
prev parent reply other threads:[~2018-04-18 13:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 12:42 [LTP] [PATCH 1/2] network/in6_02: Rewrite to the new library Petr Vorel
2018-04-17 12:42 ` [LTP] [PATCH 2/2] network/in6_02: Don't use default value for LHOST_IFACES Petr Vorel
2018-04-18 14:00 ` Alexey Kodanev
2018-04-18 14:13 ` Petr Vorel
2018-04-18 14:56 ` Alexey Kodanev
2018-04-20 8:15 ` Petr Vorel
2018-04-18 13:50 ` Alexey Kodanev [this message]
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=4961ba79-c603-5073-b1f8-65a135afcec4@oracle.com \
--to=alexey.kodanev@oracle.com \
--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.