summaryrefslogtreecommitdiffstats
path: root/tap/tap.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 13:18:17 +0200
committerGitHub <noreply@github.com>2025-09-15 13:18:17 +0200
commit8ef825d85fb4d09c32ca44c545d6eb8d995ddea4 (patch)
tree5ab7b18797dfd5849dec7827c87ca3bb5fcb0993 /tap/tap.c
parenta3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff)
parent204cf956f0b3db90d079321ee957b3860da7e33f (diff)
downloadmonitoring-plugins-8ef825d85fb4d09c32ca44c545d6eb8d995ddea4.tar.gz
Merge pull request #2149 from RincewindsHat/clang-format
Clang format
Diffstat (limited to 'tap/tap.c')
-rw-r--r--tap/tap.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/tap/tap.c b/tap/tap.c
index 00ceab27..fb40736f 100644
--- a/tap/tap.c
+++ b/tap/tap.c
@@ -65,7 +65,8 @@ static void _cleanup(void);
65 * test_name -- the name of the test, may be NULL 65 * test_name -- the name of the test, may be NULL
66 * test_comment -- a comment to print afterwards, may be NULL 66 * test_comment -- a comment to print afterwards, may be NULL
67 */ 67 */
68unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line, char *test_name, ...) { 68unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line, char *test_name,
69 ...) {
69 va_list ap; 70 va_list ap;
70 char *local_test_name = NULL; 71 char *local_test_name = NULL;
71 char *c; 72 char *c;
@@ -95,7 +96,9 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line
95 } 96 }
96 97
97 if (name_is_digits) { 98 if (name_is_digits) {
98 diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name); 99 diag(
100 " You named your test '%s'. You shouldn't use numbers for your test names.",
101 local_test_name);
99 diag(" Very confusing."); 102 diag(" Very confusing.");
100 } 103 }
101 } 104 }
@@ -116,8 +119,9 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line
116 if (local_test_name != NULL) { 119 if (local_test_name != NULL) {
117 flockfile(stdout); 120 flockfile(stdout);
118 for (c = local_test_name; *c != '\0'; c++) { 121 for (c = local_test_name; *c != '\0'; c++) {
119 if (*c == '#') 122 if (*c == '#') {
120 fputc('\\', stdout); 123 fputc('\\', stdout);
124 }
121 fputc((int)*c, stdout); 125 fputc((int)*c, stdout);
122 } 126 }
123 funlockfile(stdout); 127 funlockfile(stdout);
@@ -135,14 +139,16 @@ unsigned int _gen_result(int ok, const char *func, char *file, unsigned int line
135 the test failed. */ 139 the test failed. */
136 if (todo) { 140 if (todo) {
137 printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed); 141 printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed);
138 if (!ok) 142 if (!ok) {
139 failures--; 143 failures--;
144 }
140 } 145 }
141 146
142 printf("\n"); 147 printf("\n");
143 148
144 if (!ok) 149 if (!ok) {
145 diag(" Failed %stest (%s:%s() at line %d)", todo ? "(TODO) " : "", file, func, line); 150 diag(" Failed %stest (%s:%s() at line %d)", todo ? "(TODO) " : "", file, func, line);
151 }
146 152
147 free(local_test_name); 153 free(local_test_name);
148 154
@@ -212,8 +218,9 @@ int plan_skip_all(char *reason) {
212 218
213 printf("1..0"); 219 printf("1..0");
214 220
215 if (reason != NULL) 221 if (reason != NULL) {
216 printf(" # Skip %s", reason); 222 printf(" # Skip %s", reason);
223 }
217 224
218 printf("\n"); 225 printf("\n");
219 226
@@ -294,7 +301,8 @@ int skip(unsigned int n, char *fmt, ...) {
294 301
295 while (n-- > 0) { 302 while (n-- > 0) {
296 test_count++; 303 test_count++;
297 printf("ok %d # skip %s\n", test_count, skip_msg != NULL ? skip_msg : "libtap():malloc() failed"); 304 printf("ok %d # skip %s\n", test_count,
305 skip_msg != NULL ? skip_msg : "libtap():malloc() failed");
298 } 306 }
299 307
300 free(skip_msg); 308 free(skip_msg);
@@ -396,8 +404,9 @@ void _cleanup(void) {
396 return; 404 return;
397 } 405 }
398 406
399 if (failures) 407 if (failures) {
400 diag("Looks like you failed %d tests of %d.", failures, test_count); 408 diag("Looks like you failed %d tests of %d.", failures, test_count);
409 }
401 410
402 UNLOCK; 411 UNLOCK;
403} 412}