tests: kernel: move the test demand_paging to new ztest API
Migrate the testsuite tests/kernel/mem_protect/demand_paging to the new ztest API. Signed-off-by: Enjia Mai <enjia.mai@intel.com>
This commit is contained in:
parent
7684f46b7f
commit
00fedc2eb2
@ -1,4 +1,5 @@
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_DEMAND_PAGING_STATS=y
|
||||
CONFIG_DEMAND_PAGING_THREAD_STATS=y
|
||||
CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM=y
|
||||
|
||||
@ -83,7 +83,7 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *pEsf)
|
||||
#define HALF_BYTES (HALF_PAGES * CONFIG_MMU_PAGE_SIZE)
|
||||
static const char *nums = "0123456789";
|
||||
|
||||
void test_map_anon_pages(void)
|
||||
ZTEST(demand_paging, test_map_anon_pages)
|
||||
{
|
||||
arena_size = k_mem_free_get() + HALF_BYTES;
|
||||
arena = k_mem_map(arena_size, K_MEM_PERM_RW);
|
||||
@ -94,7 +94,7 @@ void test_map_anon_pages(void)
|
||||
z_page_frames_dump();
|
||||
}
|
||||
|
||||
void print_paging_stats(struct k_mem_paging_stats_t *stats, const char *scope)
|
||||
static void print_paging_stats(struct k_mem_paging_stats_t *stats, const char *scope)
|
||||
{
|
||||
printk("* Page Faults (%s):\n", scope);
|
||||
printk(" - Total: %lu\n", stats->pagefaults.cnt);
|
||||
@ -113,7 +113,7 @@ void print_paging_stats(struct k_mem_paging_stats_t *stats, const char *scope)
|
||||
stats->eviction.dirty);
|
||||
}
|
||||
|
||||
void test_touch_anon_pages(void)
|
||||
ZTEST(demand_paging, test_touch_anon_pages)
|
||||
{
|
||||
unsigned long faults;
|
||||
struct k_mem_paging_stats_t stats;
|
||||
@ -190,7 +190,7 @@ void test_touch_anon_pages(void)
|
||||
}
|
||||
}
|
||||
|
||||
void test_k_mem_page_out(void)
|
||||
static void test_k_mem_page_out(void)
|
||||
{
|
||||
unsigned long faults;
|
||||
int key, ret;
|
||||
@ -219,7 +219,7 @@ void test_k_mem_page_out(void)
|
||||
|
||||
}
|
||||
|
||||
void test_k_mem_page_in(void)
|
||||
ZTEST(demand_paging_api, test_k_mem_page_in)
|
||||
{
|
||||
unsigned long faults;
|
||||
int key, ret;
|
||||
@ -246,7 +246,7 @@ void test_k_mem_page_in(void)
|
||||
faults);
|
||||
}
|
||||
|
||||
void test_k_mem_pin(void)
|
||||
ZTEST(demand_paging_api, test_k_mem_pin)
|
||||
{
|
||||
unsigned long faults;
|
||||
unsigned int key;
|
||||
@ -274,7 +274,7 @@ void test_k_mem_pin(void)
|
||||
k_mem_unpin(arena, HALF_BYTES);
|
||||
}
|
||||
|
||||
void test_k_mem_unpin(void)
|
||||
ZTEST(demand_paging_api, test_k_mem_unpin)
|
||||
{
|
||||
/* Pin the memory (which we know works from prior test) */
|
||||
k_mem_pin(arena, HALF_BYTES);
|
||||
@ -290,7 +290,7 @@ void test_k_mem_unpin(void)
|
||||
* store, we can still handle pagefaults.
|
||||
* This eats up memory so should be last in the suite.
|
||||
*/
|
||||
void test_backing_store_capacity(void)
|
||||
ZTEST(demand_paging_stat, test_backing_store_capacity)
|
||||
{
|
||||
char *mem, *ret;
|
||||
unsigned int key;
|
||||
@ -322,7 +322,7 @@ void test_backing_store_capacity(void)
|
||||
}
|
||||
|
||||
/* Test if we can get paging statistics under usermode */
|
||||
void test_user_get_stats(void)
|
||||
ZTEST_USER(demand_paging_stat, test_user_get_stats)
|
||||
{
|
||||
struct k_mem_paging_stats_t stats;
|
||||
k_tid_t tid = k_current_get();
|
||||
@ -354,7 +354,7 @@ void test_user_get_stats(void)
|
||||
/* Print the histogram and return true if histogram has non-zero values
|
||||
* in one of its bins.
|
||||
*/
|
||||
bool print_histogram(struct k_mem_paging_histogram_t *hist)
|
||||
static bool print_histogram(struct k_mem_paging_histogram_t *hist)
|
||||
{
|
||||
bool has_non_zero;
|
||||
uint64_t time_ns;
|
||||
@ -380,7 +380,7 @@ bool print_histogram(struct k_mem_paging_histogram_t *hist)
|
||||
}
|
||||
|
||||
/* Test if we can get paging timing histograms */
|
||||
void test_user_get_hist(void)
|
||||
ZTEST_USER(demand_paging_stat, test_user_get_hist)
|
||||
{
|
||||
struct k_mem_paging_histogram_t hist;
|
||||
|
||||
@ -403,19 +403,16 @@ void test_user_get_hist(void)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
/* ztest main entry*/
|
||||
void test_main(void)
|
||||
void *demand_paging_api_setup(void)
|
||||
{
|
||||
ztest_test_suite(test_demand_paging,
|
||||
ztest_unit_test(test_map_anon_pages),
|
||||
ztest_unit_test(test_touch_anon_pages),
|
||||
ztest_unit_test(test_k_mem_page_out),
|
||||
ztest_unit_test(test_k_mem_page_in),
|
||||
ztest_unit_test(test_k_mem_pin),
|
||||
ztest_unit_test(test_k_mem_unpin),
|
||||
ztest_unit_test(test_backing_store_capacity),
|
||||
ztest_user_unit_test(test_user_get_stats),
|
||||
ztest_user_unit_test(test_user_get_hist));
|
||||
test_k_mem_page_out();
|
||||
|
||||
ztest_run_test_suite(test_demand_paging);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZTEST_SUITE(demand_paging, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST_SUITE(demand_paging_api, NULL, demand_paging_api_setup,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
ZTEST_SUITE(demand_paging_stat, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user