Skip to main content

Module test

Module test 

Source
Expand description

IPC ping-pong test (Port-based) + MPMC SyncChannel test (IPC-02).

ยงPort test (Task A / Task B)

Creates two kernel tasks that communicate via an IPC port:

  • Task A (sender): creates a port, stores its ID in a shared static, then sends a message with msg_type=42.
  • Task B (receiver): spins until the port ID is published, then calls recv() (which blocks if the message hasnโ€™t arrived yet), logs the result, and verifies correctness.

ยงChannel test (IPC-02)

Three kernel tasks share a channel::<u64>(4):

  • Producer-1: sends 1, 2, 3 then drops its Sender endpoint.
  • Producer-2: yields once (so the consumer may block), then sends 4, 5.
  • Consumer: blocks on recv() until both producers disconnect, verifies it received exactly 5 messages.

Staticsยง

CHAN_RX ๐Ÿ”’
CHAN_TX1 ๐Ÿ”’
Endpoint slots: each task takes its endpoint out (Option::take) once. SpinLock<Option>: Sync when T: Send : no private-field access needed.
CHAN_TX2 ๐Ÿ”’
SEM_TEST_ID ๐Ÿ”’
SEM_TEST_RESULT ๐Ÿ”’
TEST_PORT_ID ๐Ÿ”’
Shared port ID between the two test tasks. 0 = not yet created.

Functionsยง

chan_consumer_main ๐Ÿ”’
Consumer: drains all messages; expects exactly 5, then Disconnected.
chan_producer1_main ๐Ÿ”’
Producer-1: sends 1, 2, 3 then drops Sender (decrements sender_count).
chan_producer2_main ๐Ÿ”’
Producer-2: yields first so the consumer blocks, then sends 4, 5.
create_channel_test_tasks
Schedule the three channel test tasks.
create_ipc_04_05_test_task
Creates ipc 04 05 test task.
create_ipc_test_tasks
Create and schedule the IPC test tasks.
ipc_04_05_main ๐Ÿ”’
Performs the ipc 04 05 main operation.
ipc_receiver_main ๐Ÿ”’
Receiver task: waits for port ID, calls recv (blocks if needed), logs result.
ipc_sender_main ๐Ÿ”’
Sender task: creates a port, publishes ID, sends a test message, then exits.
sem_poster_main ๐Ÿ”’
Performs the sem poster main operation.