Skip to content

Commit 195435d

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

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

.augment-guidelines

Lines changed: 38 additions & 15 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"
@@ -50,7 +57,7 @@ code_patterns:
5057
description: "Custom macro for freeing pointers"
5158
- pattern: "srs_freepa"
5259
description: "Custom macro for freeing arrays"
53-
60+
5461
error_handling:
5562
- pattern: "srs_error_t"
5663
description: "Custom error handling system"
@@ -59,19 +66,35 @@ code_patterns:
5966
- pattern: "#ifdef SRS_VALGRIND"
6067
description: "Valgrind support"
6168

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"
69+
build_and_development:
70+
build:
71+
command: "make -j"
72+
description: "Build the SRS server using parallel make in the trunk directory"
73+
working_directory: "trunk"
6774

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"
75+
run_utests:
76+
command: "make utest -j && ./objs/srs_utest"
77+
description: "Run the unit tests for SRS"
78+
working_directory: "trunk"
7279

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"
80+
testing:
81+
test_patterns:
82+
- Note that private and protected members are accessible in utests, as there is a macro to convert them to public
83+
- Use descriptive test names that clearly indicate what functionality is being tested
84+
- Group related tests together (e.g., all tests for one class should be consecutive)
85+
- Test both success and failure paths, especially for error handling scenarios
86+
- Verify edge cases like sequence number wrap-around, cache overflow, and null inputs
87+
- Use existing mock helper functions for consistency and maintainability
7788

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

0 commit comments

Comments
 (0)