Revert "tests: add new kernel objects tests"

This test is generating build warnings as it is making
checks that can never be false.

This reverts commit a4f1a5f58f.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-10-16 11:25:25 -07:00 committed by Anas Nashif
parent ea2107c429
commit 13457ae46a
6 changed files with 3 additions and 134 deletions

View file

@ -994,33 +994,3 @@ void test_mark_thread_exit_uninitialized(void)
ret = z_object_validate(ko, K_OBJ_ANY, _OBJ_INIT_FALSE);
zassert_equal(ret, _OBJ_INIT_FALSE, NULL);
}
/**
* @brief Test kernel objects statically allocated during the build time
*
* @details Take addresses of the kernel objects which are statically allocated
* during the build time and verify that they are not null.
* That kernel objects shouldn't require manual registration by the end user.
*
* @ingroup kernel_memprotect_tests
*/
void test_krnl_obj_static_alloc_build_time(void)
{
struct z_object *ret;
ret = z_object_find(&child_stack);
/* Assert that ptr is not NULL */
zassert_not_null(ret, "Pointer of the child_stack is not NULL");
ret = z_object_find(&extra_stack);
zassert_not_null(ret, "Pointer of the extra_stack is not NULL");
ret = z_object_find(&kobject_sem);
zassert_not_null(ret, "Pointer of the kobject_sem is not NULL");
ret = z_object_find(&kobject_public_sem);
zassert_not_null(ret, "Pointer of the kobject_public_sem is not NULL");
ret = z_object_find(&kobject_mutex);
zassert_not_null(ret, "Pointer of the kobject_mutex is not NULL");
}

View file

@ -20,7 +20,6 @@ void test_main(void)
k_thread_priority_set(k_current_get(), -1);
ztest_test_suite(memory_protection_test_suite,
ztest_unit_test(test_krnl_obj_static_alloc_build_time),
ztest_unit_test(test_permission_inheritance),
ztest_unit_test(test_mem_domain_valid_access),
ztest_unit_test(test_mem_domain_invalid_access),

View file

@ -51,7 +51,6 @@ extern void test_create_new_higher_prio_thread_from_user(void);
extern void test_create_new_invalid_prio_thread_from_user(void);
extern void test_inherit_resource_pool(void);
extern void test_mark_thread_exit_uninitialized(void);
extern void test_krnl_obj_static_alloc_build_time(void);
/* Flag needed to figure out if the fault was expected or not. */
extern volatile bool valid_fault;

View file

@ -2,4 +2,3 @@ CONFIG_ZTEST=y
CONFIG_TEST_USERSPACE=y
CONFIG_DYNAMIC_OBJECTS=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_OBJECT_TRACING=y

View file

@ -10,21 +10,16 @@
#include <kernel_internal.h>
#define SEM_ARRAY_SIZE 16
#define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE)
/* Show that extern declarations don't interfere with detecting kernel
* objects, this was at one point a problem.
*/
extern struct k_sem sem1;
static struct k_sem semarray[SEM_ARRAY_SIZE];
static struct k_sem *dyn_sem[SEM_ARRAY_SIZE];
static struct k_sem *test_dyn_sem0;
static struct k_mutex *test_dyn_mutex;
K_SEM_DEFINE(sem1, 0, 1);
K_THREAD_STACK_DEFINE(user_stack_thr0, STACK_SIZE);
struct k_thread user_thr0;
static struct k_sem sem2;
static char bad_sem[sizeof(struct k_sem)];
static struct k_sem sem3;
@ -117,104 +112,10 @@ void test_generic_object(void)
}
}
/**
* @brief Test requestor thread will implicitly be assigned permission on the
* dynamically allocated object
*
* @details
* - Create kernel object semaphore, dynamically allocate it from the calling
* thread's resource pool.
* - Check that object's address is in bounds of that memory pool.
* - Then check the requestor thread will implicitly be assigned permission on
* the allocated object by using semaphore API k_sem_init()
*
* @ingroup kernel_memprotect_tests
*
* @see k_object_alloc()
*/
void test_kobj_assign_perms_on_alloc_obj(void)
{
test_dyn_sem0 = k_object_alloc(K_OBJ_SEM);
zassert_not_null(test_dyn_sem0, "Cannot allocate sem k_object");
struct k_thread *thread = _current;
intptr_t sem_addr = (intptr_t)&test_dyn_sem0;
intptr_t start_addr = (intptr_t)&thread->resource_pool;
size_t size_heap = CONFIG_HEAP_MEM_POOL_SIZE;
/* check that kernel object may be dynamically allocated,
* drawing memory from the calling thread's memory pool
*/
#if defined(CONFIG_X86) || (CONFIG_ARM)
zassert_true(
(sem_addr > start_addr) && (sem_addr <= (start_addr + size_heap)),
"semaphore not in bound of thread's memory pool");
#elif defined(CONFIG_ARC)
zassert_true(
(sem_addr < start_addr) && (sem_addr > (start_addr - size_heap)),
"semaphore not in bound of thread's memory pool");
#else
#error "Not implemented for this architecture"
zassert_unreachable("Not implemented for this architecture");
#endif
k_sem_init(test_dyn_sem0, 1, 1);
zassert_equal(k_sem_count_get(test_dyn_sem0), 1,
"sem count not equal to the init count");
}
/* Helper function inits dynamic kernel object and then revokes access */
static void dyn_object_release(void *p1, void *p2, void *p3)
{
struct z_object *ko;
test_dyn_mutex = k_object_alloc(K_OBJ_MUTEX);
zassert_not_null(&test_dyn_mutex, "Can't allocate dynamical kobj");
struct k_thread *thread = _current;
ko = z_object_find(test_dyn_mutex);
zassert_true(ko, "Kernel object test_dyn_mutex not found");
k_object_access_revoke(test_dyn_mutex, thread);
}
/**
* @brief Test dynamically allocated kernel object release memory
*
* @details Dynamically allocated kernel objects whose access is controlled by
* the permission system will use object permission as a reference count.
* If no threads have access to an object, the object's memory released.
*
* @ingroup kernel_memprotect_tests
*
* @see k_object_alloc()
*/
void test_no_ref_dyn_kobj_release_mem(void)
{
k_thread_create(&user_thr0, user_stack_thr0,
K_THREAD_STACK_SIZEOF(user_stack_thr0),
dyn_object_release,
NULL, NULL, NULL,
K_INHERIT_PERMS, 0, K_NO_WAIT);
k_thread_join(&user_thr0, K_FOREVER);
struct z_object *ko = z_object_find(test_dyn_mutex);
ko = z_object_find(test_dyn_mutex);
zassert_false(ko, "Kernel object test_dyn_mutex not found");
}
void test_main(void)
{
k_thread_system_pool_assign(k_current_get());
ztest_test_suite(object_validation,
ztest_unit_test(test_generic_object),
ztest_unit_test(test_kobj_assign_perms_on_alloc_obj),
ztest_unit_test(test_no_ref_dyn_kobj_release_mem)
);
ztest_unit_test(test_generic_object));
ztest_run_test_suite(object_validation);
}

View file

@ -48,6 +48,7 @@ FOR_EACH(K_APPMEM_PARTITION_DEFINE, (;), part0, part1);
struct k_mem_domain dom0;
struct k_mem_domain dom1;
K_APP_DMEM(part0) bool mem_access_check;
K_APP_BMEM(part0) static volatile bool expect_fault;
K_APP_BMEM(part0) static volatile unsigned int expected_reason;