Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference
#include <zephyr/kernel.h>
#include <zephyr/internal/syscall_handler.h>
#include <zephyr/ztest.h>
#include <kernel_internal.h>

Macros

#define SEM_ARRAY_SIZE   16
 

Functions

 K_SEM_DEFINE (sem1, 0, 1)
 
static int test_object (struct k_sem *sem, int retval)
 
void object_permission_checks (struct k_sem *sem, bool skip_init)
 
 ZTEST (object_validation, test_generic_object)
 Test to verify object permission.
 
 ZTEST (object_validation, test_kobj_assign_perms_on_alloc_obj)
 Test requestor thread will implicitly be assigned permission on the dynamically allocated object.
 
 ZTEST (object_validation, test_no_ref_dyn_kobj_release_mem)
 Test dynamically allocated kernel object release memory.
 
void * object_validation_setup (void)
 
 ZTEST_SUITE (object_validation, NULL, object_validation_setup, NULL, NULL, NULL)
 

Variables

struct k_sem sem1
 
static struct k_sem semarray [16]
 
static struct k_sem * dyn_sem [16]
 
static struct k_mutextest_dyn_mutex
 
static struct k_sem sem2
 
static char bad_sem [sizeof(struct k_sem)]
 
static struct k_sem sem3
 

Macro Definition Documentation

◆ SEM_ARRAY_SIZE

#define SEM_ARRAY_SIZE   16

Function Documentation

◆ K_SEM_DEFINE()

K_SEM_DEFINE ( sem1  ,
,
 
)

◆ object_permission_checks()

void object_permission_checks ( struct k_sem *  sem,
bool  skip_init 
)

◆ object_validation_setup()

void * object_validation_setup ( void  )

◆ test_object()

static int test_object ( struct k_sem *  sem,
int  retval 
)
static

◆ ZTEST() [1/3]

ZTEST ( object_validation  ,
test_generic_object   
)

Test to verify object permission.

  • The kernel must be able to associate kernel object memory addresses with whether the calling thread has access to that object, the object is of the expected type, and the object is of the expected init state.
  • Test support freeing kernel objects allocated at runtime manually.
See also
k_object_alloc(), k_object_access_grant()

◆ ZTEST() [2/3]

ZTEST ( object_validation  ,
test_kobj_assign_perms_on_alloc_obj   
)

Test requestor thread will implicitly be assigned permission on the dynamically allocated object.

  • 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()
See also
k_object_alloc()

◆ ZTEST() [3/3]

ZTEST ( object_validation  ,
test_no_ref_dyn_kobj_release_mem   
)

Test dynamically allocated kernel object release memory.

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.

See also
k_object_alloc()

◆ ZTEST_SUITE()

ZTEST_SUITE ( object_validation  ,
NULL  ,
object_validation_setup  ,
NULL  ,
NULL  ,
NULL   
)

Variable Documentation

◆ bad_sem

char bad_sem[sizeof(struct k_sem)]
static

◆ dyn_sem

struct k_sem* dyn_sem[16]
static

◆ sem1

struct k_sem sem1
extern

◆ sem2

struct k_sem sem2
static

◆ sem3

struct k_sem sem3
static

◆ semarray

struct k_sem semarray[16]
static

◆ test_dyn_mutex

struct k_mutex* test_dyn_mutex
static