Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 1 | /** \file metatest.c |
| 2 | * |
| 3 | * \brief Test features of the test framework. |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 4 | * |
| 5 | * When you run this program, it runs a single "meta-test". A meta-test |
| 6 | * performs an operation which should be caught as a failure by our |
| 7 | * test framework. The meta-test passes if this program calls `exit` with |
| 8 | * a nonzero status, or aborts, or is terminated by a signal, or if the |
| 9 | * framework running the program considers the run an error (this happens |
| 10 | * with Valgrind for a memory leak). The non-success of the meta-test |
| 11 | * program means that the test failure has been caught correctly. |
| 12 | * |
| 13 | * Some failures are purely functional: the logic of the code causes the |
| 14 | * test result to be set to FAIL. Other failures come from extra |
| 15 | * instrumentation which is not present in a normal build; for example, |
| 16 | * Asan or Valgrind to detect memory leaks. This is reflected by the |
| 17 | * "platform" associated with each meta-test. |
| 18 | * |
| 19 | * Use the companion script `tests/scripts/run-metatests.sh` to run all |
| 20 | * the meta-tests for a given platform and validate that they trigger a |
| 21 | * detected failure as expected. |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * Copyright The Mbed TLS Contributors |
| 26 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 27 | */ |
| 28 | |
| 29 | #define MBEDTLS_ALLOW_PRIVATE_ACCESS |
| 30 | |
| 31 | #include <mbedtls/platform.h> |
Gilles Peskine | 69e8db0 | 2023-11-02 19:52:32 +0100 | [diff] [blame] | 32 | #include <mbedtls/platform_util.h> |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 33 | #include "test/helpers.h" |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 34 | #include "test/macros.h" |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 35 | |
| 36 | #include <stdio.h> |
| 37 | #include <string.h> |
| 38 | |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 39 | #if defined(MBEDTLS_THREADING_C) |
| 40 | #include <mbedtls/threading.h> |
| 41 | #endif |
| 42 | |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 43 | |
Gilles Peskine | 69e8db0 | 2023-11-02 19:52:32 +0100 | [diff] [blame] | 44 | /* This is an external variable, so the compiler doesn't know that we're never |
| 45 | * changing its value. |
Gilles Peskine | 69e8db0 | 2023-11-02 19:52:32 +0100 | [diff] [blame] | 46 | */ |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 47 | volatile int false_but_the_compiler_does_not_know = 0; |
| 48 | |
| 49 | /* Set n bytes at the address p to all-bits-zero, in such a way that |
| 50 | * the compiler should not know that p is all-bits-zero. */ |
Gilles Peskine | da6e7a2 | 2023-11-10 10:09:27 +0100 | [diff] [blame] | 51 | static void set_to_zero_but_the_compiler_does_not_know(volatile void *p, size_t n) |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 52 | { |
Gilles Peskine | da6e7a2 | 2023-11-10 10:09:27 +0100 | [diff] [blame] | 53 | memset((void *) p, false_but_the_compiler_does_not_know, n); |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 54 | } |
Gilles Peskine | 69e8db0 | 2023-11-02 19:52:32 +0100 | [diff] [blame] | 55 | |
| 56 | |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 57 | /****************************************************************/ |
Gilles Peskine | f309fbf | 2023-11-02 18:49:52 +0100 | [diff] [blame] | 58 | /* Test framework features */ |
| 59 | /****************************************************************/ |
| 60 | |
| 61 | void meta_test_fail(const char *name) |
| 62 | { |
| 63 | (void) name; |
| 64 | mbedtls_test_fail("Forced test failure", __LINE__, __FILE__); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /****************************************************************/ |
Gilles Peskine | 80ba832 | 2023-11-02 19:23:26 +0100 | [diff] [blame] | 69 | /* Platform features */ |
| 70 | /****************************************************************/ |
| 71 | |
| 72 | void null_pointer_dereference(const char *name) |
| 73 | { |
| 74 | (void) name; |
Gilles Peskine | da6e7a2 | 2023-11-10 10:09:27 +0100 | [diff] [blame] | 75 | volatile char *volatile p; |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 76 | set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p)); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 77 | /* Undefined behavior (read from null data pointer) */ |
Gilles Peskine | 69e8db0 | 2023-11-02 19:52:32 +0100 | [diff] [blame] | 78 | mbedtls_printf("%p -> %u\n", p, (unsigned) *p); |
Gilles Peskine | 80ba832 | 2023-11-02 19:23:26 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | void null_pointer_call(const char *name) |
| 82 | { |
| 83 | (void) name; |
Gilles Peskine | da6e7a2 | 2023-11-10 10:09:27 +0100 | [diff] [blame] | 84 | unsigned(*volatile p)(void); |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 85 | set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p)); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 86 | /* Undefined behavior (execute null function pointer) */ |
Gilles Peskine | f0d5cf9 | 2023-11-03 10:58:57 +0100 | [diff] [blame] | 87 | /* The pointer representation may be truncated, but we don't care: |
| 88 | * the only point of printing it is to have some use of the pointer |
| 89 | * to dissuade the compiler from optimizing it away. */ |
| 90 | mbedtls_printf("%lx() -> %u\n", (unsigned long) (uintptr_t) p, p()); |
Gilles Peskine | 80ba832 | 2023-11-02 19:23:26 +0100 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | |
| 94 | /****************************************************************/ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 95 | /* Memory */ |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 96 | /****************************************************************/ |
| 97 | |
| 98 | void read_after_free(const char *name) |
| 99 | { |
| 100 | (void) name; |
| 101 | volatile char *p = mbedtls_calloc(1, 1); |
| 102 | *p = 'a'; |
| 103 | mbedtls_free((void *) p); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 104 | /* Undefined behavior (read after free) */ |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 105 | mbedtls_printf("%u\n", (unsigned) *p); |
| 106 | } |
| 107 | |
| 108 | void double_free(const char *name) |
| 109 | { |
| 110 | (void) name; |
| 111 | volatile char *p = mbedtls_calloc(1, 1); |
| 112 | *p = 'a'; |
| 113 | mbedtls_free((void *) p); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 114 | /* Undefined behavior (double free) */ |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 115 | mbedtls_free((void *) p); |
| 116 | } |
| 117 | |
| 118 | void read_uninitialized_stack(const char *name) |
| 119 | { |
| 120 | (void) name; |
Gilles Peskine | ccb1215 | 2023-11-10 11:35:36 +0100 | [diff] [blame] | 121 | char buf[1]; |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 122 | if (false_but_the_compiler_does_not_know) { |
| 123 | buf[0] = '!'; |
| 124 | } |
Gilles Peskine | ccb1215 | 2023-11-10 11:35:36 +0100 | [diff] [blame] | 125 | char *volatile p = buf; |
| 126 | if (*p != 0) { |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 127 | /* Unspecified result (read from uninitialized memory) */ |
Gilles Peskine | ccb1215 | 2023-11-10 11:35:36 +0100 | [diff] [blame] | 128 | mbedtls_printf("%u\n", (unsigned) *p); |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
| 132 | void memory_leak(const char *name) |
| 133 | { |
| 134 | (void) name; |
| 135 | volatile char *p = mbedtls_calloc(1, 1); |
Gilles Peskine | d2fa698 | 2023-11-09 21:46:24 +0100 | [diff] [blame] | 136 | mbedtls_printf("%u\n", (unsigned) *p); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 137 | /* Leak of a heap object */ |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | |
| 141 | /****************************************************************/ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 142 | /* Threading */ |
| 143 | /****************************************************************/ |
| 144 | |
| 145 | void mutex_lock_not_initialized(const char *name) |
| 146 | { |
| 147 | (void) name; |
Gilles Peskine | ad2a17e | 2023-11-16 15:09:48 +0100 | [diff] [blame] | 148 | #if defined(MBEDTLS_THREADING_C) |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 149 | mbedtls_threading_mutex_t mutex; |
| 150 | memset(&mutex, 0, sizeof(mutex)); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 151 | /* This mutex usage error is detected by our test framework's mutex usage |
| 152 | * verification framework. See tests/src/threading_helpers.c. Other |
| 153 | * threading implementations (e.g. pthread without our instrumentation) |
| 154 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 155 | TEST_ASSERT(mbedtls_mutex_lock(&mutex) == 0); |
| 156 | exit: |
| 157 | ; |
| 158 | #endif |
| 159 | } |
| 160 | |
| 161 | void mutex_unlock_not_initialized(const char *name) |
| 162 | { |
| 163 | (void) name; |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 164 | #if defined(MBEDTLS_THREADING_C) |
| 165 | mbedtls_threading_mutex_t mutex; |
| 166 | memset(&mutex, 0, sizeof(mutex)); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 167 | /* This mutex usage error is detected by our test framework's mutex usage |
| 168 | * verification framework. See tests/src/threading_helpers.c. Other |
| 169 | * threading implementations (e.g. pthread without our instrumentation) |
| 170 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 171 | TEST_ASSERT(mbedtls_mutex_unlock(&mutex) == 0); |
| 172 | exit: |
| 173 | ; |
| 174 | #endif |
| 175 | } |
| 176 | |
| 177 | void mutex_free_not_initialized(const char *name) |
| 178 | { |
| 179 | (void) name; |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 180 | #if defined(MBEDTLS_THREADING_C) |
| 181 | mbedtls_threading_mutex_t mutex; |
| 182 | memset(&mutex, 0, sizeof(mutex)); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 183 | /* This mutex usage error is detected by our test framework's mutex usage |
| 184 | * verification framework. See tests/src/threading_helpers.c. Other |
| 185 | * threading implementations (e.g. pthread without our instrumentation) |
| 186 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 187 | mbedtls_mutex_free(&mutex); |
| 188 | #endif |
| 189 | } |
| 190 | |
| 191 | void mutex_double_init(const char *name) |
| 192 | { |
| 193 | (void) name; |
| 194 | #if defined(MBEDTLS_THREADING_C) |
| 195 | mbedtls_threading_mutex_t mutex; |
| 196 | mbedtls_mutex_init(&mutex); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 197 | /* This mutex usage error is detected by our test framework's mutex usage |
| 198 | * verification framework. See tests/src/threading_helpers.c. Other |
| 199 | * threading implementations (e.g. pthread without our instrumentation) |
| 200 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 201 | mbedtls_mutex_init(&mutex); |
| 202 | mbedtls_mutex_free(&mutex); |
| 203 | #endif |
| 204 | } |
| 205 | |
| 206 | void mutex_double_free(const char *name) |
| 207 | { |
| 208 | (void) name; |
| 209 | #if defined(MBEDTLS_THREADING_C) |
| 210 | mbedtls_threading_mutex_t mutex; |
| 211 | mbedtls_mutex_init(&mutex); |
| 212 | mbedtls_mutex_free(&mutex); |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 213 | /* This mutex usage error is detected by our test framework's mutex usage |
| 214 | * verification framework. See tests/src/threading_helpers.c. Other |
| 215 | * threading implementations (e.g. pthread without our instrumentation) |
| 216 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 217 | mbedtls_mutex_free(&mutex); |
| 218 | #endif |
| 219 | } |
| 220 | |
| 221 | void mutex_leak(const char *name) |
| 222 | { |
| 223 | (void) name; |
Gilles Peskine | ad2a17e | 2023-11-16 15:09:48 +0100 | [diff] [blame] | 224 | #if defined(MBEDTLS_THREADING_C) |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 225 | mbedtls_threading_mutex_t mutex; |
| 226 | mbedtls_mutex_init(&mutex); |
| 227 | #endif |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 228 | /* This mutex usage error is detected by our test framework's mutex usage |
| 229 | * verification framework. See tests/src/threading_helpers.c. Other |
| 230 | * threading implementations (e.g. pthread without our instrumentation) |
| 231 | * might consider this normal usage. */ |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | |
| 235 | /****************************************************************/ |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 236 | /* Command line entry point */ |
| 237 | /****************************************************************/ |
| 238 | |
| 239 | typedef struct { |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 240 | /** Command line argument that will trigger that metatest. |
| 241 | * |
| 242 | * Conventionally matches "[a-z0-9_]+". */ |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 243 | const char *name; |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 244 | |
| 245 | /** Platform under which that metatest is valid. |
| 246 | * |
| 247 | * - "any": should work anywhere. |
| 248 | * - "asan": triggers ASan (Address Sanitizer). |
| 249 | * - "msan": triggers MSan (Memory Sanitizer). |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 250 | * - "pthread": requires MBEDTLS_THREADING_PTHREAD and MBEDTLS_TEST_HOOKS, |
| 251 | * which enables MBEDTLS_TEST_MUTEX_USAGE internally in the test |
| 252 | * framework (see tests/src/threading_helpers.c). |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 253 | */ |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 254 | const char *platform; |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 255 | |
| 256 | /** Function that performs the metatest. |
| 257 | * |
| 258 | * The function receives the name as an argument. This allows using the |
| 259 | * same function to perform multiple variants of a test based on the name. |
| 260 | * |
| 261 | * When executed on a conforming platform, the function is expected to |
| 262 | * either cause a test failure (mbedtls_test_fail()), or cause the |
| 263 | * program to abort in some way (e.g. by causing a segfault or by |
| 264 | * triggering a sanitizer). |
| 265 | * |
| 266 | * When executed on a non-conforming platform, the function may return |
| 267 | * normally or may have unpredictable behavior. |
| 268 | */ |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 269 | void (*entry_point)(const char *name); |
| 270 | } metatest_t; |
| 271 | |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 272 | /* The list of availble meta-tests. Remember to register new functions here! |
| 273 | * |
| 274 | * Note that we always compile all the functions, so that `metatest --list` |
| 275 | * will always list all the available meta-tests. |
Gilles Peskine | 2f40cc0 | 2023-11-16 15:11:44 +0100 | [diff] [blame^] | 276 | * |
| 277 | * See the documentation of metatest_t::platform for the meaning of |
| 278 | * platform values. |
Gilles Peskine | cce0012 | 2023-11-10 15:36:15 +0100 | [diff] [blame] | 279 | */ |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 280 | metatest_t metatests[] = { |
Gilles Peskine | f309fbf | 2023-11-02 18:49:52 +0100 | [diff] [blame] | 281 | { "test_fail", "any", meta_test_fail }, |
Gilles Peskine | 80ba832 | 2023-11-02 19:23:26 +0100 | [diff] [blame] | 282 | { "null_dereference", "any", null_pointer_dereference }, |
| 283 | { "null_call", "any", null_pointer_call }, |
Gilles Peskine | b0f0a64 | 2023-11-02 19:42:13 +0100 | [diff] [blame] | 284 | { "read_after_free", "asan", read_after_free }, |
| 285 | { "double_free", "asan", double_free }, |
| 286 | { "read_uninitialized_stack", "msan", read_uninitialized_stack }, |
| 287 | { "memory_leak", "asan", memory_leak }, |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 288 | { "mutex_lock_not_initialized", "pthread", mutex_lock_not_initialized }, |
| 289 | { "mutex_unlock_not_initialized", "pthread", mutex_unlock_not_initialized }, |
| 290 | { "mutex_free_not_initialized", "pthread", mutex_free_not_initialized }, |
| 291 | { "mutex_double_init", "pthread", mutex_double_init }, |
| 292 | { "mutex_double_free", "pthread", mutex_double_free }, |
| 293 | { "mutex_leak", "pthread", mutex_leak }, |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 294 | { NULL, NULL, NULL } |
| 295 | }; |
| 296 | |
| 297 | static void help(FILE *out, const char *argv0) |
| 298 | { |
| 299 | mbedtls_fprintf(out, "Usage: %s list|TEST\n", argv0); |
| 300 | mbedtls_fprintf(out, "Run a meta-test that should cause a test failure.\n"); |
| 301 | mbedtls_fprintf(out, "With 'list', list the available tests and their platform requirement.\n"); |
| 302 | } |
| 303 | |
| 304 | int main(int argc, char *argv[]) |
| 305 | { |
| 306 | const char *argv0 = argc > 0 ? argv[0] : "metatest"; |
| 307 | if (argc != 2) { |
| 308 | help(stderr, argv0); |
| 309 | mbedtls_exit(MBEDTLS_EXIT_FAILURE); |
| 310 | } |
| 311 | |
| 312 | /* Support "-help", "--help", "--list", etc. */ |
| 313 | const char *command = argv[1]; |
| 314 | while (*command == '-') { |
| 315 | ++command; |
| 316 | } |
| 317 | |
| 318 | if (strcmp(argv[1], "help") == 0) { |
| 319 | help(stdout, argv0); |
| 320 | mbedtls_exit(MBEDTLS_EXIT_SUCCESS); |
| 321 | } |
| 322 | if (strcmp(argv[1], "list") == 0) { |
| 323 | for (const metatest_t *p = metatests; p->name != NULL; p++) { |
| 324 | mbedtls_printf("%s %s\n", p->name, p->platform); |
| 325 | } |
| 326 | mbedtls_exit(MBEDTLS_EXIT_SUCCESS); |
| 327 | } |
| 328 | |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 329 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
| 330 | mbedtls_test_mutex_usage_init(); |
| 331 | #endif |
| 332 | |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 333 | for (const metatest_t *p = metatests; p->name != NULL; p++) { |
| 334 | if (strcmp(argv[1], p->name) == 0) { |
| 335 | mbedtls_printf("Running metatest %s...\n", argv[1]); |
| 336 | p->entry_point(argv[1]); |
Gilles Peskine | 102aea2 | 2023-11-03 18:05:38 +0100 | [diff] [blame] | 337 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
| 338 | mbedtls_test_mutex_usage_check(); |
| 339 | #endif |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 340 | mbedtls_printf("Running metatest %s... done, result=%d\n", |
| 341 | argv[1], (int) mbedtls_test_info.result); |
| 342 | mbedtls_exit(mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SUCCESS ? |
| 343 | MBEDTLS_EXIT_SUCCESS : |
| 344 | MBEDTLS_EXIT_FAILURE); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | mbedtls_fprintf(stderr, "%s: FATAL: No such metatest: %s\n", |
| 349 | argv0, command); |
| 350 | mbedtls_exit(MBEDTLS_EXIT_FAILURE); |
| 351 | } |