[LTP] [PATCH 2/2] network/in6_02: Don't use default value for LHOST_IFACES
Petr Vorel
pvorel@suse.cz
Tue Apr 17 14:42:07 CEST 2018
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(-)
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;
}
--
2.16.3
More information about the ltp
mailing list