void setup_test() { char *TAP_levels = getenv("HARNESS_OSSL_LEVEL"); char *test_seed = getenv("OPENSSL_TEST_RAND_ORDER"); test_open_streams(); level = TAP_levels != NULL ? 4 * atoi(TAP_levels) : 0; if (test_seed != NULL) { seed = atoi(test_seed); if (seed <= 0) seed = time(NULL); test_printf_stdout("%*s# RAND SEED %d\n", subtest_level(), "", seed); test_flush_stdout(); srand(seed); } #ifndef OPENSSL_NO_CRYPTO_MDEBUG if (should_report_leaks()) { CRYPTO_set_mem_debug(1); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); } #endif }
/* * Write some data. * * This function implements a simple state machine that detects new lines. * It indents the output and prefixes it with a '#' character. * * It returns the number of input characters that were output in in_size. * More characters than this will likely have been output however any calling * code will be unable to correctly assess the actual number of characters * emitted and would be prone to failure if the actual number were returned. * * The BIO_data field is used as our state. If it is NULL, we've just * seen a new line. If it is not NULL, we're processing characters in a line. */ static int tap_write_ex(BIO *b, const char *buf, size_t size, size_t *in_size) { static char empty[] = ""; BIO *next = BIO_next(b); size_t i; int j; for (i = 0; i < size; i++) { if (BIO_get_data(b) == NULL) { BIO_set_data(b, empty); for (j = 0; j < subtest_level(); j++) if (!write_string(next, " ", 1)) goto err; if (!write_string(next, "# ", 2)) goto err; } if (!write_string(next, buf + i, 1)) goto err; if (buf[i] == '\n') BIO_set_data(b, NULL); } *in_size = i; return 1; err: *in_size = i; return 0; }