Skip to content

Commit 352fed6

Browse files
dcpleungkartben
authored andcommitted
tests: mem_protect/mem_map: limit CPUs to 1 if incoherent cache
For CPUs with incoherent cache under SMP, the tests to read/write buffer (... majority of tests here) may not work correctly if the test thread jumps between CPUs. So use the test infrastructure to limit the test to 1 CPU. Signed-off-by: Daniel Leung <[email protected]>
1 parent 292d688 commit 352fed6

File tree

1 file changed

+15
-2
lines changed
  • tests/kernel/mem_protect/mem_map/src

1 file changed

+15
-2
lines changed

tests/kernel/mem_protect/mem_map/src/main.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,5 +560,18 @@ void *mem_map_env_setup(void)
560560
return NULL;
561561
}
562562

563-
ZTEST_SUITE(mem_map, NULL, NULL, NULL, NULL, NULL);
564-
ZTEST_SUITE(mem_map_api, NULL, mem_map_env_setup, NULL, NULL, NULL);
563+
/* For CPUs with incoherent cache under SMP, the tests to read/write
564+
* buffer (... majority of tests here) may not work correctly if
565+
* the test thread jumps between CPUs. So use the test infrastructure
566+
* to limit the test to 1 CPU.
567+
*/
568+
#ifdef CONFIG_CPU_CACHE_INCOHERENT
569+
#define FUNC_BEFORE ztest_simple_1cpu_before
570+
#define FUNC_AFTER ztest_simple_1cpu_after
571+
#else
572+
#define FUNC_BEFORE NULL
573+
#define FUNC_AFTER NULL
574+
#endif
575+
576+
ZTEST_SUITE(mem_map, NULL, NULL, FUNC_BEFORE, FUNC_AFTER, NULL);
577+
ZTEST_SUITE(mem_map_api, NULL, mem_map_env_setup, FUNC_BEFORE, FUNC_AFTER, NULL);

0 commit comments

Comments
 (0)