]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove HARNESS_OSSL_PREFIX manipulation in the test harness
authorEugene Syromiatnikov <esyr@openssl.org>
Mon, 21 Jul 2025 11:32:24 +0000 (13:32 +0200)
committerNeil Horman <nhorman@openssl.org>
Tue, 29 Jul 2025 17:12:10 +0000 (13:12 -0400)
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 <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28025)

test/recipes/95-test_external_gost_engine_data/gost_engine.sh
test/recipes/95-test_external_oqsprovider_data/oqsprovider.sh
test/recipes/95-test_external_pkcs11_provider_data/pkcs11-provider.sh
util/perl/OpenSSL/Test.pm

index 54ebd5796c33b0ec5cd345f77596b99d94a0140a..9d8f8121a324847dc580c10878053288494d2e40 100755 (executable)
@@ -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
index a03c3722fc432eadb8a4d71d6dacd42829cf40d4..c3227c8b16811d67bf7708374994ad4eaf716b2c 100755 (executable)
@@ -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
index 88d3440280061b595fab80a8a6ec961241a380a7..39cbdcbb73fafd651e72d4d81dfbca11b028731b 100755 (executable)
@@ -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
index b90870d7138a85ab73799f0822a18ec47dd0bc7f..98dbc0135043e0a8af9e8250a30b2027143b5e41 100644 (file)
@@ -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}) {