Skip to content

Conversation

@tmleman
Copy link
Contributor

@tmleman tmleman commented Jun 23, 2025

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:

  • 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/list/ --platform native_sim

@tmleman tmleman added the DNM Do Not Merge tag label Jun 23, 2025
@tmleman
Copy link
Contributor Author

tmleman commented Jun 23, 2025

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 completed

or

$ 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

@tmleman tmleman changed the title [SKIP SOFCI-TEST] test: convert LIST unit tests from CMocka to Ztest framework [SKIP SOFCI-TEST] test: convert LIST unit tests from CMock to Ztest framework Jun 23, 2025
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - great idea !

@tmleman tmleman force-pushed the topic/upstream/pr/unit_test/poc/ztest/list branch 13 times, most recently from b8300ff to 9f07951 Compare July 11, 2025 15:34
@tmleman tmleman changed the title [SKIP SOFCI-TEST] test: convert LIST unit tests from CMock to Ztest framework test: convert LIST unit tests from CMock to Ztest framework Jul 11, 2025
@tmleman tmleman marked this pull request as ready for review July 11, 2025 15:35
@tmleman tmleman added DNM Do Not Merge tag and removed DNM Do Not Merge tag labels Jul 14, 2025
@tmleman tmleman force-pushed the topic/upstream/pr/unit_test/poc/ztest/list branch from 9f07951 to 2c36807 Compare July 14, 2025 09:24
@tmleman tmleman removed the DNM Do Not Merge tag label Jul 14, 2025
tmleman added 2 commits July 14, 2025 12:43
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>
@lgirdwood
Copy link
Member

@wszypelt good to merge ? not expecting this code to run in internal CI.

@wszypelt
Copy link

@lgirdwood good to merge :)

@lgirdwood lgirdwood merged commit a7e7df8 into thesofproject:main Jul 16, 2025
40 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants