@@ -90,6 +90,7 @@ void helper_checkConfig(util_log_config_t *expected, util_log_config_t *is) {
90
90
}
91
91
92
92
TEST_F (test, parseEnv_errors) {
93
+ expected_message = " " ;
93
94
loggerConfig = {0 , 0 , LOG_ERROR, LOG_ERROR, NULL };
94
95
expect_fput_count = 0 ;
95
96
expected_stream = stderr;
@@ -105,6 +106,9 @@ TEST_F(test, parseEnv_errors) {
105
106
helper_checkConfig (&b, &loggerConfig);
106
107
helper_log_init (" _level:debug" );
107
108
helper_checkConfig (&b, &loggerConfig);
109
+ expect_fput_count = 1 ;
110
+ expected_message = " [ERROR UMF] Cannot open output file - path too long\n " ;
111
+ helper_log_init ((" output:file," + std::string (300 , ' x' )).c_str ());
108
112
}
109
113
110
114
TEST_F (test, parseEnv) {
@@ -148,17 +152,20 @@ TEST_F(test, parseEnv) {
148
152
output.first + " ;" +
149
153
timestamp.first + " ;" + pid.first ;
150
154
b = loggerConfig = {0 , 0 , LOG_ERROR, LOG_ERROR, NULL };
155
+ expect_fput_count = 0 ;
156
+ expect_fopen_count = 0 ;
157
+ expected_stream = stderr;
158
+ expected_message = " " ;
159
+ expected_filename = " " ;
160
+ auto n = output.first .find (' ,' );
161
+ if (n != std::string::npos) {
162
+ expected_filename = output.first .substr (n + 1 );
163
+ }
164
+
151
165
if (output.second != NULL ) {
152
166
b.output = output.second ;
153
167
if (output.second == MOCK_FILE_PTR) {
154
168
expect_fopen_count = 1 ;
155
- } else {
156
- expect_fopen_count = 0 ;
157
- }
158
- auto n = output.first .find (' ,' );
159
- if (n != std::string::npos) {
160
- expected_filename =
161
- output.first .substr (n + 1 ).c_str ();
162
169
}
163
170
expected_stream = output.second ;
164
171
b.timestamp = timestamp.second ;
@@ -168,13 +175,14 @@ TEST_F(test, parseEnv) {
168
175
b.level = (util_log_level_t )logLevel.second ;
169
176
if (logLevel.second <= LOG_INFO) {
170
177
expect_fput_count = 1 ;
171
- } else {
172
- expect_fput_count = 0 ;
173
178
}
174
179
} else {
175
180
expect_fput_count = 1 ;
176
- expect_fopen_count = 0 ;
177
- expected_stream = stderr;
181
+ if (expected_filename.size () > MAX_FILE_PATH) {
182
+ expected_message =
183
+ " [ERROR UMF] Cannot open output file - "
184
+ " path too long\n " ;
185
+ }
178
186
}
179
187
helper_log_init (envVar.c_str ());
180
188
helper_checkConfig (&b, &loggerConfig);
0 commit comments