Message ID | 20180417124207.4561-2-pvorel@suse.cz |
---|---|
State | Superseded |
Delegated to: | Alexey Kodanev |
Headers | show |
Series | None | expand |
On 04/17/2018 03:42 PM, Petr Vorel wrote: > in6_02 can be test without help of network.sh. In that case LHOST_IFACES > is not defined and "eth0" is used as default value. This can cause > failures. > I think the fix should be before the conversion to the new API, otherwise it unnecessary depends on it. > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > I'm not sure if we can make all C network tests make independent on > loading variables via tst_net.sh, but here it does not make much sense > to me to fail when it's not done. > --- > testcases/network/lib6/in6_02.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/testcases/network/lib6/in6_02.c b/testcases/network/lib6/in6_02.c > index e3deb7b7b..c00e5dc0c 100644 > --- a/testcases/network/lib6/in6_02.c > +++ b/testcases/network/lib6/in6_02.c > @@ -33,14 +33,13 @@ > > #define I2N_RNDCOUNT 10 /* random ints */ > #define I2N_LOWCOUNT 10 /* sequential from 0 */ > -#define DEFAULT_IFACE "eth0" > > static struct { > char *name; > int nonzero; > } test_case[] = { > { "lo", 1 }, > - { DEFAULT_IFACE, 1 }, > + { NULL, 1 }, > { "hoser75", 0 }, > { "6", 0 }, > }; > @@ -61,6 +60,8 @@ void if_nametoindex_test(void) > tst_res(TINFO, "IPv6 if_nametoindex() test"); > > for (i = 0; i < ARRAY_SIZE(test_case); ++i) { > + if (test_case[i].name == NULL) > + continue; What about using TCONF if it skips the test-case because LHOST_IFACE is not defined? Thanks, Alexey
Hi Alexey, > On 04/17/2018 03:42 PM, Petr Vorel wrote: > > in6_02 can be test without help of network.sh. In that case LHOST_IFACES > > is not defined and "eth0" is used as default value. This can cause > > failures. > I think the fix should be before the conversion to the new API, otherwise > it unnecessary depends on it. Agree, I'll fix it. ... > > for (i = 0; i < ARRAY_SIZE(test_case); ++i) { > > + if (test_case[i].name == NULL) > > + continue; > What about using TCONF if it skips the test-case because > LHOST_IFACE is not defined? I wanted to keep at least testing of if_nametoindex("lo"). Would be overkill in case of TCONF to create in6_02.sh which would just load tst_net.sh? I don't like the fact, that network C tests depend on being run via network.sh (unlike shell network tests). > Thanks, > Alexey Kind regards, Petr
On 04/18/2018 05:13 PM, Petr Vorel wrote: > Hi Alexey, > >> On 04/17/2018 03:42 PM, Petr Vorel wrote: >>> in6_02 can be test without help of network.sh. In that case LHOST_IFACES >>> is not defined and "eth0" is used as default value. This can cause >>> failures. > >> I think the fix should be before the conversion to the new API, otherwise >> it unnecessary depends on it. > Agree, I'll fix it. > > ... >>> for (i = 0; i < ARRAY_SIZE(test_case); ++i) { >>> + if (test_case[i].name == NULL) >>> + continue; > >> What about using TCONF if it skips the test-case because >> LHOST_IFACE is not defined? > I wanted to keep at least testing of if_nametoindex("lo"). > Would be overkill in case of TCONF to create in6_02.sh which would just load tst_net.sh? > I don't like the fact, that network C tests depend on being run via network.sh (unlike > shell network tests). Why it depends on network.sh? LHOST_IFACE is just an environment variable. It can be defined on the test machine already before the test is started, or with tst_net.sh. I mean, using TCONF for the LHOST_IFACE test-case, when the test in6_02, doesn't find the variable and skips it, then proceeds with the rest of test-cases.
Hi Alexey, > >> What about using TCONF if it skips the test-case because > >> LHOST_IFACE is not defined? > > I wanted to keep at least testing of if_nametoindex("lo"). > > Would be overkill in case of TCONF to create in6_02.sh which would just load tst_net.sh? > > I don't like the fact, that network C tests depend on being run via network.sh (unlike > > shell network tests). > Why it depends on network.sh? LHOST_IFACE is just an environment variable. > It can be defined on the test machine already before the test is started, > or with tst_net.sh. Yes, but that's what I doesn't like: you need to source tst_net.sh (either with network.sh or manually). Not a big issue, it's just you shouldn't run C tests like in6_02 without variables. This is different from other non-networking tests, which you can run as they are (without any preparation, setup). This is the reason I was thinking about wrapping any C test which need variables with shell script which source tst_net.sh for it. Kind regards, Petr
diff --git a/testcases/network/lib6/in6_02.c b/testcases/network/lib6/in6_02.c index e3deb7b7b..c00e5dc0c 100644 --- a/testcases/network/lib6/in6_02.c +++ b/testcases/network/lib6/in6_02.c @@ -33,14 +33,13 @@ #define I2N_RNDCOUNT 10 /* random ints */ #define I2N_LOWCOUNT 10 /* sequential from 0 */ -#define DEFAULT_IFACE "eth0" static struct { char *name; int nonzero; } test_case[] = { { "lo", 1 }, - { DEFAULT_IFACE, 1 }, + { NULL, 1 }, { "hoser75", 0 }, { "6", 0 }, }; @@ -61,6 +60,8 @@ void if_nametoindex_test(void) tst_res(TINFO, "IPv6 if_nametoindex() test"); for (i = 0; i < ARRAY_SIZE(test_case); ++i) { + if (test_case[i].name == NULL) + continue; TEST(if_nametoindex(test_case[i].name)); if (!TEST_RETURN != !test_case[i].nonzero) { tst_res(TFAIL, "if_nametoindex(\"%s\") %ld [should be %szero]", @@ -242,16 +243,16 @@ void setup(void) char *ifnames = getenv("LHOST_IFACES"); if (!ifnames) { - tst_res(TWARN, "LHOST_IFACES not defined, default to %s", DEFAULT_IFACE); + tst_res(TINFO, "LHOST_IFACES not defined, it will not be tested"); return; } static char name[256]; sscanf(ifnames, "%255s", name); - if (!strcmp(name, test_case[1].name)) + if (!strcmp(name, test_case[0].name)) return; - tst_res(TINFO, "change default '%s' name to '%s'", DEFAULT_IFACE, name); + tst_res(TINFO, "LHOST_IFACES \"%s\"", name); test_case[1].name = name; }
in6_02 can be test without help of network.sh. In that case LHOST_IFACES is not defined and "eth0" is used as default value. This can cause failures. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- I'm not sure if we can make all C network tests make independent on loading variables via tst_net.sh, but here it does not make much sense to me to fail when it's not done. --- testcases/network/lib6/in6_02.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)