Commit bcb4cfe9 authored by Andrew Boie's avatar Andrew Boie Committed by Anas Nashif
Browse files

tests: net: use main thread for test



The main thread was doing nothing but spawning another thread to perform
the test. Delete the alternate thread, and just do the test on the main
thread, adjusting stack size and priority as necessary.

Issue: ZEP-2236
Signed-off-by: default avatarAndrew Boie <andrew.p.boie@intel.com>
parent e0185d4c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ CONFIG_NET_DEBUG_IF=y
CONFIG_NET_DEBUG_CORE=y
CONFIG_NET_DEBUG_6LO=y
CONFIG_NET_DEBUG_NET_PKT=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_NET_6LO_CONTEXT=y
#Before modifying this value, add respective code in src/main.c
+3 −12
Original line number Diff line number Diff line
@@ -899,10 +899,12 @@ static const struct {
#endif
};

static void main_thread(void)
void main(void)
{
	int count, pass;

	k_thread_priority_set(k_current_get(), K_PRIO_COOP(7));

#if defined(CONFIG_NET_6LO_CONTEXT)
	net_6lo_set_context(net_if_get_default(), &ctx1);
	net_6lo_set_context(net_if_get_default(), &ctx2);
@@ -923,14 +925,3 @@ static void main_thread(void)

	TC_END_REPORT(((pass != ARRAY_SIZE(tests)) ? TC_FAIL : TC_PASS));
}

#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;

void main(void)
{
	k_thread_create(&thread_data, thread_stack, STACKSIZE,
			(k_thread_entry_t)main_thread,
			NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}
+3 −12
Original line number Diff line number Diff line
@@ -669,22 +669,13 @@ static bool run_tests(void)
	return true;
}

void main_thread(void)
void main(void)
{
	k_thread_priority_set(k_current_get(), K_PRIO_COOP(7));

	if (run_tests()) {
		TC_END_REPORT(TC_PASS);
	} else {
		TC_END_REPORT(TC_FAIL);
	}
}

#define STACKSIZE 2000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;

void main(void)
{
	k_thread_create(&thread_data, thread_stack, STACKSIZE,
			(k_thread_entry_t)main_thread,
			NULL, NULL, NULL, K_PRIO_COOP(7), 0, 0);
}
+2 −0
Original line number Diff line number Diff line
@@ -24,3 +24,5 @@ CONFIG_NET_MGMT_EVENT=y

# Turn off UDP checksum checking as the test fails otherwise.
CONFIG_NET_UDP_CHECKSUM=n

CONFIG_MAIN_STACK_SIZE=3072
+2 −12
Original line number Diff line number Diff line
@@ -524,10 +524,11 @@ static void receiver_cb(struct net_mgmt_event_callback *cb,
	test_result(true);
}

void main_thread(void)
void main(void)
{
	struct net_if *iface;

	k_thread_priority_set(k_current_get(), K_PRIO_COOP(7));
	net_mgmt_init_event_callback(&rx_cb, receiver_cb,
				     NET_EVENT_IPV4_ADDR_ADD);

@@ -543,14 +544,3 @@ void main_thread(void)

	k_yield();
}

#define STACKSIZE 3000
char __noinit __stack thread_stack[STACKSIZE];
static struct k_thread thread_data;

void main(void)
{
	k_thread_create(&thread_data, thread_stack, STACKSIZE,
			(k_thread_entry_t)main_thread, NULL, NULL, NULL,
			K_PRIO_COOP(7), 0, 0);
}
Loading