Skip to content

Add thread attribute to test harness#413

Open
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/add_thread_attribute_to_test_harness
Open

Add thread attribute to test harness#413
xuchang-vivo wants to merge 1 commit into
vivoblueos:mainfrom
xuchang-vivo:xc/add_thread_attribute_to_test_harness

Conversation

@xuchang-vivo
Copy link
Copy Markdown
Contributor

@xuchang-vivo xuchang-vivo commented May 11, 2026

Summary

  • Add a thread attribute to blueos_test_macro::test and only_test so a test body can run concurrently in multiple BlueOS threads.
  • Keep existing serial and repeat behavior unchanged when thread is omitted or set to 1.
  • Add a kernel unittest that combines thread = 2 with repeat = 2 to validate concurrent execution.

Why

This gives stress and regression tests a direct way to exercise concurrent paths from the test harness without hand-rolling thread startup and completion coordination in each test.

Implementation Notes

  • The macro parses repeat and thread together, rejects duplicate or zero values, and uses ConstBarrier plus wait_until/wake for threaded execution.
  • Kernel unit tests alias crate as blueos inside the test module only, so the macro can use the same blueos::... paths as external unittest crates.

Testing

  • rustfmt test_harness/src/lib.rs kernel/src/lib.rs
  • ninja -C out/qemu_mps2_an385.debug kernel_unittest_clippy
  • ninja -C out/qemu_mps2_an385.debug kernel/kernel:run_unittest

Expected Output

The new test_harness_thread_attribute unittest is declared as #[test(thread = 2, repeat = 2)], so the kernel unittest run prints one RUN/OK pair per repeat iteration and includes the configured thread count:

[ RUN      ] test_harness_thread_attribute [1/2, threads=2]
[       OK ] test_harness_thread_attribute [1/2, threads=2]
[ RUN      ] test_harness_thread_attribute [2/2, threads=2]
[       OK ] test_harness_thread_attribute [2/2, threads=2]

@xuchang-vivo
Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/25646966663.

@xuchang-vivo xuchang-vivo marked this pull request as ready for review May 11, 2026 02:31
@xuchang-vivo
Copy link
Copy Markdown
Contributor Author

build_prs

@github-actions
Copy link
Copy Markdown

@xuchang-vivo
Copy link
Copy Markdown
Contributor Author

build_prs

@xuchang-vivo xuchang-vivo marked this pull request as draft May 11, 2026 02:35
@github-actions
Copy link
Copy Markdown

❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/25647237583.

@github-actions
Copy link
Copy Markdown

@xuchang-vivo xuchang-vivo marked this pull request as ready for review May 11, 2026 02:54
@github-actions
Copy link
Copy Markdown

✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/25647307332.

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.

2 participants