net: apps: User can set the loopback test count

User can set the desired number of network packets that are
sent. There is an example config that sends 10000 packets
and then stops the test application.

Change-Id: I5aa9049236f7bebdc9ea9997b9eb1f672c6adcbf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-03-14 12:58:49 +02:00
commit b650e8edb1
3 changed files with 27 additions and 0 deletions

View file

@ -172,6 +172,13 @@ config NETWORKING_WITH_LOOPBACK
neighbor cache. All packets transmitted are neighbor cache. All packets transmitted are
looped back to the receiving fifo/fiber. looped back to the receiving fifo/fiber.
config NETWORK_LOOPBACK_TEST_COUNT
int "How many packets the loopback test passes"
depends on NETWORKING_WITH_LOOPBACK
default 0
help
If set to 0, then the loopback test runs forever.
choice choice
prompt "Wired networking support" prompt "Wired networking support"
depends on NETWORKING depends on NETWORKING

View file

@ -0,0 +1,6 @@
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_IPV6_NO_ND=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_NETWORK_LOOPBACK_TEST_COUNT=10000

View file

@ -70,6 +70,14 @@ static nano_thread_id_t receiver_id;
static bool failure; static bool failure;
static int appdatalen; static int appdatalen;
/* How many packets to send/receive */
#if defined(CONFIG_NETWORK_LOOPBACK_TEST_COUNT)
#define TEST_COUNT CONFIG_NETWORK_LOOPBACK_TEST_COUNT
#else
#define TEST_COUNT 0
#endif
static unsigned long count = TEST_COUNT;
void fiber_receiver(void) void fiber_receiver(void)
{ {
struct nano_timer timer; struct nano_timer timer;
@ -108,6 +116,9 @@ void fiber_receiver(void)
ip_buf_unref(buf); ip_buf_unref(buf);
} }
if (count && (count < received)) {
break;
}
fiber_wakeup(sender_id); fiber_wakeup(sender_id);
fiber_sleep(SLEEPTICKS); fiber_sleep(SLEEPTICKS);
@ -167,6 +178,9 @@ void fiber_sender(void)
failure = true; failure = true;
} }
if (count && (count < sent)) {
break;
}
} }
if (failure) { if (failure) {