Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions components/drivers/audio/utest/tc_audio_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,43 @@
* Change Logs:
* Date Author Notes
* 2025-05-01 wumingzi first version
* 2025-11-24 ChuanN-sudo add standardized utest documentation block
Comment on lines 8 to +9
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

🔴 [Date/日期]: Future dates in changelog / 变更日志中的未来日期

English: The dates "2025-05-01" and "2025-11-24" are in the future. Changelog dates must reflect the actual date when changes were made. Please update these to the correct historical dates.

中文:日期 "2025-05-01" 和 "2025-11-24" 是未来日期。变更日志日期必须反映实际修改时的日期。请更新为正确的历史日期。

Suggested change
* 2025-05-01 wumingzi first version
* 2025-11-24 ChuanN-sudo add standardized utest documentation block
* 2024-05-01 wumingzi first version
* 2024-06-01 ChuanN-sudo add standardized utest documentation block

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

日期没问题

*/

/* The file can test the rt-thread audio driver framework including following api via memory
* simulation.
/**
* Test Case Name: Audio Test
*
* rt_audio_register
* rt_audio_rx_done
* rt_audio_tx_complete
* Test Objectives:
* - Validate RT-Thread audio driver framework registration and data flow mechanisms.
* - Verify audio playback (TX) and recording (RX) data transmission correctness.
* - Ensure proper buffer management and memory integrity during audio operations.
* - Test core APIs: rt_audio_register(), rt_audio_tx_complete(), rt_audio_rx_done()
*
* When audio devices generate or receive new data, the corresponding buffer in device will
* receive date from kernel or surroundings. The same phenomenon will also happen at the
* application level. Thus we can fill memory to simulate the generation of data then track
* and check memory to ensure kernel processing audio data correctly. And this depends on
* implementations of audio drivers.
* Test Scenarios:
* - Locate audio devices using SOUND_PLAYER_DEVICE_NAME and SOUND_MIC_DEVICE_NAME macros.
* - Write known byte patterns (0xAA, 0x55) to simulate audio data flow through TX/RX buffers.
* - Synchronize player and microphone test execution using audio_fsm_step state machine.
* - Test two consecutive block transfers for both TX and RX paths.
*
* Therefore, if the player_test testcase failed, it could mean rt_audio_register or
* rt_audio_tx_complete existing bugs. Similarly, if mic_test testcase failed, it could mean
* rt_audio_register or rt_audio_rx_done existing bugs.
* Verification Metrics:
* - Written audio data appears correctly in device TX buffers with exact byte patterns.
* - Data read from microphone device matches expected fill patterns (0xAA then 0x55) without corruption.
* - Buffer boundaries are respected with no overflow or underflow conditions.
* - Device open/close operations complete successfully without resource leaks.
*
* Dependencies:
* - Hardware requirements: QEMU emulator or any hardware platform that supports RT-Thread.
* - Software configuration:
* - RT_USING_UTESTCASES must be enabled (select "RT-Thread Utestcases" in menuconfig).
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

🟡 [Terminology/术语]: Inconsistent terminology / 术语不一致

English: The term "Utestcases" should be "Unit Test Cases" or "utest cases" for consistency with standard terminology. The macro name RT_USING_UTESTCASES is correct, but the description should use proper terminology.

中文:术语 "Utestcases" 应为 "Unit Test Cases" 或 "utest cases" 以与标准术语保持一致。宏名称 RT_USING_UTESTCASES 是正确的,但描述应使用正确的术语。

Suggested: "RT_USING_UTESTCASES must be enabled (select 'RT-Thread Unit Test Cases' in menuconfig)."

Suggested change
* - RT_USING_UTESTCASES must be enabled (select "RT-Thread Utestcases" in menuconfig).
* - RT_USING_UTESTCASES must be enabled (select "RT-Thread Unit Test Cases" in menuconfig).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里的描述按照menuconfig描述的

* - RT_USING_AUDIO must be enabled (enable via: RT-Thread Components -> Device Drivers -> Using Audio device drivers).
* - RT_UTEST_USING_AUDIO_DRIVER must be enabled (enable via: RT-Thread Utestcases -> Kernel Components-> Drivers -> Audio Test).
* - Environmental Assumptions: Audio devices registered and functional, sufficient memory available.
*
* Expected Results:
* - Final output: "[ PASSED ] [ result ] testcase (components.drivers.audio.tc_audio_main)"
* - No memory leaks detected during buffer allocation/deallocation.
* - No assertions triggered during test execution.
* - Buffer content verification passes for all test patterns.
*/

#include "tc_audio_common.h"
Expand Down