aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ananyev <konstantin.ananyev@intel.com>2017-05-09 18:09:18 +0000
committerGerrit Code Review <gerrit@fd.io>2017-05-09 18:09:18 +0000
commit8d020909941acca43cf7e772a99682a894347526 (patch)
tree8cfe147125735d74a4d7f9e24935daf3d93d7f3e
parent36d90e3aa7ad9a72f7acbefa4d409a71d78bfd25 (diff)
parent68f21c315fccc74ee6bec7e3b19da253d2afbf60 (diff)
Merge "tldk_test: added copy command to makefile to make test_scapy_gen.py visible"
-rw-r--r--test/gtest/Makefile2
-rw-r--r--test/gtest/main.cpp9
-rw-r--r--test/gtest/test_common.h2
-rw-r--r--test/gtest/test_tle_udp_stream_gen.h3
4 files changed, 14 insertions, 2 deletions
diff --git a/test/gtest/Makefile b/test/gtest/Makefile
index 65434e8..648c233 100644
--- a/test/gtest/Makefile
+++ b/test/gtest/Makefile
@@ -79,6 +79,8 @@ SRCS-y += test_tle_udp_stream_gen.cpp
SRCS-y += test_tle_tcp_stream.cpp
#SRCS-y += test_tle_tcp_stream_gen.cpp
+SYMLINK-y-app += test_scapy_gen.py
+
CXXFLAGS += -std=c++11
ifeq ($(shell test $(GCC_VERSION) -lt 50 && echo 1), 1)
diff --git a/test/gtest/main.cpp b/test/gtest/main.cpp
index 17cdccd..53dcf78 100644
--- a/test/gtest/main.cpp
+++ b/test/gtest/main.cpp
@@ -28,12 +28,14 @@
#include "test_common.h"
struct rte_mempool *mbuf_pool;
+char binpath[PATH_MAX];
int
main(int argc, char *argv[])
{
uint8_t nb_ports = 1;
int rc = 0;
+ char *slash;
/* Initialize GoogleTest&Mock and parse any args */
testing::InitGoogleMock(&argc, argv);
@@ -44,6 +46,13 @@ main(int argc, char *argv[])
argc -= ret;
argv += ret;
+ /* get the path of binary and save in a global variable to be used later*/
+ realpath(argv[0], binpath);
+ slash = NULL;
+ slash = strrchr(binpath, '/');
+ if (strcmp(binpath, "") != 0 && slash != NULL)
+ binpath[slash - binpath] = 0;
+
/*
* Creates a new mempool in memory to hold the mbufs.
* Multiplied by 2 because of mempeool to be used for packet
diff --git a/test/gtest/test_common.h b/test/gtest/test_common.h
index 2eb93e4..a7fa41a 100644
--- a/test/gtest/test_common.h
+++ b/test/gtest/test_common.h
@@ -45,6 +45,8 @@
extern struct rte_mempool *mbuf_pool;
extern struct rte_mempool *frag_mp;
+extern char binpath[PATH_MAX];
+
int port_init(uint8_t port, struct rte_mempool *mbuf_pool);
uint64_t
diff --git a/test/gtest/test_tle_udp_stream_gen.h b/test/gtest/test_tle_udp_stream_gen.h
index 294e37c..0f3d11b 100644
--- a/test/gtest/test_tle_udp_stream_gen.h
+++ b/test/gtest/test_tle_udp_stream_gen.h
@@ -345,7 +345,7 @@ test_tle_udp_gen_base::prepare_pcaps(string l_ip, string r_ip, int l_port,
string py_cmd;
/* generate pcap rx & tx files * for tests using scapy */
- py_cmd = "python ./test/gtest/test_scapy_gen.py ";
+ py_cmd = "python " + string(binpath) + "/test_scapy_gen.py ";
py_cmd = py_cmd + " " + l_ip + " " + r_ip + " " +
to_string(l_port) + " " + to_string(r_port) + " " +
to_string(nb_pkts);
@@ -356,7 +356,6 @@ test_tle_udp_gen_base::prepare_pcaps(string l_ip, string r_ip, int l_port,
py_cmd = py_cmd + " -bc4 " + to_string(l4_chksum);
py_cmd = py_cmd + " " + rx_pcap_dest;
system(py_cmd.c_str());
-
return 0;
}