From: Juha-Matti Tilli <[email protected]> Do some MTU, promiscuous mode and MAC address related operations in odp_l2fwd_simple to increase code coverage.
Signed-off-by: Juha-Matti Tilli <[email protected]> --- /** 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: f1449d2555fbfa3d72aeb79d3ad6d2f199e83731 ** Merge commit sha: dfd19c141174b2de7b89e7b95ab23b19139afb13 **/ example/l2fwd_simple/odp_l2fwd_simple.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/example/l2fwd_simple/odp_l2fwd_simple.c b/example/l2fwd_simple/odp_l2fwd_simple.c index fd0cec3cf..d292dd707 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_pktio_mtu(global.if0); + mtu2 = odp_pktio_mtu(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));
