summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/test
diff options
context:
space:
mode:
authorjoshua <>2025-05-22 02:23:41 +0000
committerjoshua <>2025-05-22 02:23:41 +0000
commit5b7c445f1263dc89805458bfa2c536ff947115ed (patch)
tree256d30090d124831fa2e52f6a8a72039f3a0035f /src/regress/lib/libcrypto/test
parent72db6d31d19d25d9927fd4584785d15fea3fcc43 (diff)
downloadopenbsd-5b7c445f1263dc89805458bfa2c536ff947115ed.tar.gz
openbsd-5b7c445f1263dc89805458bfa2c536ff947115ed.tar.bz2
openbsd-5b7c445f1263dc89805458bfa2c536ff947115ed.zip
Fix test_errorf macro expanding to two lines
This caused test_fail to always be called when used in certain conditions, and wrapping with do {} while (0) fixes this.
Diffstat (limited to 'src/regress/lib/libcrypto/test')
-rw-r--r--src/regress/lib/libcrypto/test/test.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/regress/lib/libcrypto/test/test.h b/src/regress/lib/libcrypto/test/test.h
index e6cfec80ea..051871dd35 100644
--- a/src/regress/lib/libcrypto/test/test.h
+++ b/src/regress/lib/libcrypto/test/test.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: test.h,v 1.1 2025/05/21 08:57:13 joshua Exp $ */ 1/* $OpenBSD: test.h,v 1.2 2025/05/22 02:23:41 joshua Exp $ */
2/* 2/*
3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev> 3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev>
4 * 4 *
@@ -82,7 +82,9 @@ void test_logf_internal(struct test *_t, const char *_label, const char *_func,
82 * stderr if the test fails. 82 * stderr if the test fails.
83 */ 83 */
84#define test_logf(t, fmt, ...) \ 84#define test_logf(t, fmt, ...) \
85 test_logf_internal(t, NULL, __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 85 do { \
86 test_logf_internal(t, NULL, __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \
87 } while (0)
86 88
87/* 89/*
88 * test_errorf prints an error message. It will also cause the test to fail. 90 * test_errorf prints an error message. It will also cause the test to fail.
@@ -93,8 +95,10 @@ void test_logf_internal(struct test *_t, const char *_label, const char *_func,
93 * information about what is broken. 95 * information about what is broken.
94 */ 96 */
95#define test_errorf(t, fmt, ...) \ 97#define test_errorf(t, fmt, ...) \
96 test_logf_internal(t, "ERROR", __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \ 98 do { \
97 test_fail(t) 99 test_logf_internal(t, "ERROR", __func__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \
100 test_fail(t); \
101 } while (0)
98 102
99/* 103/*
100 * test_skip marks the test as skipped. Once called, the test should return. 104 * test_skip marks the test as skipped. Once called, the test should return.