-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debug: use a boot-time test runner to test virtual heap
Add a simple API to run tests at start up and use it to test the virtual heap allocator. Signed-off-by: Guennadi Liakhovetski <[email protected]>
- Loading branch information
Showing
7 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
* | ||
* Author: Guennadi Liakhovetski <[email protected]> | ||
*/ | ||
|
||
#ifndef __SOF_BOOT_TEST_H__ | ||
#define __SOF_BOOT_TEST_H__ | ||
|
||
#include <sof/list.h> | ||
#include <zephyr/init.h> | ||
|
||
struct boot_test { | ||
struct list_item list; | ||
int (*test)(void); | ||
}; | ||
|
||
#if CONFIG_SOF_BOOT_TEST | ||
void sof_boot_test(void); | ||
void sof_boot_test_register(struct boot_test *test); | ||
#else | ||
#define sof_boot_test() do {} while (0) | ||
#define sof_boot_test_register(x) do {} while (0) | ||
#endif | ||
|
||
#define SOF_BOOT_TEST(x) \ | ||
static struct boot_test x##_test = {.test = x}; \ | ||
static int x##_init(void) \ | ||
{ \ | ||
sof_boot_test_register(&x##_test); \ | ||
return 0; \ | ||
} \ | ||
SYS_INIT(x##_init, APPLICATION, 0) | ||
|
||
#define run_once(fn, ...) do { \ | ||
static bool once; \ | ||
if (!once) { \ | ||
once = true; \ | ||
fn(__VA_ARGS__); \ | ||
} \ | ||
} while (0) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
* | ||
* Author: Guennadi Liakhovetski <[email protected]> | ||
*/ | ||
|
||
/* need zephyr_tr */ | ||
#include <rtos/interrupt.h> | ||
|
||
#include <sof/boot_test.h> | ||
#include <sof/list.h> | ||
#include <sof/trace/trace.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
|
||
LOG_MODULE_REGISTER(boot_test, CONFIG_SOF_LOG_LEVEL); | ||
|
||
static struct list_item test_list = LIST_INIT(test_list); | ||
|
||
void sof_boot_test_register(struct boot_test *test) | ||
{ | ||
list_item_append(&test->list, &test_list); | ||
} | ||
|
||
void sof_boot_test(void) | ||
{ | ||
struct list_item *list; | ||
|
||
list_for_item (list, &test_list) { | ||
struct boot_test *test = list_item(list, struct boot_test, list); | ||
/* TODO: measure time */ | ||
int ret = test->test(); | ||
|
||
tr_info(&zephyr_tr, "test %p returned %d", test->test, ret); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
* | ||
* Author: Guennadi Liakhovetski <[email protected]> | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <stdbool.h> | ||
|
||
#include <adsp_memory_regions.h> | ||
#include <sof/boot_test.h> | ||
#include <sof/lib/regions_mm.h> | ||
|
||
static int vmh_test(void) | ||
{ | ||
struct virtual_memory_heap *h = vmh_init_heap(NULL, MEM_REG_ATTR_CORE_HEAP, 0, false); | ||
|
||
if (!h) | ||
return -EINVAL; | ||
|
||
return vmh_free_heap(h); | ||
} | ||
|
||
SOF_BOOT_TEST(vmh_test); |