Skip to content

Commit 97e2b64

Browse files
committed
AI: Update utest private access and smart pointers for augment code.
1 parent 1173560 commit 97e2b64

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

.augment-guidelines

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ architecture:
1919
* Coroutine state must be preserved across yields by async I/O operations
2020
* Shared state can be modified between context switches
2121
* Timing-dependent bugs related to when coroutines yield
22-
22+
23+
key_components:
24+
- name: "SrsServer"
25+
description: "Main server class of live stream for RTMP/HTTP-FLV/HLS/DASH and HTTP-API"
26+
- name: "SrsLiveSource"
27+
description: "Central management of live stream sources for RTMP/HTTP-FLV/HLS/DASH"
28+
29+
codebase_structure:
2330
key_directories:
2431
- path: "trunk/src/"
2532
description: "Main source code directory"
@@ -46,11 +53,17 @@ architecture:
4653

4754
code_patterns:
4855
memory_management:
56+
- pattern: "SrsUniquePtr<T>"
57+
description: "Smart pointer for unique ownership - preferred for single ownership scenarios"
58+
usage: "SrsUniquePtr<MyClass> ptr(new MyClass()); ptr->method(); // automatic cleanup"
59+
- pattern: "SrsSharedPtr<T>"
60+
description: "Smart pointer for shared ownership - preferred for reference counting scenarios"
61+
usage: "SrsSharedPtr<MyClass> ptr(new MyClass()); SrsSharedPtr<MyClass> copy = ptr; // reference counted"
4962
- pattern: "srs_freep"
50-
description: "Custom macro for freeing pointers"
63+
description: "Custom macro for freeing pointers - use only when smart pointers are not suitable"
5164
- pattern: "srs_freepa"
52-
description: "Custom macro for freeing arrays"
53-
65+
description: "Custom macro for freeing arrays - use only when smart pointers are not suitable"
66+
5467
error_handling:
5568
- pattern: "srs_error_t"
5669
description: "Custom error handling system"
@@ -59,19 +72,35 @@ code_patterns:
5972
- pattern: "#ifdef SRS_VALGRIND"
6073
description: "Valgrind support"
6174

62-
key_components:
63-
- name: "SrsServer"
64-
description: "Main server class of live stream for RTMP/HTTP-FLV/HLS/DASH and HTTP-API"
65-
- name: "SrsLiveSource"
66-
description: "Central management of live stream sources for RTMP/HTTP-FLV/HLS/DASH"
75+
build_and_development:
76+
build:
77+
command: "make -j"
78+
description: "Build the SRS server using parallel make in the trunk directory"
79+
working_directory: "trunk"
6780

68-
build:
69-
command: "cd trunk && make -j"
70-
description: "Build the SRS server using parallel make in the trunk directory"
71-
working_directory: "trunk"
81+
run_utests:
82+
command: "make utest -j && ./objs/srs_utest"
83+
description: "Run the unit tests for SRS"
84+
working_directory: "trunk"
7285

73-
run-utests:
74-
command: "cd trunk && make utest -j && ./objs/srs_utest"
75-
description: "Run the unit tests for SRS"
76-
working_directory: "trunk"
86+
testing:
87+
test_patterns:
88+
- Note that private and protected members are accessible in utests, as there is a macro to convert them to public
89+
- Use descriptive test names that clearly indicate what functionality is being tested
90+
- Group related tests together (e.g., all tests for one class should be consecutive)
91+
- Test both success and failure paths, especially for error handling scenarios
92+
- Verify edge cases like sequence number wrap-around, cache overflow, and null inputs
93+
- Use existing mock helper functions for consistency and maintainability
7794

95+
error_handling_macros:
96+
- Use HELPER_EXPECT_SUCCESS(x) when expecting a function to succeed (returns srs_success)
97+
- Use HELPER_EXPECT_FAILED(x) when expecting a function to fail (returns non-srs_success error)
98+
- These macros automatically handle error cleanup and provide better error messages
99+
- Always declare "srs_error_t err;" at the beginning of test functions that use these macros
100+
- |
101+
Example:
102+
VOID TEST(MyTest, TestFunction) {
103+
srs_error_t err;
104+
HELPER_EXPECT_SUCCESS(some_function_that_should_succeed());
105+
HELPER_EXPECT_FAILED(some_function_that_should_fail());
106+
}

0 commit comments

Comments
 (0)