1#line 2 "suites/host_test.function" 2 3/** 4 * \brief Verifies that string is in string parameter format i.e. "<str>" 5 * It also strips enclosing '"' from the input string. 6 * 7 * \param str String parameter. 8 * 9 * \return 0 if success else 1 10 */ 11int verify_string(char **str) 12{ 13 if ((*str)[0] != '"' || 14 (*str)[strlen(*str) - 1] != '"') { 15 mbedtls_fprintf(stderr, 16 "Expected string (with \"\") for parameter and got: %s\n", *str); 17 return -1; 18 } 19 20 (*str)++; 21 (*str)[strlen(*str) - 1] = '\0'; 22 23 return 0; 24} 25 26/** 27 * \brief Verifies that string is an integer. Also gives the converted 28 * integer value. 29 * 30 * \param str Input string. 31 * \param value Pointer to int for output value. 32 * 33 * \return 0 if success else 1 34 */ 35int verify_int(char *str, int32_t *value) 36{ 37 size_t i; 38 int minus = 0; 39 int digits = 1; 40 int hex = 0; 41 42 for (i = 0; i < strlen(str); i++) { 43 if (i == 0 && str[i] == '-') { 44 minus = 1; 45 continue; 46 } 47 48 if (((minus && i == 2) || (!minus && i == 1)) && 49 str[i - 1] == '0' && (str[i] == 'x' || str[i] == 'X')) { 50 hex = 1; 51 continue; 52 } 53 54 if (!((str[i] >= '0' && str[i] <= '9') || 55 (hex && ((str[i] >= 'a' && str[i] <= 'f') || 56 (str[i] >= 'A' && str[i] <= 'F'))))) { 57 digits = 0; 58 break; 59 } 60 } 61 62 if (digits) { 63 if (hex) { 64 *value = strtol(str, NULL, 16); 65 } else { 66 *value = strtol(str, NULL, 10); 67 } 68 69 return 0; 70 } 71 72 mbedtls_fprintf(stderr, 73 "Expected integer for parameter and got: %s\n", str); 74 return KEY_VALUE_MAPPING_NOT_FOUND; 75} 76 77 78/** 79 * \brief Usage string. 80 * 81 */ 82#define USAGE \ 83 "Usage: %s [OPTIONS] files...\n\n" \ 84 " Command line arguments:\n" \ 85 " files... One or more test data files. If no file is\n" \ 86 " specified the following default test case\n" \ 87 " file is used:\n" \ 88 " %s\n\n" \ 89 " Options:\n" \ 90 " -v | --verbose Display full information about each test\n" \ 91 " -h | --help Display this information\n\n", \ 92 argv[0], \ 93 "TESTCASE_FILENAME" 94 95 96/** 97 * \brief Read a line from the passed file pointer. 98 * 99 * \param f FILE pointer 100 * \param buf Pointer to memory to hold read line. 101 * \param len Length of the buf. 102 * 103 * \return 0 if success else -1 104 */ 105int get_line(FILE *f, char *buf, size_t len) 106{ 107 char *ret; 108 int i = 0, str_len = 0, has_string = 0; 109 110 /* Read until we get a valid line */ 111 do { 112 ret = fgets(buf, len, f); 113 if (ret == NULL) { 114 return -1; 115 } 116 117 str_len = strlen(buf); 118 119 /* Skip empty line and comment */ 120 if (str_len == 0 || buf[0] == '#') { 121 continue; 122 } 123 has_string = 0; 124 for (i = 0; i < str_len; i++) { 125 char c = buf[i]; 126 if (c != ' ' && c != '\t' && c != '\n' && 127 c != '\v' && c != '\f' && c != '\r') { 128 has_string = 1; 129 break; 130 } 131 } 132 } while (!has_string); 133 134 /* Strip new line and carriage return */ 135 ret = buf + strlen(buf); 136 if (ret-- > buf && *ret == '\n') { 137 *ret = '\0'; 138 } 139 if (ret-- > buf && *ret == '\r') { 140 *ret = '\0'; 141 } 142 143 return 0; 144} 145 146/** 147 * \brief Splits string delimited by ':'. Ignores '\:'. 148 * 149 * \param buf Input string 150 * \param len Input string length 151 * \param params Out params found 152 * \param params_len Out params array len 153 * 154 * \return Count of strings found. 155 */ 156static int parse_arguments(char *buf, size_t len, char **params, 157 size_t params_len) 158{ 159 size_t cnt = 0, i; 160 char *cur = buf; 161 char *p = buf, *q; 162 163 params[cnt++] = cur; 164 165 while (*p != '\0' && p < (buf + len)) { 166 if (*p == '\\') { 167 p++; 168 p++; 169 continue; 170 } 171 if (*p == ':') { 172 if (p + 1 < buf + len) { 173 cur = p + 1; 174 TEST_HELPER_ASSERT(cnt < params_len); 175 params[cnt++] = cur; 176 } 177 *p = '\0'; 178 } 179 180 p++; 181 } 182 183 /* Replace newlines, question marks and colons in strings */ 184 for (i = 0; i < cnt; i++) { 185 p = params[i]; 186 q = params[i]; 187 188 while (*p != '\0') { 189 if (*p == '\\' && *(p + 1) == 'n') { 190 p += 2; 191 *(q++) = '\n'; 192 } else if (*p == '\\' && *(p + 1) == ':') { 193 p += 2; 194 *(q++) = ':'; 195 } else if (*p == '\\' && *(p + 1) == '?') { 196 p += 2; 197 *(q++) = '?'; 198 } else { 199 *(q++) = *(p++); 200 } 201 } 202 *q = '\0'; 203 } 204 205 return cnt; 206} 207 208/** 209 * \brief Converts parameters into test function consumable parameters. 210 * Example: Input: {"int", "0", "char*", "Hello", 211 * "hex", "abef", "exp", "1"} 212 * Output: { 213 * 0, // Verified int 214 * "Hello", // Verified string 215 * 2, { 0xab, 0xef },// Converted len,hex pair 216 * 9600 // Evaluated expression 217 * } 218 * 219 * 220 * \param cnt Parameter array count. 221 * \param params Out array of found parameters. 222 * \param int_params_store Memory for storing processed integer parameters. 223 * 224 * \return 0 for success else 1 225 */ 226static int convert_params(size_t cnt, char **params, int32_t *int_params_store) 227{ 228 char **cur = params; 229 char **out = params; 230 int ret = DISPATCH_TEST_SUCCESS; 231 232 while (cur < params + cnt) { 233 char *type = *cur++; 234 char *val = *cur++; 235 236 if (strcmp(type, "char*") == 0) { 237 if (verify_string(&val) == 0) { 238 *out++ = val; 239 } else { 240 ret = (DISPATCH_INVALID_TEST_DATA); 241 break; 242 } 243 } else if (strcmp(type, "int") == 0) { 244 if (verify_int(val, int_params_store) == 0) { 245 *out++ = (char *) int_params_store++; 246 } else { 247 ret = (DISPATCH_INVALID_TEST_DATA); 248 break; 249 } 250 } else if (strcmp(type, "hex") == 0) { 251 if (verify_string(&val) == 0) { 252 size_t len; 253 254 TEST_HELPER_ASSERT( 255 mbedtls_test_unhexify((unsigned char *) val, strlen(val), 256 val, &len) == 0); 257 258 *int_params_store = len; 259 *out++ = val; 260 *out++ = (char *) (int_params_store++); 261 } else { 262 ret = (DISPATCH_INVALID_TEST_DATA); 263 break; 264 } 265 } else if (strcmp(type, "exp") == 0) { 266 int exp_id = strtol(val, NULL, 10); 267 if (get_expression(exp_id, int_params_store) == 0) { 268 *out++ = (char *) int_params_store++; 269 } else { 270 ret = (DISPATCH_INVALID_TEST_DATA); 271 break; 272 } 273 } else { 274 ret = (DISPATCH_INVALID_TEST_DATA); 275 break; 276 } 277 } 278 return ret; 279} 280 281/** 282 * \brief Tests snprintf implementation with test input. 283 * 284 * \note 285 * At high optimization levels (e.g. gcc -O3), this function may be 286 * inlined in run_test_snprintf. This can trigger a spurious warning about 287 * potential misuse of snprintf from gcc -Wformat-truncation (observed with 288 * gcc 7.2). This warning makes tests in run_test_snprintf redundant on gcc 289 * only. They are still valid for other compilers. Avoid this warning by 290 * forbidding inlining of this function by gcc. 291 * 292 * \param n Buffer test length. 293 * \param ref_buf Expected buffer. 294 * \param ref_ret Expected snprintf return value. 295 * 296 * \return 0 for success else 1 297 */ 298#if defined(__GNUC__) 299__attribute__((__noinline__)) 300#endif 301static int test_snprintf(size_t n, const char *ref_buf, int ref_ret) 302{ 303 int ret; 304 char buf[10] = "xxxxxxxxx"; 305 const char ref[10] = "xxxxxxxxx"; 306 307 if (n >= sizeof(buf)) { 308 return -1; 309 } 310 ret = mbedtls_snprintf(buf, n, "%s", "123"); 311 if (ret < 0 || (size_t) ret >= n) { 312 ret = -1; 313 } 314 315 if (strncmp(ref_buf, buf, sizeof(buf)) != 0 || 316 ref_ret != ret || 317 memcmp(buf + n, ref + n, sizeof(buf) - n) != 0) { 318 return 1; 319 } 320 321 return 0; 322} 323 324/** 325 * \brief Tests snprintf implementation. 326 * 327 * \return 0 for success else 1 328 */ 329static int run_test_snprintf(void) 330{ 331 return test_snprintf(0, "xxxxxxxxx", -1) != 0 || 332 test_snprintf(1, "", -1) != 0 || 333 test_snprintf(2, "1", -1) != 0 || 334 test_snprintf(3, "12", -1) != 0 || 335 test_snprintf(4, "123", 3) != 0 || 336 test_snprintf(5, "123", 3) != 0; 337} 338 339/** \brief Write the description of the test case to the outcome CSV file. 340 * 341 * \param outcome_file The file to write to. 342 * If this is \c NULL, this function does nothing. 343 * \param argv0 The test suite name. 344 * \param test_case The test case description. 345 */ 346static void write_outcome_entry(FILE *outcome_file, 347 const char *argv0, 348 const char *test_case) 349{ 350 /* The non-varying fields are initialized on first use. */ 351 static const char *platform = NULL; 352 static const char *configuration = NULL; 353 static const char *test_suite = NULL; 354 355 if (outcome_file == NULL) { 356 return; 357 } 358 359 if (platform == NULL) { 360 platform = getenv("MBEDTLS_TEST_PLATFORM"); 361 if (platform == NULL) { 362 platform = "unknown"; 363 } 364 } 365 if (configuration == NULL) { 366 configuration = getenv("MBEDTLS_TEST_CONFIGURATION"); 367 if (configuration == NULL) { 368 configuration = "unknown"; 369 } 370 } 371 if (test_suite == NULL) { 372 test_suite = strrchr(argv0, '/'); 373 if (test_suite != NULL) { 374 test_suite += 1; // skip the '/' 375 } else { 376 test_suite = argv0; 377 } 378 } 379 380 /* Write the beginning of the outcome line. 381 * Ignore errors: writing the outcome file is on a best-effort basis. */ 382 mbedtls_fprintf(outcome_file, "%s;%s;%s;%s;", 383 platform, configuration, test_suite, test_case); 384} 385 386/** \brief Write the result of the test case to the outcome CSV file. 387 * 388 * \param outcome_file The file to write to. 389 * If this is \c NULL, this function does nothing. 390 * \param unmet_dep_count The number of unmet dependencies. 391 * \param unmet_dependencies The array of unmet dependencies. 392 * \param missing_unmet_dependencies Non-zero if there was a problem tracking 393 * all unmet dependencies, 0 otherwise. 394 * \param ret The test dispatch status (DISPATCH_xxx). 395 * \param info A pointer to the test info structure. 396 */ 397static void write_outcome_result(FILE *outcome_file, 398 size_t unmet_dep_count, 399 int unmet_dependencies[], 400 int missing_unmet_dependencies, 401 int ret, 402 const mbedtls_test_info_t *info) 403{ 404 if (outcome_file == NULL) { 405 return; 406 } 407 408 /* Write the end of the outcome line. 409 * Ignore errors: writing the outcome file is on a best-effort basis. */ 410 switch (ret) { 411 case DISPATCH_TEST_SUCCESS: 412 if (unmet_dep_count > 0) { 413 size_t i; 414 mbedtls_fprintf(outcome_file, "SKIP"); 415 for (i = 0; i < unmet_dep_count; i++) { 416 mbedtls_fprintf(outcome_file, "%c%d", 417 i == 0 ? ';' : ':', 418 unmet_dependencies[i]); 419 } 420 if (missing_unmet_dependencies) { 421 mbedtls_fprintf(outcome_file, ":..."); 422 } 423 break; 424 } 425 switch (info->result) { 426 case MBEDTLS_TEST_RESULT_SUCCESS: 427 mbedtls_fprintf(outcome_file, "PASS;"); 428 break; 429 case MBEDTLS_TEST_RESULT_SKIPPED: 430 mbedtls_fprintf(outcome_file, "SKIP;Runtime skip"); 431 break; 432 default: 433 mbedtls_fprintf(outcome_file, "FAIL;%s:%d:%s", 434 info->filename, info->line_no, 435 info->test); 436 break; 437 } 438 break; 439 case DISPATCH_TEST_FN_NOT_FOUND: 440 mbedtls_fprintf(outcome_file, "FAIL;Test function not found"); 441 break; 442 case DISPATCH_INVALID_TEST_DATA: 443 mbedtls_fprintf(outcome_file, "FAIL;Invalid test data"); 444 break; 445 case DISPATCH_UNSUPPORTED_SUITE: 446 mbedtls_fprintf(outcome_file, "SKIP;Unsupported suite"); 447 break; 448 default: 449 mbedtls_fprintf(outcome_file, "FAIL;Unknown cause"); 450 break; 451 } 452 mbedtls_fprintf(outcome_file, "\n"); 453 fflush(outcome_file); 454} 455 456/** 457 * \brief Desktop implementation of execute_tests(). 458 * Parses command line and executes tests from 459 * supplied or default data file. 460 * 461 * \param argc Command line argument count. 462 * \param argv Argument array. 463 * 464 * \return Program exit status. 465 */ 466int execute_tests(int argc, const char **argv) 467{ 468 /* Local Configurations and options */ 469 const char *default_filename = "DATA_FILE"; 470 const char *test_filename = NULL; 471 const char **test_files = NULL; 472 size_t testfile_count = 0; 473 int option_verbose = 0; 474 size_t function_id = 0; 475 476 /* Other Local variables */ 477 int arg_index = 1; 478 const char *next_arg; 479 size_t testfile_index, i, cnt; 480 int ret; 481 unsigned total_errors = 0, total_tests = 0, total_skipped = 0; 482 FILE *file; 483 char buf[5000]; 484 char *params[50]; 485 /* Store for processed integer params. */ 486 int32_t int_params[50]; 487 void *pointer; 488#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 489 int stdout_fd = -1; 490#endif /* __unix__ || __APPLE__ __MACH__ */ 491 const char *outcome_file_name = getenv("MBEDTLS_TEST_OUTCOME_FILE"); 492 FILE *outcome_file = NULL; 493 494#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ 495 !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) 496 unsigned char alloc_buf[1000000]; 497 mbedtls_memory_buffer_alloc_init(alloc_buf, sizeof(alloc_buf)); 498#endif 499 500#if defined(MBEDTLS_TEST_MUTEX_USAGE) 501 mbedtls_test_mutex_usage_init(); 502#endif 503 504 /* 505 * The C standard doesn't guarantee that all-bits-0 is the representation 506 * of a NULL pointer. We do however use that in our code for initializing 507 * structures, which should work on every modern platform. Let's be sure. 508 */ 509 memset(&pointer, 0, sizeof(void *)); 510 if (pointer != NULL) { 511 mbedtls_fprintf(stderr, "all-bits-zero is not a NULL pointer\n"); 512 return 1; 513 } 514 515 /* 516 * Make sure we have a snprintf that correctly zero-terminates 517 */ 518 if (run_test_snprintf() != 0) { 519 mbedtls_fprintf(stderr, "the snprintf implementation is broken\n"); 520 return 1; 521 } 522 523 if (outcome_file_name != NULL && *outcome_file_name != '\0') { 524 outcome_file = fopen(outcome_file_name, "a"); 525 if (outcome_file == NULL) { 526 mbedtls_fprintf(stderr, "Unable to open outcome file. Continuing anyway.\n"); 527 } 528 } 529 530 while (arg_index < argc) { 531 next_arg = argv[arg_index]; 532 533 if (strcmp(next_arg, "--verbose") == 0 || 534 strcmp(next_arg, "-v") == 0) { 535 option_verbose = 1; 536 } else if (strcmp(next_arg, "--help") == 0 || 537 strcmp(next_arg, "-h") == 0) { 538 mbedtls_fprintf(stdout, USAGE); 539 mbedtls_exit(EXIT_SUCCESS); 540 } else { 541 /* Not an option, therefore treat all further arguments as the file 542 * list. 543 */ 544 test_files = &argv[arg_index]; 545 testfile_count = argc - arg_index; 546 break; 547 } 548 549 arg_index++; 550 } 551 552 /* If no files were specified, assume a default */ 553 if (test_files == NULL || testfile_count == 0) { 554 test_files = &default_filename; 555 testfile_count = 1; 556 } 557 558 /* Initialize the struct that holds information about the last test */ 559 mbedtls_test_info_reset(); 560 561 /* Now begin to execute the tests in the testfiles */ 562 for (testfile_index = 0; 563 testfile_index < testfile_count; 564 testfile_index++) { 565 size_t unmet_dep_count = 0; 566 int unmet_dependencies[20]; 567 int missing_unmet_dependencies = 0; 568 569 test_filename = test_files[testfile_index]; 570 571 file = fopen(test_filename, "r"); 572 if (file == NULL) { 573 mbedtls_fprintf(stderr, "Failed to open test file: %s\n", 574 test_filename); 575 if (outcome_file != NULL) { 576 fclose(outcome_file); 577 } 578 return 1; 579 } 580 581 while (!feof(file)) { 582 if (unmet_dep_count > 0) { 583 mbedtls_fprintf(stderr, 584 "FATAL: Dep count larger than zero at start of loop\n"); 585 mbedtls_exit(MBEDTLS_EXIT_FAILURE); 586 } 587 unmet_dep_count = 0; 588 missing_unmet_dependencies = 0; 589 590 if ((ret = get_line(file, buf, sizeof(buf))) != 0) { 591 break; 592 } 593 mbedtls_fprintf(stdout, "%s%.66s", 594 mbedtls_test_info.result == MBEDTLS_TEST_RESULT_FAILED ? 595 "\n" : "", buf); 596 mbedtls_fprintf(stdout, " "); 597 for (i = strlen(buf) + 1; i < 67; i++) { 598 mbedtls_fprintf(stdout, "."); 599 } 600 mbedtls_fprintf(stdout, " "); 601 fflush(stdout); 602 write_outcome_entry(outcome_file, argv[0], buf); 603 604 total_tests++; 605 606 if ((ret = get_line(file, buf, sizeof(buf))) != 0) { 607 break; 608 } 609 cnt = parse_arguments(buf, strlen(buf), params, 610 sizeof(params) / sizeof(params[0])); 611 612 if (strcmp(params[0], "depends_on") == 0) { 613 for (i = 1; i < cnt; i++) { 614 int dep_id = strtol(params[i], NULL, 10); 615 if (dep_check(dep_id) != DEPENDENCY_SUPPORTED) { 616 if (unmet_dep_count < 617 ARRAY_LENGTH(unmet_dependencies)) { 618 unmet_dependencies[unmet_dep_count] = dep_id; 619 unmet_dep_count++; 620 } else { 621 missing_unmet_dependencies = 1; 622 } 623 } 624 } 625 626 if ((ret = get_line(file, buf, sizeof(buf))) != 0) { 627 break; 628 } 629 cnt = parse_arguments(buf, strlen(buf), params, 630 sizeof(params) / sizeof(params[0])); 631 } 632 633 // If there are no unmet dependencies execute the test 634 if (unmet_dep_count == 0) { 635 mbedtls_test_info_reset(); 636 637#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 638 /* Suppress all output from the library unless we're verbose 639 * mode 640 */ 641 if (!option_verbose) { 642 stdout_fd = redirect_output(stdout, "/dev/null"); 643 if (stdout_fd == -1) { 644 /* Redirection has failed with no stdout so exit */ 645 exit(1); 646 } 647 } 648#endif /* __unix__ || __APPLE__ __MACH__ */ 649 650 function_id = strtoul(params[0], NULL, 10); 651 if ((ret = check_test(function_id)) == DISPATCH_TEST_SUCCESS) { 652 ret = convert_params(cnt - 1, params + 1, int_params); 653 if (DISPATCH_TEST_SUCCESS == ret) { 654 ret = dispatch_test(function_id, (void **) (params + 1)); 655 } 656 } 657 658#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) 659 if (!option_verbose && restore_output(stdout, stdout_fd)) { 660 /* Redirection has failed with no stdout so exit */ 661 exit(1); 662 } 663#endif /* __unix__ || __APPLE__ __MACH__ */ 664 665 } 666 667 write_outcome_result(outcome_file, 668 unmet_dep_count, unmet_dependencies, 669 missing_unmet_dependencies, 670 ret, &mbedtls_test_info); 671 if (unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE) { 672 total_skipped++; 673 mbedtls_fprintf(stdout, "----"); 674 675 if (1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE) { 676 mbedtls_fprintf(stdout, "\n Test Suite not enabled"); 677 } 678 679 if (1 == option_verbose && unmet_dep_count > 0) { 680 mbedtls_fprintf(stdout, "\n Unmet dependencies: "); 681 for (i = 0; i < unmet_dep_count; i++) { 682 mbedtls_fprintf(stdout, "%d ", 683 unmet_dependencies[i]); 684 } 685 if (missing_unmet_dependencies) { 686 mbedtls_fprintf(stdout, "..."); 687 } 688 } 689 mbedtls_fprintf(stdout, "\n"); 690 fflush(stdout); 691 692 unmet_dep_count = 0; 693 missing_unmet_dependencies = 0; 694 } else if (ret == DISPATCH_TEST_SUCCESS) { 695 if (mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SUCCESS) { 696 mbedtls_fprintf(stdout, "PASS\n"); 697 } else if (mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SKIPPED) { 698 mbedtls_fprintf(stdout, "----\n"); 699 total_skipped++; 700 } else { 701 total_errors++; 702 mbedtls_fprintf(stdout, "FAILED\n"); 703 mbedtls_fprintf(stdout, " %s\n at ", 704 mbedtls_test_info.test); 705 if (mbedtls_test_info.step != (unsigned long) (-1)) { 706 mbedtls_fprintf(stdout, "step %lu, ", 707 mbedtls_test_info.step); 708 } 709 mbedtls_fprintf(stdout, "line %d, %s", 710 mbedtls_test_info.line_no, 711 mbedtls_test_info.filename); 712 if (mbedtls_test_info.line1[0] != 0) { 713 mbedtls_fprintf(stdout, "\n %s", 714 mbedtls_test_info.line1); 715 } 716 if (mbedtls_test_info.line2[0] != 0) { 717 mbedtls_fprintf(stdout, "\n %s", 718 mbedtls_test_info.line2); 719 } 720 } 721 fflush(stdout); 722 } else if (ret == DISPATCH_INVALID_TEST_DATA) { 723 mbedtls_fprintf(stderr, "FAILED: FATAL PARSE ERROR\n"); 724 fclose(file); 725 mbedtls_exit(2); 726 } else if (ret == DISPATCH_TEST_FN_NOT_FOUND) { 727 mbedtls_fprintf(stderr, "FAILED: FATAL TEST FUNCTION NOT FOUND\n"); 728 fclose(file); 729 mbedtls_exit(2); 730 } else { 731 total_errors++; 732 } 733 } 734 fclose(file); 735 } 736 737 if (outcome_file != NULL) { 738 fclose(outcome_file); 739 } 740 741 mbedtls_fprintf(stdout, 742 "\n----------------------------------------------------------------------------\n\n"); 743 if (total_errors == 0) { 744 mbedtls_fprintf(stdout, "PASSED"); 745 } else { 746 mbedtls_fprintf(stdout, "FAILED"); 747 } 748 749 mbedtls_fprintf(stdout, " (%u / %u tests (%u skipped))\n", 750 total_tests - total_errors, total_tests, total_skipped); 751 752#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ 753 !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) 754#if defined(MBEDTLS_MEMORY_DEBUG) 755 mbedtls_memory_buffer_alloc_status(); 756#endif 757 mbedtls_memory_buffer_alloc_free(); 758#endif 759 760 return total_errors != 0; 761} 762