-
Notifications
You must be signed in to change notification settings - Fork 349
test: convert LIST unit tests from CMock to Ztest framework #10066
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
Merged
lgirdwood
merged 2 commits into
thesofproject:main
from
tmleman:topic/upstream/pr/unit_test/poc/ztest/list
Jul 16, 2025
Merged
test: convert LIST unit tests from CMock to Ztest framework #10066
lgirdwood
merged 2 commits into
thesofproject:main
from
tmleman:topic/upstream/pr/unit_test/poc/ztest/list
Jul 16, 2025
Conversation
This file contains hidden or 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
Contributor
Author
|
This PR serves only as a POC demonstrating the possibility of porting existing unit tests to the Zephyr framework using Copilot. To build and run the tests: $ west twister --testsuite-root sof/test/ztest/unit/ --platform native_sim
INFO - Using Ninja..
warning: tag 'v4.1-branch' is externally known as 'v4.1.0'
INFO - Zephyr version: v4.1.0-5353-g8c6b2c8c8877
INFO - Using 'zephyr' toolchain.
INFO - Building initial testsuite list...
INFO - Writing JSON report /home/tmleman/work/repos/converged/twister-out/testplan.json
INFO - JOBS: 20
INFO - Adding tasks to the queue...
INFO - Added initial list of jobs to queue
INFO - Total complete: 1/ 1 100% built (not run): 0, filtered: 0, failed: 0, error: 0
INFO - 1 test scenarios (1 configurations) selected, 0 configurations filtered (0 by static filter, 0 at runtime).
INFO - 1 of 1 executed test configurations passed (100.00%), 0 built (not run), 0 failed, 0 errored, with no warnings in 9.64 seconds.
INFO - 6 of 6 executed test cases passed (100.00%) on 1 out of total 1080 platforms (0.09%).
INFO - 1 test configurations executed on platforms, 0 test configurations were only built.
INFO - Saving reports...
INFO - Writing JSON report /home/tmleman/work/repos/converged/twister-out/twister.json
INFO - Writing xunit report /home/tmleman/work/repos/converged/twister-out/twister.xml...
INFO - Writing xunit report /home/tmleman/work/repos/converged/twister-out/twister_report.xml...
INFO - Run completedor $ west -v build -d build_ut -b native_sim sof/test/ztest/unit/list
$ ./build_ut/zephyr/zephyr.exe
*** Booting Zephyr OS build 4.1.99 ***
Running TESTSUITE sof_list_suite
===================================================================
START - test_list_init
PASS - test_list_init in 0.000 seconds
===================================================================
START - test_list_is_empty
PASS - test_list_is_empty in 0.000 seconds
===================================================================
START - test_list_item_append
PASS - test_list_item_append in 0.000 seconds
===================================================================
START - test_list_item_del
PASS - test_list_item_del in 0.000 seconds
===================================================================
START - test_list_item_is_last
PASS - test_list_item_is_last in 0.000 seconds
===================================================================
START - test_list_item_prepend
PASS - test_list_item_prepend in 0.000 seconds
===================================================================
TESTSUITE sof_list_suite succeeded
------ TESTSUITE SUMMARY START ------
SUITE PASS - 100.00% [sof_list_suite]: pass = 6, fail = 0, skip = 0, total = 6 duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_init] duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_is_empty] duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_item_append] duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_item_del] duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_item_is_last] duration = 0.000 seconds
- PASS - [sof_list_suite.test_list_item_prepend] duration = 0.000 seconds
------ TESTSUITE SUMMARY END ------
===================================================================
PROJECT EXECUTION SUCCESSFUL |
lyakh
reviewed
Jun 24, 2025
lgirdwood
reviewed
Jun 27, 2025
Member
lgirdwood
left a comment
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.
LGTM - great idea !
2 tasks
b8300ff to
9f07951
Compare
9f07951 to
2c36807
Compare
This commit converts the legacy LIST unit tests from the CMocka/Unity test framework to the Zephyr Ztest framework. The converted tests maintain the same test coverage while adhering to SOF and Zephyr coding standards. The test code was generated with assistance from GitHub Copilot AI. Test flow and test coverage scope is based on the existing CMocka tests located at sof/test/cmocka/src/list. All list operations are covered: - list_init - list_is_empty - list_item_append - list_item_prepend - list_item_del - list_item_is_last Tests can be run with: west twister --testsuite-root sof/test/ztest/unit/ --platform \ native_sim --verbose --inline-logs Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This commit introduces a functional CI workflow that builds and executes SOF unit tests that have been ported from cmocka to Zephyr ztest. Key features: - Targets native_sim platform for unit test execution - Installs minimal dependencies: clang, llvm, ninja-build, device-tree-compiler - Includes multilib support (gcc-multilib/g++-multilib) for i386 native_sim - Runs tests using west twister with verbose output and inline logs - 10-minute timeout for efficient CI resource usage - Proper concurrency control to cancel previous runs The workflow has been tested and verified to work in CI environment. It provides a foundation for continuous integration of SOF unit tests without requiring the full Zephyr SDK installation, making it faster and more resource-efficient. Future iterations can extend this workflow to include additional test suites and platforms as they are developed. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
lyakh
approved these changes
Jul 14, 2025
lgirdwood
approved these changes
Jul 14, 2025
Member
|
@wszypelt good to merge ? not expecting this code to run in internal CI. |
|
@lgirdwood good to merge :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit converts the legacy LIST unit tests from the CMock test framework to the Zephyr Ztest framework. The converted tests maintain the same test coverage while adhering to SOF and Zephyr coding standards.
All list operations are covered:
Tests can be run with:
west twister --testsuite-root sof/test/ztest/unit/list/ --platform native_sim