From: Eugene Syromiatnikov Date: Mon, 21 Jul 2025 11:32:24 +0000 (+0200) Subject: Remove HARNESS_OSSL_PREFIX manipulation in the test harness X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70c05fcde53cf480d6ed4c9c851fe0665f7cf76f;p=thirdparty%2Fopenssl.git Remove HARNESS_OSSL_PREFIX manipulation in the test harness The aim of HARNESS_OSSL_PREFIX environment variable is to avoid contaminating TAP producer's output with stanzas that can be interpreted by a TAP producer by prefixing them with comment; this can be achieved by processing the output within the runner instead, as it already does for non-standard prefixes; it also has the added benefit of alleviating the need to reset it for the external tests in order to avoid messing with their output checks. Signed-off-by: Eugene Syromiatnikov Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/28025) --- diff --git a/test/recipes/95-test_external_gost_engine_data/gost_engine.sh b/test/recipes/95-test_external_gost_engine_data/gost_engine.sh index 54ebd5796c3..9d8f8121a32 100755 --- a/test/recipes/95-test_external_gost_engine_data/gost_engine.sh +++ b/test/recipes/95-test_external_gost_engine_data/gost_engine.sh @@ -48,7 +48,6 @@ echo "------------------------------------------------------------------" cmake $SRCTOP/gost-engine -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" -DOPENSSL_ENGINES_DIR="$OPENSSL_ROOT_DIR/engines" make export CTEST_OUTPUT_ON_FAILURE=1 -export HARNESS_OSSL_PREFIX='' export OPENSSL_ENGINES="$PWD/bin" export OPENSSL_APP="$O_EXE/openssl" make test diff --git a/test/recipes/95-test_external_oqsprovider_data/oqsprovider.sh b/test/recipes/95-test_external_oqsprovider_data/oqsprovider.sh index a03c3722fc4..c3227c8b168 100755 --- a/test/recipes/95-test_external_oqsprovider_data/oqsprovider.sh +++ b/test/recipes/95-test_external_oqsprovider_data/oqsprovider.sh @@ -65,7 +65,6 @@ fi echo " CWD: $PWD" liboqs_DIR=$SRCTOP/oqs-provider/.local cmake $SRCTOP/oqs-provider -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" -B _build && cmake --build _build export CTEST_OUTPUT_ON_FAILURE=1 -export HARNESS_OSSL_PREFIX='' export OPENSSL_APP="$O_EXE/openssl" export OPENSSL_MODULES=$PWD/_build/lib export OQS_PROVIDER_TESTSCRIPTS=$SRCTOP/oqs-provider/scripts diff --git a/test/recipes/95-test_external_pkcs11_provider_data/pkcs11-provider.sh b/test/recipes/95-test_external_pkcs11_provider_data/pkcs11-provider.sh index 88d34402800..39cbdcbb73f 100755 --- a/test/recipes/95-test_external_pkcs11_provider_data/pkcs11-provider.sh +++ b/test/recipes/95-test_external_pkcs11_provider_data/pkcs11-provider.sh @@ -63,9 +63,8 @@ echo "------------------------------------------------------------------" echo "Running tests" echo "------------------------------------------------------------------" -# The OpenSSL app uses ${HARNESS_OSSL_PREFIX} as a prefix for its standard output # For maintenance reasons and simplicity we only run test with kryoptic token -HARNESS_OSSL_PREFIX= meson test -C $PKCS11_PROVIDER_BUILDDIR --suite=kryoptic +meson test -C $PKCS11_PROVIDER_BUILDDIR --suite=kryoptic if [ $? -ne 0 ]; then cat $PKCS11_PROVIDER_BUILDDIR/meson-logs/testlog.txt diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm index b90870d7138..98dbc013504 100644 --- a/util/perl/OpenSSL/Test.pm +++ b/util/perl/OpenSSL/Test.pm @@ -465,29 +465,27 @@ sub run { $ENV{HARNESS_OSSL_LEVEL} = $level + 1; + # We prefix the output with "# " in non-capture mode by default to avoid + # its interpretation by the TAP consumer. + my $default_prefix = $opts{capture} ? "" : "# "; + my $pipe; + local $_; + + open($pipe, '-|', "$prefix$cmd") or die "Can't start command: $!"; + while(<$pipe>) { + my $l = ($opts{prefix} // $default_prefix) . $_; + if ($opts{capture}) { + push @r, $l; + } else { + print STDOUT $l; + } + } + close $pipe; + # The dance we do with $? is the same dance the Unix shells appear to # do. For example, a program that gets aborted (and therefore signals # SIGABRT = 6) will appear to exit with the code 134. We mimic this # to make it easier to compare with a manual run of the command. - if ($opts{capture} || defined($opts{prefix})) { - my $pipe; - local $_; - - open($pipe, '-|', "$prefix$cmd") or die "Can't start command: $!"; - while(<$pipe>) { - my $l = ($opts{prefix} // "") . $_; - if ($opts{capture}) { - push @r, $l; - } else { - print STDOUT $l; - } - } - close $pipe; - } else { - $ENV{HARNESS_OSSL_PREFIX} = "# "; - system("$prefix$cmd"); - delete $ENV{HARNESS_OSSL_PREFIX}; - } $e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8); $r = $hooks{exit_checker}->($e); if ($opts{statusvar}) {