Commit a69de3f2 authored by Pauli's avatar Pauli
Browse files

TAP line filter BIO.



This is an implementation of a BIO filter that produce TAP compatible output
for the test framework.  The current test indentation level is honoured.

The test output functions have been modified to not attempt to indent
their output and to not include the leading '#' character.

The filter is applied to bio_err only.  bio_out is left unchanged, although
tests using bio_out have been modified to use bio_err instead.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3732)
parent 906eb3d0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -717,7 +717,7 @@ static int do_print_item(const TEST_PACKAGE *package)
    OPENSSL_assert(package->encode_expectations_elem_size <= DATA_BUF_SIZE);

    (void)RAND_bytes(buf, (int)package->encode_expectations_elem_size);
    ret = ASN1_item_print(bio_out, o, 0, i, NULL);
    ret = ASN1_item_print(bio_err, o, 0, i, NULL);

    return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ IF[{- !$disabled{tests} -}]
  LIBS_NO_INST=libtestutil.a
  SOURCE[libtestutil.a]=testutil/basic_output.c testutil/output_helpers.c \
          testutil/driver.c testutil/tests.c testutil/cb.c testutil/stanza.c \
          testutil/format_output.c \
          testutil/format_output.c testutil/tap_bio.c \
          {- rebase_files("../apps", $target{apps_aux_src}) -} \
          testutil/test_main.c testutil/main.c
  INCLUDE[libtestutil.a]=.. ../include
+5 −7
Original line number Diff line number Diff line
@@ -14,13 +14,7 @@

#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_EC is defined */

#ifdef OPENSSL_NO_EC
int main(int argc, char *argv[])
{
    puts("Elliptic curves are disabled.");
    return 0;
}
#else
#ifndef OPENSSL_NO_EC

# include <openssl/crypto.h>
# include <openssl/bio.h>
@@ -403,9 +397,13 @@ static int test_builtin(void)

void register_tests(void)
{
#ifdef OPENSSL_NO_EC
    TEST_note("Elliptic curves are disabled.");
#else
    /* initialize the prng */
    RAND_seed(rnd_seed, sizeof(rnd_seed));
    ADD_TEST(x9_62_tests);
    ADD_TEST(test_builtin);
#endif
}
#endif
+2 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@

#include "../testutil.h"
#include "output.h"
#include "tu_local.h"

#include <openssl/crypto.h>
#include <openssl/bio.h>
@@ -20,6 +21,7 @@ void test_open_streams(void)
{
    bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
    bio_err = BIO_push(BIO_new(BIO_f_tap()), bio_err);

    OPENSSL_assert(bio_out != NULL);
    OPENSSL_assert(bio_err != NULL);
+1 −1
Original line number Diff line number Diff line
@@ -12,5 +12,5 @@

int openssl_error_cb(const char *str, size_t len, void *u)
{
    return test_printf_stderr("%*s# %s", subtest_level(), "", str);
    return test_printf_stderr("%s", str);
}
Loading