summaryrefslogtreecommitdiff
path: root/regress/unittests/test_helper/test_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/unittests/test_helper/test_helper.c')
-rw-r--r--regress/unittests/test_helper/test_helper.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/regress/unittests/test_helper/test_helper.c b/regress/unittests/test_helper/test_helper.c
index 6f7f381c7..400555ed2 100644
--- a/regress/unittests/test_helper/test_helper.c
+++ b/regress/unittests/test_helper/test_helper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: test_helper.c,v 1.3 2015/01/13 14:51:51 djm Exp $ */ 1/* $OpenBSD: test_helper.c,v 1.4 2015/01/15 07:36:28 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2011 Damien Miller <djm@mindrot.org> 3 * Copyright (c) 2011 Damien Miller <djm@mindrot.org>
4 * 4 *
@@ -114,6 +114,7 @@ static u_int test_number = 0;
114static test_onerror_func_t *test_onerror = NULL; 114static test_onerror_func_t *test_onerror = NULL;
115static void *onerror_ctx = NULL; 115static void *onerror_ctx = NULL;
116static const char *data_dir = NULL; 116static const char *data_dir = NULL;
117static char subtest_info[512];
117 118
118int 119int
119main(int argc, char **argv) 120main(int argc, char **argv)
@@ -185,8 +186,9 @@ test_data_file(const char *name)
185void 186void
186test_info(char *s, size_t len) 187test_info(char *s, size_t len)
187{ 188{
188 snprintf(s, len, "In test %u - \"%s\"\n", test_number, 189 snprintf(s, len, "In test %u: \"%s\"%s%s\n", test_number,
189 active_test_name == NULL ? "<none>" : active_test_name); 190 active_test_name == NULL ? "<none>" : active_test_name,
191 *subtest_info != '\0' ? " - " : "", subtest_info);
190} 192}
191 193
192#ifdef SIGINFO 194#ifdef SIGINFO
@@ -205,6 +207,7 @@ test_start(const char *n)
205{ 207{
206 assert(active_test_name == NULL); 208 assert(active_test_name == NULL);
207 assert((active_test_name = strdup(n)) != NULL); 209 assert((active_test_name = strdup(n)) != NULL);
210 *subtest_info = '\0';
208 if (verbose_mode) 211 if (verbose_mode)
209 printf("test %u - \"%s\": ", test_number, active_test_name); 212 printf("test %u - \"%s\": ", test_number, active_test_name);
210 test_number++; 213 test_number++;
@@ -223,6 +226,7 @@ set_onerror_func(test_onerror_func_t *f, void *ctx)
223void 226void
224test_done(void) 227test_done(void)
225{ 228{
229 *subtest_info = '\0';
226 assert(active_test_name != NULL); 230 assert(active_test_name != NULL);
227 free(active_test_name); 231 free(active_test_name);
228 active_test_name = NULL; 232 active_test_name = NULL;
@@ -235,6 +239,16 @@ test_done(void)
235} 239}
236 240
237void 241void
242test_subtest_info(const char *fmt, ...)
243{
244 va_list ap;
245
246 va_start(ap, fmt);
247 vsnprintf(subtest_info, sizeof(subtest_info), fmt, ap);
248 va_end(ap);
249}
250
251void
238ssl_err_check(const char *file, int line) 252ssl_err_check(const char *file, int line)
239{ 253{
240 long openssl_error = ERR_get_error(); 254 long openssl_error = ERR_get_error();
@@ -280,8 +294,9 @@ static void
280test_header(const char *file, int line, const char *a1, const char *a2, 294test_header(const char *file, int line, const char *a1, const char *a2,
281 const char *name, enum test_predicate pred) 295 const char *name, enum test_predicate pred)
282{ 296{
283 fprintf(stderr, "\n%s:%d test #%u \"%s\"\n", 297 fprintf(stderr, "\n%s:%d test #%u \"%s\"%s%s\n",
284 file, line, test_number, active_test_name); 298 file, line, test_number, active_test_name,
299 *subtest_info != '\0' ? " - " : "", subtest_info);
285 fprintf(stderr, "ASSERT_%s_%s(%s%s%s) failed:\n", 300 fprintf(stderr, "ASSERT_%s_%s(%s%s%s) failed:\n",
286 name, pred_name(pred), a1, 301 name, pred_name(pred), a1,
287 a2 != NULL ? ", " : "", a2 != NULL ? a2 : ""); 302 a2 != NULL ? ", " : "", a2 != NULL ? a2 : "");