ztest: remove ztest_mem_domain

Just add ztest's partition to the default domain, as well as the
malloc partition if it exists.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-08-25 14:52:51 -07:00 committed by Anas Nashif
commit d650b4e800
7 changed files with 21 additions and 31 deletions

View file

@ -169,7 +169,6 @@ __syscall void z_test_1cpu_stop(void);
#define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition) #define ZTEST_BMEM K_APP_BMEM(ztest_mem_partition)
#define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition) #define ZTEST_SECTION K_APP_DMEM_SECTION(ztest_mem_partition)
extern struct k_mem_partition ztest_mem_partition; extern struct k_mem_partition ztest_mem_partition;
extern struct k_mem_domain ztest_mem_domain;
#else #else
#define ZTEST_DMEM #define ZTEST_DMEM
#define ZTEST_BMEM #define ZTEST_BMEM

View file

@ -399,7 +399,6 @@ void end_report(void)
} }
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
struct k_mem_domain ztest_mem_domain;
K_APPMEM_PARTITION_DEFINE(ztest_mem_partition); K_APPMEM_PARTITION_DEFINE(ztest_mem_partition);
#endif #endif
@ -416,24 +415,18 @@ int main(void)
void main(void) void main(void)
{ {
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
struct k_mem_partition *parts[] = { /* Partition containing globals tagged with ZTEST_DMEM and ZTEST_BMEM
#ifdef Z_LIBC_PARTITION_EXISTS * macros. Any variables that user code may reference need to be
/* C library globals, stack canary storage, etc */ * placed in this partition if no other memory domain configuration
&z_libc_partition, * is made.
#endif
#ifdef Z_MALLOC_PARTITION_EXISTS
/* Required for access to malloc arena */
&z_malloc_partition,
#endif
&ztest_mem_partition
};
/* Ztests just have one memory domain with one partition.
* Any variables that user code may reference need to go in them,
* using the ZTEST_DMEM and ZTEST_BMEM macros.
*/ */
k_mem_domain_init(&ztest_mem_domain, ARRAY_SIZE(parts), parts); k_mem_domain_add_partition(&k_mem_domain_default,
k_mem_domain_add_thread(&ztest_mem_domain, k_current_get()); &ztest_mem_partition);
#ifdef Z_MALLOC_PARTITION_EXISTS
/* Allow access to malloc() memory */
k_mem_domain_add_partition(&k_mem_domain_default,
&z_malloc_partition);
#endif
#endif /* CONFIG_USERSPACE */ #endif /* CONFIG_USERSPACE */
z_init_mock(); z_init_mock();

View file

@ -13,7 +13,7 @@ extern void test_mbedtls(void);
void test_main(void) void test_main(void)
{ {
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
k_mem_domain_add_partition(&ztest_mem_domain, &k_mbedtls_partition); k_mem_domain_add_partition(&k_mem_domain_default, &k_mbedtls_partition);
#endif #endif
ztest_test_suite(test_mbedtls_fn, ztest_test_suite(test_mbedtls_fn,
ztest_user_unit_test(test_mbedtls)); ztest_user_unit_test(test_mbedtls));

View file

@ -25,7 +25,6 @@ extern void test_mem_domain_add_partitions_simple(void);
extern void test_mem_domain_remove_partitions_simple(void); extern void test_mem_domain_remove_partitions_simple(void);
extern void test_mem_domain_remove_partitions(void); extern void test_mem_domain_remove_partitions(void);
extern void test_mem_domain_remove_thread(void); extern void test_mem_domain_remove_thread(void);
extern void test_mem_domain_destroy(void);
extern void test_kobject_access_grant(void); extern void test_kobject_access_grant(void);
extern void test_syscall_invalid_kobject(void); extern void test_syscall_invalid_kobject(void);
extern void test_thread_without_kobject_permission(void); extern void test_thread_without_kobject_permission(void);
@ -68,7 +67,6 @@ void test_main(void)
ztest_unit_test(test_mem_domain_remove_partitions_simple), ztest_unit_test(test_mem_domain_remove_partitions_simple),
ztest_unit_test(test_mem_domain_remove_partitions), ztest_unit_test(test_mem_domain_remove_partitions),
ztest_unit_test(test_mem_domain_remove_thread), ztest_unit_test(test_mem_domain_remove_thread),
ztest_unit_test(test_mem_domain_destroy),
ztest_unit_test(test_mark_thread_exit_uninitialized), ztest_unit_test(test_mark_thread_exit_uninitialized),
ztest_unit_test(test_kobject_access_grant), ztest_unit_test(test_kobject_access_grant),
ztest_unit_test(test_syscall_invalid_kobject), ztest_unit_test(test_syscall_invalid_kobject),

View file

@ -559,7 +559,7 @@ void test_mem_domain_remove_thread(void *p1, void *p2, void *p3)
k_mem_domain_remove_thread(k_current_get()); k_mem_domain_remove_thread(k_current_get());
k_mem_domain_add_thread(&ztest_mem_domain, k_current_get()); k_mem_domain_add_thread(&k_mem_domain_default, k_current_get());
k_thread_user_mode_enter(mem_domain_for_user_tc7, k_thread_user_mode_enter(mem_domain_for_user_tc7,
NULL, NULL, NULL); NULL, NULL, NULL);

View file

@ -424,12 +424,12 @@ void test_main(void)
k_thread_access_grant(k_current_get(), k_thread_access_grant(k_current_get(),
&thread_12_thread_data, &thread_12_stack_area); &thread_12_thread_data, &thread_12_stack_area);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_05); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_05);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_06); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_06);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_07); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_07);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_08); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_08);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_09); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_09);
k_mem_domain_add_thread(&ztest_mem_domain, THREAD_11); k_mem_domain_add_thread(&k_mem_domain_default, THREAD_11);
#endif #endif
rv = sys_mutex_lock(&not_my_mutex, K_NO_WAIT); rv = sys_mutex_lock(&not_my_mutex, K_NO_WAIT);
if (rv != 0) { if (rv != 0) {

View file

@ -209,8 +209,8 @@ void test_main(void)
k_thread_access_grant(k_current_get(), &thread_preempt, &stack_preempt, k_thread_access_grant(k_current_get(), &thread_preempt, &stack_preempt,
&start_sema, &end_sema); &start_sema, &end_sema);
#ifdef CONFIG_USERSPACE #ifdef CONFIG_USERSPACE
k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_COOP_THREAD); k_mem_domain_add_thread(&k_mem_domain_default, T_KDEFINE_COOP_THREAD);
k_mem_domain_add_thread(&ztest_mem_domain, T_KDEFINE_PREEMPT_THREAD); k_mem_domain_add_thread(&k_mem_domain_default, T_KDEFINE_PREEMPT_THREAD);
#endif #endif
ztest_test_suite(thread_init, ztest_test_suite(thread_init,