test: object_tracing: account for pre-existing threads
Count existing threads before the test has started to deal with platforms that have some existing services. Remove hard-coded accounting for IPM, this is now counted before the test starts. Fixes #21756 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
3ddc2da64d
commit
28298fa06a
1 changed files with 8 additions and 11 deletions
|
@ -15,7 +15,7 @@ extern void test_obj_tracing(void);
|
|||
|
||||
#define TOTAL_TEST_NUMBER 2
|
||||
#define ZTEST_THREADS_CREATED 1
|
||||
#define TOTAL_THREADS (N_PHILOSOPHERS + 3 + IPM_THREAD + ZTEST_THREADS_CREATED)
|
||||
#define TOTAL_THREADS (N_PHILOSOPHERS + ZTEST_THREADS_CREATED)
|
||||
#define TOTAL_OBJECTS (N_PHILOSOPHERS)
|
||||
|
||||
#define OBJ_LIST_NAME k_sem
|
||||
|
@ -27,19 +27,13 @@ extern void test_obj_tracing(void);
|
|||
|
||||
#define RANDDELAY(x) k_sleep(10 * (x) + 1)
|
||||
|
||||
/* 1 IPM console thread if enabled */
|
||||
#if defined(CONFIG_IPM_CONSOLE_RECEIVER) && defined(CONFIG_PRINTK)
|
||||
#define IPM_THREAD 1
|
||||
#else
|
||||
#define IPM_THREAD 0
|
||||
#endif /* CONFIG_IPM_CONSOLE_RECEIVER && CONFIG_PRINTK*/
|
||||
static int initial_count;
|
||||
|
||||
/* Must account for:
|
||||
* N Philosopher threads
|
||||
* 1 Object monitor thread
|
||||
* 1 System idle thread
|
||||
* 1 System workqueue thread
|
||||
* 1 IPM console thread
|
||||
*/
|
||||
|
||||
void *force_sys_work_q_in = (void *)&k_sys_work_q;
|
||||
|
@ -60,7 +54,7 @@ K_SEM_DEFINE(f3, -5, 1);
|
|||
* @}
|
||||
*/
|
||||
|
||||
static inline int test_thread_monitor(void)
|
||||
static inline int thread_monitor(void)
|
||||
{
|
||||
int obj_counter = 0;
|
||||
struct k_thread *thread_list = NULL;
|
||||
|
@ -114,9 +108,9 @@ static void object_monitor(void)
|
|||
}
|
||||
TC_PRINT("SEMAPHORE QUANTITY: %d\n", obj_counter);
|
||||
|
||||
thread_counter += test_thread_monitor();
|
||||
thread_counter += thread_monitor();
|
||||
|
||||
zassert_true(((thread_counter == TOTAL_THREADS) &&
|
||||
zassert_true(((thread_counter == (TOTAL_THREADS + initial_count)) &&
|
||||
(obj_counter == TOTAL_OBJECTS)), "test failed");
|
||||
}
|
||||
|
||||
|
@ -186,6 +180,9 @@ void test_philosophers_tracing(void)
|
|||
|
||||
void test_main(void)
|
||||
{
|
||||
|
||||
initial_count = thread_monitor();
|
||||
|
||||
ztest_test_suite(obj_tracing,
|
||||
ztest_unit_test(test_philosophers_tracing),
|
||||
ztest_unit_test(test_obj_tracing));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue