Skip to content

Conversation

@Mattemagikern
Copy link
Contributor

This commit adds a new test case to the pipe API concurrency tests to verify the behavior of zero-length pipes. The test ensures that writing to a zero-length pipe blocks until data is read, and reading from a zero-length pipe blocks until data is written—unless the pipe is closed, reset, or the operation times out.

The test creates two pipes with zero-length buffers and spawns a helper thread that performs complementary read/write operations. The two threads use the pipe API as their only synchronization mechanism, validating the correct blocking and wake-up behavior of zero-length pipes under concurrent access.

@Mattemagikern Mattemagikern marked this pull request as ready for review October 25, 2025 14:49
@zephyrbot zephyrbot added area: Kernel area: Tests Issues related to a particular existing or missing test labels Oct 25, 2025
npitre
npitre previously approved these changes Oct 26, 2025
Copy link
Contributor

@peter-mitsis peter-mitsis left a comment

Choose a reason for hiding this comment

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

I think this test needs a couple more checks to properly show the behavior described by the commit message.

  1. Since the claim is that the zero-length pipe should block, it is better to not rely upon just the pipe behavior. I recommend setting a global variable in both thread_read_write() and test_zero_size_pipe_read_write() so that it can be inspected and show that context switches did occur where they were expected.
  2. In test_zero_size_pipe_read_write(), I recommend initializing the contents of output so that they are guaranteed to be different than the initialized contents of input. Thus, when the two buffers are ultimately compared, we are that much more certain that the expected match is not a false positive from uninitialized data.
  3. Similar to the previous comment, in thread_read_write(), tmp should be initialized to something different than both input and output from test_zero_size_pipe_read_write().

This commit adds a new test case to the pipe API concurrency tests to
verify the behavior of zero-length pipes. The test ensures that writing
to a zero-length pipe blocks until data is read, and reading from a
zero-length pipe blocks until data is written—unless the pipe is closed,
reset, or the operation times out.

The test creates two pipes with zero-length buffers and spawns a helper
thread that performs complementary read/write operations. The two threads
use the pipe API as their only synchronization mechanism, validating the
correct blocking and wake-up behavior of zero-length pipes under
concurrent access.

Signed-off-by: Måns Ansgariusson <[email protected]>
@sonarqubecloud
Copy link

@cfriedt cfriedt merged commit 8c07902 into zephyrproject-rtos:main Oct 30, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Kernel area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants