|
1 | 1 | /* |
2 | | - * Copyright (c) 2006-2024 RT-Thread Development Team |
| 2 | + * Copyright (c) 2006-2025 RT-Thread Development Team |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | * |
6 | 6 | * Change Logs: |
7 | 7 | * Date Author Notes |
8 | 8 | * 2021-06-16 KyleChan the first version |
| 9 | + * 2025-11-13 CYFS Add standardized utest documentation block |
| 10 | +*/ |
| 11 | + |
| 12 | +/** |
| 13 | + * Test Case Name: UART POSIX Non-Blocking Test |
| 14 | + * |
| 15 | + * Test Objectives: |
| 16 | + * - Validate POSIX-layer non-blocking serial operations using termios configuration |
| 17 | + * - Verify APIs: open/close, tcgetattr/tcsetattr, cfsetispeed/cfsetospeed, fcntl(O_NONBLOCK), |
| 18 | + * read, write, rt_thread_mdelay |
| 19 | + * |
| 20 | + * Test Scenarios: |
| 21 | + * - **Scenario 1 (Non-Blocking Echo / tc_uart_api):** |
| 22 | + * 1. Open POSIX device `RT_SERIAL_POSIX_TC_DEVICE_NAME`, configure baud, frame format, and disable flow control. |
| 23 | + * 2. Enable O_NONBLOCK mode and allocate small TX/RX buffer. |
| 24 | + * 3. Loop `RT_SERIAL_TC_SEND_ITERATIONS` times, issuing fixed-size and random-length writes, followed by reads after short delays to confirm echo data availability. |
| 25 | + * |
| 26 | + * Verification Metrics: |
| 27 | + * - Each write/read pair returns the expected number of bytes. |
| 28 | + * - No system calls fail; routine returns RT_TRUE signalling success. |
| 29 | + * |
| 30 | + * Dependencies: |
| 31 | + * - Requires `RT_UTEST_SERIAL_V2` with POSIX device exposure (`RT_SERIAL_POSIX_TC_DEVICE_NAME`) and loopback wiring. |
| 32 | + * - Operating environment must provide termios/fcntl APIs (e.g., RT-Thread POSIX layer or Linux host). |
| 33 | + * |
| 34 | + * Expected Results: |
| 35 | + * - Test executes without assertions; logs remain quiet unless errors occur. |
| 36 | + * - Utest harness prints `[ PASSED ] [ result ] testcase (components.drivers.serial.v2.uart_posix_nonblock)`. |
9 | 37 | */ |
10 | 38 |
|
11 | 39 | #include <rtthread.h> |
|
0 commit comments