systemd can rename network interfaces. We should look at LHOST_IFACES
variable for predefined test interface names.

Signed-off-by: Alexey Kodanev <alexey.koda...@oracle.com>
---
 testcases/network/lib6/in6_02.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/testcases/network/lib6/in6_02.c b/testcases/network/lib6/in6_02.c
index fea1827..dadb2a5 100644
--- a/testcases/network/lib6/in6_02.c
+++ b/testcases/network/lib6/in6_02.c
@@ -255,4 +255,36 @@ void initest(void)
 void setup(void)
 {
        TEST_PAUSE;
+
+       tst_resm(TINFO, "get interface name from LHOST_IFACES var");
+
+       char *ifnames = getenv("LHOST_IFACES");
+
+       if (!ifnames) {
+               tst_resm(TWARN, "LHOST_IFACES not defined, default to eth0");
+               return;
+       }
+
+       char *end = strchr(ifnames, ' ');
+
+       if (!end)
+               end = strchr(ifnames, '\0');
+
+       if (!end || end <= ifnames)
+               return;
+
+       size_t size = end - ifnames + 1;
+
+       char *name = malloc(size);
+
+       strncpy(name, ifnames, size - 1);
+       name[size] = '\0';
+
+       if (!strcmp(name, n2i[1].name)) {
+               free(name);
+               return;
+       }
+
+       tst_resm(TINFO, "change default 'eth0' name to '%s'", name);
+       n2i[1].name = name;
 }
-- 
1.7.1


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to