AI: Update utest private access and smart pointers for augment code.
This commit is contained in:
parent
1173560b55
commit
97e2b64939
|
|
@ -19,7 +19,14 @@ architecture:
|
||||||
* Coroutine state must be preserved across yields by async I/O operations
|
* Coroutine state must be preserved across yields by async I/O operations
|
||||||
* Shared state can be modified between context switches
|
* Shared state can be modified between context switches
|
||||||
* Timing-dependent bugs related to when coroutines yield
|
* Timing-dependent bugs related to when coroutines yield
|
||||||
|
|
||||||
|
key_components:
|
||||||
|
- name: "SrsServer"
|
||||||
|
description: "Main server class of live stream for RTMP/HTTP-FLV/HLS/DASH and HTTP-API"
|
||||||
|
- name: "SrsLiveSource"
|
||||||
|
description: "Central management of live stream sources for RTMP/HTTP-FLV/HLS/DASH"
|
||||||
|
|
||||||
|
codebase_structure:
|
||||||
key_directories:
|
key_directories:
|
||||||
- path: "trunk/src/"
|
- path: "trunk/src/"
|
||||||
description: "Main source code directory"
|
description: "Main source code directory"
|
||||||
|
|
@ -46,11 +53,17 @@ architecture:
|
||||||
|
|
||||||
code_patterns:
|
code_patterns:
|
||||||
memory_management:
|
memory_management:
|
||||||
|
- pattern: "SrsUniquePtr<T>"
|
||||||
|
description: "Smart pointer for unique ownership - preferred for single ownership scenarios"
|
||||||
|
usage: "SrsUniquePtr<MyClass> ptr(new MyClass()); ptr->method(); // automatic cleanup"
|
||||||
|
- pattern: "SrsSharedPtr<T>"
|
||||||
|
description: "Smart pointer for shared ownership - preferred for reference counting scenarios"
|
||||||
|
usage: "SrsSharedPtr<MyClass> ptr(new MyClass()); SrsSharedPtr<MyClass> copy = ptr; // reference counted"
|
||||||
- pattern: "srs_freep"
|
- pattern: "srs_freep"
|
||||||
description: "Custom macro for freeing pointers"
|
description: "Custom macro for freeing pointers - use only when smart pointers are not suitable"
|
||||||
- pattern: "srs_freepa"
|
- pattern: "srs_freepa"
|
||||||
description: "Custom macro for freeing arrays"
|
description: "Custom macro for freeing arrays - use only when smart pointers are not suitable"
|
||||||
|
|
||||||
error_handling:
|
error_handling:
|
||||||
- pattern: "srs_error_t"
|
- pattern: "srs_error_t"
|
||||||
description: "Custom error handling system"
|
description: "Custom error handling system"
|
||||||
|
|
@ -59,19 +72,35 @@ code_patterns:
|
||||||
- pattern: "#ifdef SRS_VALGRIND"
|
- pattern: "#ifdef SRS_VALGRIND"
|
||||||
description: "Valgrind support"
|
description: "Valgrind support"
|
||||||
|
|
||||||
key_components:
|
build_and_development:
|
||||||
- name: "SrsServer"
|
build:
|
||||||
description: "Main server class of live stream for RTMP/HTTP-FLV/HLS/DASH and HTTP-API"
|
command: "make -j"
|
||||||
- name: "SrsLiveSource"
|
description: "Build the SRS server using parallel make in the trunk directory"
|
||||||
description: "Central management of live stream sources for RTMP/HTTP-FLV/HLS/DASH"
|
working_directory: "trunk"
|
||||||
|
|
||||||
build:
|
run_utests:
|
||||||
command: "cd trunk && make -j"
|
command: "make utest -j && ./objs/srs_utest"
|
||||||
description: "Build the SRS server using parallel make in the trunk directory"
|
description: "Run the unit tests for SRS"
|
||||||
working_directory: "trunk"
|
working_directory: "trunk"
|
||||||
|
|
||||||
run-utests:
|
testing:
|
||||||
command: "cd trunk && make utest -j && ./objs/srs_utest"
|
test_patterns:
|
||||||
description: "Run the unit tests for SRS"
|
- Note that private and protected members are accessible in utests, as there is a macro to convert them to public
|
||||||
working_directory: "trunk"
|
- Use descriptive test names that clearly indicate what functionality is being tested
|
||||||
|
- Group related tests together (e.g., all tests for one class should be consecutive)
|
||||||
|
- Test both success and failure paths, especially for error handling scenarios
|
||||||
|
- Verify edge cases like sequence number wrap-around, cache overflow, and null inputs
|
||||||
|
- Use existing mock helper functions for consistency and maintainability
|
||||||
|
|
||||||
|
error_handling_macros:
|
||||||
|
- Use HELPER_EXPECT_SUCCESS(x) when expecting a function to succeed (returns srs_success)
|
||||||
|
- Use HELPER_EXPECT_FAILED(x) when expecting a function to fail (returns non-srs_success error)
|
||||||
|
- These macros automatically handle error cleanup and provide better error messages
|
||||||
|
- Always declare "srs_error_t err;" at the beginning of test functions that use these macros
|
||||||
|
- |
|
||||||
|
Example:
|
||||||
|
VOID TEST(MyTest, TestFunction) {
|
||||||
|
srs_error_t err;
|
||||||
|
HELPER_EXPECT_SUCCESS(some_function_that_should_succeed());
|
||||||
|
HELPER_EXPECT_FAILED(some_function_that_should_fail());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user