Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : * @brief Return the selected color mode name for configuration diagnostics
5 : : *
6 : : * The name describes the configured policy, not whether a particular output
7 : : * stream currently permits terminal styling
8 : : *
9 : : * @return Static mode name, or "unknown" for an unsupported mode value
10 : : */
11 : 1480 : static const char *color_mode_name(void)
12 : : {
13 [ + + + - ]: 1480 : switch(rational_color_mode)
14 : : {
15 : 28 : case COLOR_MODE_AUTO:
16 : 28 : return("auto");
17 : 1428 : case COLOR_MODE_ALWAYS:
18 : 1428 : return("always");
19 : 24 : case COLOR_MODE_NEVER:
20 : 24 : return("never");
21 : 0 : default:
22 : 0 : return("unknown");
23 : : }
24 : : }
25 : :
26 : : #ifdef TESTITALL_TEST_HOOKS
27 : : /**
28 : : * @brief Show parsed configuration details for TESTING logger output
29 : : *
30 : : * @details
31 : : * Test templates use these lines as stable key-value diagnostics. The function
32 : : * prints only options that were explicitly set or values that are useful for
33 : : * validating argument parsing behavior
34 : : */
35 : 740 : void show_testing_diagnostics(void)
36 : : {
37 : 740 : slog(TESTING,"rational_logger_mode=%s\n",rational_reconvert(rational_logger_mode));
38 : :
39 [ + + ]: 740 : if(config->config_file_path != NULL)
40 : : {
41 : 130 : slog(TESTING,"argument:config=%s\n",config->config_file_path);
42 : : }
43 : :
44 : 740 : slog(TESTING,"argument:color=%s\n",color_mode_name());
45 : :
46 [ + + ]: 740 : if(config->roots.length != 0)
47 : : {
48 : 592 : bool first_root = true;
49 : :
50 : 592 : slog(TESTING,"argument:roots=");
51 : :
52 [ + + + + ]: 1800 : m_string_array_foreach(conf(roots),root)
53 : : {
54 [ + + ]: 616 : slog(TESTING|UNDECOR,first_root == true ? "%s" : ", %s",m_text(root));
55 : 616 : first_root = false;
56 : : }
57 : 592 : slog(TESTING|UNDECOR,"\n");
58 : : }
59 : :
60 : : // Print configured database path when available
61 [ + + ]: 740 : if(conf(db_primary_file_path)->string_length > 0)
62 : : {
63 : 524 : slog(TESTING,"argument:database=%s\n",confstr(db_primary_file_path));
64 : : }
65 : :
66 : : // Print configured database file name when available
67 [ + + ]: 740 : if(conf(db_file_name)->string_length > 0)
68 : : {
69 : 524 : slog(TESTING,"argument:db_file_name=%s\n",confstr(db_file_name));
70 : : }
71 : :
72 [ + + ]: 740 : if(config->db_file_paths.length != 0)
73 : : {
74 : 148 : bool first_db_file_path = true;
75 : :
76 : 148 : slog(TESTING,"argument:db_file_paths=");
77 : :
78 [ + + + + ]: 592 : m_string_array_foreach(conf(db_file_paths),db_file_path)
79 : : {
80 [ + + ]: 296 : slog(TESTING|UNDECOR,first_db_file_path == true ? "%s" : ", %s",m_text(db_file_path));
81 : 296 : first_db_file_path = false;
82 : : }
83 : 148 : slog(TESTING|UNDECOR,"\n");
84 : : }
85 : :
86 [ + + ]: 740 : if(config->db_file_names != NULL)
87 : : {
88 : 148 : slog(TESTING,"argument:db_file_names=");
89 : :
90 [ + + ]: 444 : for(int i = 0; config->db_file_names[i]; i++)
91 : : {
92 [ + + ]: 296 : slog(TESTING|UNDECOR,i == 0 ? "%s" : ", %s",config->db_file_names[i]);
93 : : }
94 : 148 : slog(TESTING|UNDECOR,"\n");
95 : : }
96 : :
97 [ + + ]: 740 : if(config->ignore != NULL)
98 : : {
99 : 94 : slog(TESTING,"argument:ignore=");
100 : :
101 : : // Print string-array contents
102 [ + + ]: 206 : for(int i = 0; config->ignore[i] != NULL; ++i)
103 : : {
104 [ + + ]: 112 : slog(TESTING|UNDECOR,i == 0 ? "%s" : ", %s",config->ignore[i]);
105 : : }
106 : 94 : slog(TESTING|UNDECOR,"\n");
107 : : }
108 : :
109 [ + + ]: 740 : if(config->include != NULL)
110 : : {
111 : 36 : slog(TESTING,"argument:include=");
112 : :
113 : : // Print string-array contents
114 [ + + ]: 84 : for(int i = 0; config->include[i] != NULL; ++i)
115 : : {
116 [ + + ]: 48 : slog(TESTING|UNDECOR,i == 0 ? "%s" : ", %s",config->include[i]);
117 : : }
118 : 36 : slog(TESTING|UNDECOR,"\n");
119 : : }
120 : :
121 [ + + ]: 740 : if(config->lock_checksum != NULL)
122 : : {
123 : 104 : slog(TESTING,"argument:lock-checksum=");
124 : :
125 : : // Print string-array contents
126 [ + + ]: 218 : for(int i = 0; config->lock_checksum[i] != NULL; ++i)
127 : : {
128 [ + + ]: 114 : slog(TESTING|UNDECOR,i == 0 ? "%s" : ", %s",config->lock_checksum[i]);
129 : : }
130 : 104 : slog(TESTING|UNDECOR,"\n");
131 : : }
132 : :
133 [ + + ]: 740 : if(config->db_check_level != FULL)
134 : : {
135 [ + - ]: 338 : slog(TESTING,"argument:check-level=%s\n",config->db_check_level == QUICK ? "QUICK" : "FULL");
136 : : }
137 : :
138 [ + + ]: 740 : if(config->maxdepth > 0)
139 : : {
140 : 4 : slog(TESTING,"argument:maxdepth=%d\n",config->maxdepth);
141 : : }
142 : :
143 [ + + ]: 740 : if(config->verbose)
144 : : {
145 [ + - ]: 16 : slog(TESTING,"argument:verbose=%s\n",config->verbose ? "yes" : "no");
146 : : }
147 : :
148 [ + + ]: 740 : if(config->quiet_ignored)
149 : : {
150 [ + - ]: 4 : slog(TESTING,"argument:quiet-ignored=%s\n",config->quiet_ignored ? "yes" : "no");
151 : : }
152 : :
153 [ + + ]: 740 : if(config->watch_timestamps)
154 : : {
155 [ + - ]: 30 : slog(TESTING,"argument:watch-timestamps=%s\n",config->watch_timestamps ? "yes" : "no");
156 : : }
157 : :
158 [ + + ]: 740 : if(config->rehash_locked == true)
159 : : {
160 [ + - ]: 21 : slog(TESTING,"argument:rehash-locked=%s\n",config->rehash_locked ? "yes" : "no");
161 : : }
162 : :
163 [ + + ]: 740 : if(config->force)
164 : : {
165 [ + - ]: 4 : slog(TESTING,"argument:force=%s\n",config->force ? "yes" : "no");
166 : : }
167 : :
168 [ + + ]: 740 : if(config->update)
169 : : {
170 [ + - ]: 219 : slog(TESTING,"argument:update=%s\n",config->update ? "yes" : "no");
171 : : }
172 : :
173 [ + + ]: 740 : if(config->progress)
174 : : {
175 [ + - ]: 106 : slog(TESTING,"argument:progress=%s\n",config->progress ? "yes" : "no");
176 : : }
177 : :
178 [ + + ]: 740 : if(config->compare)
179 : : {
180 [ + - ]: 148 : slog(TESTING,"argument:compare=%s\n",config->compare ? "yes" : "no");
181 : : }
182 : :
183 [ + + ]: 740 : if(config->compare_filter)
184 : : {
185 : 58 : bool first_compare_filter = true;
186 : :
187 : 58 : slog(TESTING,"argument:compare-filter=");
188 : :
189 [ + + ]: 58 : if((config->compare_filter & CF_CHECKSUM_MISMATCH) != 0u)
190 : : {
191 [ + - ]: 28 : slog(TESTING|UNDECOR,"%schecksum-mismatch",first_compare_filter ? "" : ", ");
192 : 28 : first_compare_filter = false;
193 : : }
194 : :
195 [ + + ]: 58 : if((config->compare_filter & CF_FIRST_SOURCE) != 0u)
196 : : {
197 [ + + ]: 28 : slog(TESTING|UNDECOR,"%sfirst-source",first_compare_filter ? "" : ", ");
198 : 28 : first_compare_filter = false;
199 : : }
200 : :
201 [ + + ]: 58 : if((config->compare_filter & CF_SECOND_SOURCE) != 0u)
202 : : {
203 [ + + ]: 28 : slog(TESTING|UNDECOR,"%ssecond-source",first_compare_filter ? "" : ", ");
204 : : }
205 : :
206 : 58 : slog(TESTING|UNDECOR,"\n");
207 : : }
208 : :
209 [ + + ]: 740 : if(config->db_drop_ignored)
210 : : {
211 [ + - ]: 28 : slog(TESTING,"argument:db-drop-ignored=%s\n",config->db_drop_ignored ? "yes" : "no");
212 : : }
213 : :
214 [ + + ]: 740 : if(config->db_drop_inaccessible)
215 : : {
216 [ + - ]: 28 : slog(TESTING,"argument:db-drop-inaccessible=%s\n",config->db_drop_inaccessible ? "yes" : "no");
217 : : }
218 : :
219 [ + + ]: 740 : if(config->dry_run)
220 : : {
221 [ + + ]: 119 : slog(TESTING,"argument:dry-run=%s\n",config->dry_run_with_checksums ? "with-checksums" : "yes");
222 : : }
223 : :
224 [ + + ]: 740 : if(config->one_file_system)
225 : : {
226 [ + - ]: 8 : slog(TESTING,"argument:one-file-system=%s\n",config->one_file_system ? "yes" : "no");
227 : : }
228 : 740 : }
229 : : #endif
230 : :
231 : : /**
232 : : * @brief Show parsed configuration details for verbose user output
233 : : *
234 : : * @details
235 : : * Verbose output is a compact, single-line configuration summary for people
236 : : * running the program interactively. It reports the same configuration values
237 : : * as the TESTING diagnostics
238 : : */
239 : 740 : void show_verbose_diagnostics(void)
240 : : {
241 : 740 : slog(VERBOSE,"Configuration: ");
242 : 740 : slog(VERBOSE|UNDECOR,"rational_logger_mode=%s\n",rational_reconvert(rational_logger_mode));
243 : :
244 [ + + ]: 740 : if(config->config_file_path != NULL)
245 : : {
246 : 130 : slog(VERBOSE|UNDECOR,"config=%s; ",config->config_file_path);
247 : : }
248 : :
249 [ + + ]: 740 : if(config->roots.length != 0)
250 : : {
251 : 592 : bool first_root = true;
252 : :
253 : 592 : slog(VERBOSE|UNDECOR,"roots=");
254 : :
255 [ + + + + ]: 1800 : m_string_array_foreach(conf(roots),root)
256 : : {
257 [ + + ]: 616 : slog(VERBOSE|UNDECOR,first_root == true ? "%s" : ", %s",m_text(root));
258 : 616 : first_root = false;
259 : : }
260 : 592 : slog(VERBOSE|UNDECOR,"; ");
261 : : }
262 : :
263 : : // Print configured database path when available
264 [ + + ]: 740 : if(conf(db_primary_file_path)->string_length > 0)
265 : : {
266 : 524 : slog(VERBOSE|UNDECOR,"database=%s; ",confstr(db_primary_file_path));
267 : : }
268 : :
269 : : // Print configured database file name when available
270 [ + + ]: 740 : if(conf(db_file_name)->string_length > 0)
271 : : {
272 : 524 : slog(VERBOSE|UNDECOR,"db_file_name=%s; ",confstr(db_file_name));
273 : : }
274 : :
275 [ + + ]: 740 : if(config->db_file_paths.length != 0)
276 : : {
277 : 148 : bool first_db_file_path = true;
278 : :
279 : 148 : slog(VERBOSE|UNDECOR,"db_file_paths=");
280 : :
281 [ + + + + ]: 592 : m_string_array_foreach(conf(db_file_paths),db_file_path)
282 : : {
283 [ + + ]: 296 : slog(VERBOSE|UNDECOR,first_db_file_path == true ? "%s" : ", %s",m_text(db_file_path));
284 : 296 : first_db_file_path = false;
285 : : }
286 : 148 : slog(VERBOSE|UNDECOR,"; ");
287 : : }
288 : :
289 [ + + ]: 740 : if(config->db_file_names != NULL)
290 : : {
291 : 148 : slog(VERBOSE|UNDECOR,"db_file_names=");
292 : :
293 [ + + ]: 444 : for(int i = 0; config->db_file_names[i]; i++)
294 : : {
295 [ + + ]: 296 : slog(VERBOSE|UNDECOR,i == 0 ? "%s" : ", %s",config->db_file_names[i]);
296 : : }
297 : 148 : slog(VERBOSE|UNDECOR,"; ");
298 : : }
299 : :
300 [ + + ]: 740 : if(config->ignore != NULL)
301 : : {
302 : 94 : slog(VERBOSE|UNDECOR,"ignore=");
303 : :
304 : : // Print string-array contents
305 [ + + ]: 206 : for(int i = 0; config->ignore[i] != NULL; ++i)
306 : : {
307 [ + + ]: 112 : slog(VERBOSE|UNDECOR,i == 0 ? "%s" : ", %s",config->ignore[i]);
308 : : }
309 : 94 : slog(VERBOSE|UNDECOR,"; ");
310 : : }
311 : :
312 [ + + ]: 740 : if(config->include != NULL)
313 : : {
314 : 36 : slog(VERBOSE|UNDECOR,"include=");
315 : :
316 : : // Print string-array contents
317 [ + + ]: 84 : for(int i = 0; config->include[i] != NULL; ++i)
318 : : {
319 [ + + ]: 48 : slog(VERBOSE|UNDECOR,i == 0 ? "%s" : ", %s",config->include[i]);
320 : : }
321 : 36 : slog(VERBOSE|UNDECOR,"; ");
322 : : }
323 : :
324 [ + + ]: 740 : if(config->lock_checksum != NULL)
325 : : {
326 : 104 : slog(VERBOSE|UNDECOR,"lock-checksum=");
327 : :
328 : : // Print string-array contents
329 [ + + ]: 218 : for(int i = 0; config->lock_checksum[i] != NULL; ++i)
330 : : {
331 [ + + ]: 114 : slog(VERBOSE|UNDECOR,i == 0 ? "%s" : ", %s",config->lock_checksum[i]);
332 : : }
333 : 104 : slog(VERBOSE|UNDECOR,"; ");
334 : : }
335 : :
336 : 740 : const char *dry_run_mode = "no";
337 : :
338 [ + + ]: 740 : if(config->dry_run == true)
339 : : {
340 [ + + ]: 119 : if(config->dry_run_with_checksums == true)
341 : : {
342 : 9 : dry_run_mode = "with-checksums";
343 : : } else {
344 : 110 : dry_run_mode = "yes";
345 : : }
346 : : }
347 : :
348 [ + + + + : 740 : slog(VERBOSE|UNDECOR,"verbose=%s; maxdepth=%d; silent=no; quiet-ignored=%s; force=%s; update=%s; watch-timestamps=%s; rehash-locked=%s; progress=%s; compare=%s, db-drop-ignored=%s, db-drop-inaccessible=%s, dry-run=%s, one-file-system=%s, check-level=%s, rational_logger_mode=%s, color=%s",
+ + + + +
+ + + + +
+ + + + +
+ + + +
+ ]
349 : : config->verbose ? "yes" : "no",
350 : : config->maxdepth,
351 : : config->quiet_ignored ? "yes" : "no",
352 : : config->force ? "yes" : "no",
353 : : config->update ? "yes" : "no",
354 : : config->watch_timestamps ? "yes" : "no",
355 : : config->rehash_locked ? "yes" : "no",
356 : : config->progress ? "yes" : "no",
357 : : config->compare ? "yes" : "no",
358 : : config->db_drop_ignored ? "yes" : "no",
359 : : config->db_drop_inaccessible ? "yes" : "no",
360 : : dry_run_mode,
361 : : config->one_file_system ? "yes" : "no",
362 : : config->db_check_level == QUICK ? "QUICK" : "FULL",
363 : : rational_reconvert(rational_logger_mode),
364 : : color_mode_name());
365 : :
366 [ + + ]: 740 : if(config->compare_filter)
367 : : {
368 : 58 : bool first_compare_filter = true;
369 : :
370 : 58 : slog(VERBOSE|UNDECOR,"; compare-filter=");
371 : :
372 [ + + ]: 58 : if((config->compare_filter & CF_CHECKSUM_MISMATCH) != 0u)
373 : : {
374 [ + - ]: 28 : slog(VERBOSE|UNDECOR,"%schecksum-mismatch",first_compare_filter ? "" : ", ");
375 : 28 : first_compare_filter = false;
376 : : }
377 : :
378 [ + + ]: 58 : if((config->compare_filter & CF_FIRST_SOURCE) != 0u)
379 : : {
380 [ + + ]: 28 : slog(VERBOSE|UNDECOR,"%sfirst-source",first_compare_filter ? "" : ", ");
381 : 28 : first_compare_filter = false;
382 : : }
383 : :
384 [ + + ]: 58 : if((config->compare_filter & CF_SECOND_SOURCE) != 0u)
385 : : {
386 [ + + ]: 28 : slog(VERBOSE|UNDECOR,"%ssecond-source",first_compare_filter ? "" : ", ");
387 : : }
388 : : }
389 : :
390 : 740 : slog(VERBOSE|UNDECOR,"\n");
391 : 740 : }
|