[v12,5/5] example: l2fwd_simple: do operations to increase code coverage

Message ID 1515596425-24694-6-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series
  • linux-generic: pktio: add null pktio support
Related show

Commit Message

Github ODP bot Jan. 10, 2018, 3 p.m.
From: Juha-Matti Tilli <juha-matti.tilli@iki.fi>


Do some MTU, promiscuous mode and MAC address related operations in
odp_l2fwd_simple to increase code coverage.

Signed-off-by: Juha-Matti Tilli <juha-matti.tilli@iki.fi>

---
/** Email created from pull request 365 (jmtilli:nullpktio)
 ** https://github.com/Linaro/odp/pull/365
 ** Patch: https://github.com/Linaro/odp/pull/365.patch
 ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea
 ** Merge commit sha: b7570030cbadfa847595dcf4adec3ef33cea31c5
 **/
 example/l2fwd_simple/odp_l2fwd_simple.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch

diff --git a/example/l2fwd_simple/odp_l2fwd_simple.c b/example/l2fwd_simple/odp_l2fwd_simple.c
index ad8661717..c74a523a6 100644
--- a/example/l2fwd_simple/odp_l2fwd_simple.c
+++ b/example/l2fwd_simple/odp_l2fwd_simple.c
@@ -145,6 +145,8 @@  int main(int argc, char **argv)
 	odph_odpthread_params_t thr_params;
 	int opt;
 	int long_index;
+	odph_ethaddr_t correct_src;
+	uint32_t mtu1, mtu2;
 
 	static const struct option longopts[] = { {NULL, 0, NULL, 0} };
 	static const char *shortopts = "";
@@ -204,6 +206,23 @@  int main(int argc, char **argv)
 	global.if1 = create_pktio(argv[optind + 1], pool, &global.if1in,
 								&global.if1out);
 
+	/* Do some operations to increase code coverage in tests */
+	if (odp_pktio_mac_addr(global.if0, &correct_src, sizeof(correct_src))
+	    != sizeof(correct_src))
+		printf("Warning: can't get MAC address\n");
+	else if (memcmp(&correct_src, &global.src, sizeof(correct_src)) != 0)
+		printf("Warning: src MAC invalid\n");
+
+	odp_pktio_promisc_mode_set(global.if0, true);
+	odp_pktio_promisc_mode_set(global.if1, true);
+	(void)odp_pktio_promisc_mode(global.if0);
+	(void)odp_pktio_promisc_mode(global.if1);
+
+	mtu1 = odp_pktin_maxlen(global.if0);
+	mtu2 = odp_pktout_maxlen(global.if1);
+	if (mtu1 && mtu2 && mtu1 > mtu2)
+		printf("Warning: input MTU bigger than output MTU\n");
+
 	odp_cpumask_default_worker(&cpumask, MAX_WORKERS);
 
 	memset(&thr_params, 0, sizeof(thr_params));