|
6 | 6 | * Change Logs: |
7 | 7 | * Date Author Notes |
8 | 8 | * 2025-07-18 kurisaW First commit |
| 9 | + * 2025-11-13 CYFS Add standardized documentation block for object_tc |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * Test Case Name: Kernel Object Management Test |
| 14 | + * |
| 15 | + * Test Objectives: |
| 16 | + * - Validate RT-Thread object lifecycle, lookup, enumeration, and metadata utilities |
| 17 | + * - Verify core APIs: rt_object_init, rt_object_allocate, rt_object_delete, rt_object_detach, |
| 18 | + * rt_object_find, rt_thread_find, rt_device_find, rt_object_get_information, |
| 19 | + * rt_object_get_length, rt_object_get_pointers, rt_object_get_name, rt_object_get_type, |
| 20 | + * rt_object_is_systemobject |
| 21 | + * |
| 22 | + * Test Scenarios: |
| 23 | + * - **Scenario 1 (Name Handling / test_object_name_handling):** |
| 24 | + * 1. Create static objects with maximum-length names to validate truncation and null-termination rules. |
| 25 | + * 2. Allocate dynamic objects with maximum-length names to confirm dynamic object naming and non-system classification. |
| 26 | + * 3. Exercise NULL name handling for both static initialization and dynamic allocation paths. |
| 27 | + * 4. Verify exact-length names remain intact alongside proper detach/cleanup. |
| 28 | + * - **Scenario 2 (Find Operations / test_object_find_operations):** |
| 29 | + * 1. Register static thread objects and verify discovery via rt_object_find. |
| 30 | + * 2. Create runtime threads and confirm rt_thread_find returns expected handles. |
| 31 | + * 3. (Optional with RT_USING_DEVICE) Register temporary devices, test rt_device_find against multiple entries, and validate deregistration paths. |
| 32 | + * 4. Test same-prefix device registrations to confirm distinct name resolution. |
| 33 | + * 5. Validate negative paths for nonexistent and NULL names across object, thread, and device lookup helpers. |
| 34 | + * - **Scenario 3 (Info Enumeration / test_object_info_enumeration):** |
| 35 | + * 1. Mix static and dynamic thread objects and query rt_object_get_information for metadata. |
| 36 | + * 2. Retrieve counts with rt_object_get_length and enumerate pointers with sufficient buffer space. |
| 37 | + * 3. Probe buffer boundary behavior by providing undersized pointer arrays. |
| 38 | + * 4. (Optional with RT_USING_SEMAPHORE) Inspect empty semaphore container reporting. |
| 39 | + * - **Scenario 4 (Type Utilities / test_object_type_handling):** |
| 40 | + * 1. Inspect object type via rt_object_get_type and verify system-object status. |
| 41 | + * 2. Retrieve object names using full buffers, truncated buffers, and invalid parameters. |
| 42 | + * 3. Confirm error codes for NULL object pointers, NULL buffers, and zero-length requests. |
| 43 | + * |
| 44 | + * Verification Metrics: |
| 45 | + * - **Scenario 1:** Name strings must be null-terminated within TEST_RT_NAME_MAX, retain expected contents, and reflect correct system-object classification. |
| 46 | + * - **Scenario 2:** Lookup helpers return valid handles for registered objects, correctly distinguish between devices with similar name prefixes, and return NULL for missing or invalid names; device deregistration must succeed. |
| 47 | + * - **Scenario 3:** Enumeration APIs report counts ≥ created objects, populate pointer arrays without overflow, and respect small-buffer contracts. |
| 48 | + * - **Scenario 4:** Type and name utilities yield correct metadata and error codes across valid/invalid inputs, preserving partial name copies when truncated. |
| 49 | + * |
| 50 | + * Dependencies: |
| 51 | + * - Scheduler availability (`rt_scheduler_is_available`) required before executing the suite. |
| 52 | + * - Dynamic memory (rt_malloc/rt_free) needed for pointer buffer allocation. |
| 53 | + * - `RT_USING_UTEST` enabled with test entry registered under `core.object`. |
| 54 | + * - Optional paths: `RT_USING_DEVICE` for device lookup tests, `RT_USING_SEMAPHORE` for semaphore enumeration checks. |
| 55 | + * |
| 56 | + * Expected Results: |
| 57 | + * - Test runs to completion with all assertions passing in the utest framework. |
| 58 | + * - Console shows `[ PASSED ] [ result ] testcase (core.object)` when invoked via `utest_run core.object`. |
9 | 59 | */ |
10 | 60 |
|
11 | 61 | #include <utest.h> |
|
0 commit comments