-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boot test and virtual heap testing #7688
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,28 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause | ||
* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
*/ | ||
|
||
#ifndef __SOF_BOOT_TEST_H__ | ||
#define __SOF_BOOT_TEST_H__ | ||
|
||
#include <stdbool.h> | ||
|
||
#define TEST_RUN_ONCE(fn, ...) do { \ | ||
static bool once; \ | ||
if (!once) { \ | ||
once = true; \ | ||
fn(__VA_ARGS__); \ | ||
} \ | ||
} while (0) | ||
|
||
#define TEST_CHECK_RET(ret, testname) do { \ | ||
if ((ret) < 0) { \ | ||
LOG_ERR(testname " failed: %d", (ret)); \ | ||
ztest_test_fail(); \ | ||
} else { \ | ||
ztest_test_pass(); \ | ||
} \ | ||
} 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,12 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
*/ | ||
|
||
#include <zephyr/logging/log.h> | ||
|
||
#include <zephyr/ztest.h> | ||
|
||
LOG_MODULE_REGISTER(sof_boot_test, LOG_LEVEL_DBG); | ||
|
||
ZTEST_SUITE(sof_boot, NULL, NULL, NULL, NULL, NULL); |
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,5 @@ | ||
if (CONFIG_ACE_VERSION_1_5) | ||
zephyr_library_sources_ifdef(CONFIG_SOF_BOOT_TEST | ||
vmh.c | ||
) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// 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> | ||
|
||
#include <zephyr/logging/log.h> | ||
#include <zephyr/ztest.h> | ||
|
||
LOG_MODULE_DECLARE(sof_boot_test, CONFIG_SOF_LOG_LEVEL); | ||
|
||
#define ALLOC_SIZE1 1616 | ||
#define ALLOC_SIZE2 26 | ||
|
||
static int vmh_test_single(bool span) | ||
{ | ||
struct vmh_heap *h = vmh_init_heap(NULL, MEM_REG_ATTR_CORE_HEAP, 0, span); | ||
|
||
if (!h) | ||
return -EINVAL; | ||
|
||
char *buf = vmh_alloc(h, ALLOC_SIZE1); | ||
int ret1; | ||
|
||
if (buf) { | ||
buf[0] = 0; | ||
buf[ALLOC_SIZE1 - 1] = 15; | ||
|
||
ret1 = vmh_free(h, buf); | ||
if (ret1 < 0) | ||
goto out; | ||
} else if (span) { | ||
ret1 = -ENOMEM; | ||
LOG_ERR("Failed to allocate %u in contiguous mode", ALLOC_SIZE1); | ||
goto out; | ||
} else { | ||
LOG_WRN("Ignoring failure to allocate %u in non-contiguous mode", | ||
ALLOC_SIZE1); | ||
} | ||
|
||
buf = vmh_alloc(h, ALLOC_SIZE2); | ||
|
||
if (!buf) { | ||
ret1 = -ENOMEM; | ||
LOG_ERR("Failed to allocate %u", ALLOC_SIZE2); | ||
goto out; | ||
} | ||
|
||
buf[0] = 0; | ||
buf[ALLOC_SIZE2 - 1] = 15; | ||
|
||
ret1 = vmh_free(h, buf); | ||
if (ret1 < 0) | ||
LOG_ERR("Free error %d", ret1); | ||
|
||
out: | ||
int ret2 = vmh_free_heap(h); | ||
|
||
if (ret2 < 0) | ||
LOG_ERR("Free heap error %d", ret2); | ||
|
||
if (!ret1) | ||
ret1 = ret2; | ||
|
||
return ret1; | ||
} | ||
|
||
static int vmh_test(void) | ||
{ | ||
int ret = vmh_test_single(false); | ||
|
||
if (ret < 0) { | ||
LOG_ERR("Non-contiguous test error %d", ret); | ||
return ret; | ||
} | ||
|
||
ret = vmh_test_single(true); | ||
if (ret < 0) | ||
LOG_ERR("Contiguous test error %d", ret); | ||
|
||
return ret; | ||
} | ||
|
||
ZTEST(sof_boot, virtual_memory_heap) | ||
{ | ||
int ret = vmh_test(); | ||
|
||
TEST_CHECK_RET(ret, "virtual_memory_heap"); | ||
} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact, thinking about this now, this code would probably be common for all SOF boot tests, so we can have a macro to be called in this case something like
SOF_ZTEST_BOOT(vmh, vmh_test);
I can try to do this now or we can try to switch to one like this later when we get at least a second such boot testThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done