]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
runtests: support running tests under wine or qemu
authorViktor Szakats <commit@vsz.me>
Fri, 21 Mar 2025 13:39:55 +0000 (14:39 +0100)
committerViktor Szakats <commit@vsz.me>
Sun, 23 Mar 2025 19:26:38 +0000 (20:26 +0100)
To run curl, tests and servers via `wine`:
```shell
export CURL_TEST_EXE_RUNNER=wine
```
runtests prefixes commands with the specified runner. For systems where
this isn't automatic or supported, e.g. macOS.

Closes #16785

tests/runner.pm
tests/runtests.pl
tests/serverhelp.pm
tests/testutil.pm

index 0c48f8ced6f4e59425a29a7654275ea9648e8cc5..14acbcdd92cbdefc39107706921c8edce95d09ce 100644 (file)
@@ -99,6 +99,7 @@ use testutil qw(
     clearlogs
     logmsg
     runclient
+    exerunner
     shell_quote
     subbase64
     subsha256base64file
@@ -935,6 +936,8 @@ sub singletest_run {
             return (-1, 0, 0, "", "", 0);
         }
 
+        $CMDLINE=exerunner() . $CMDLINE;
+
         if($bundle) {
             $CMDLINE.=" $tool_name";
         }
@@ -971,7 +974,7 @@ sub singletest_run {
     }
 
     if(!$tool) {
-        $CMDLINE=shell_quote($CURL);
+        $CMDLINE=exerunner() . shell_quote($CURL);
         if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-q/)) {
             $CMDLINE .= " -q";
         }
index 57e3152392ace9b753e362f903d4a33b6a447d6e..ae2e5fef817a9ca6c8836495503c35ee5de78096 100755 (executable)
@@ -498,7 +498,7 @@ sub checksystemfeatures {
 
     my $curlverout="$LOGDIR/curlverout.log";
     my $curlvererr="$LOGDIR/curlvererr.log";
-    my $versioncmd=shell_quote($CURL) . " --version 1>$curlverout 2>$curlvererr";
+    my $versioncmd=exerunner() . shell_quote($CURL) . " --version 1>$curlverout 2>$curlvererr";
 
     unlink($curlverout);
     unlink($curlvererr);
@@ -2531,7 +2531,7 @@ if(!$randseed) {
     # seed of the month. December 2019 becomes 201912
     $randseed = ($year+1900)*100 + $mon+1;
     print "Using curl: $CURL\n";
-    open(my $curlvh, "-|", shell_quote($CURL) . " --version 2>$dev_null") ||
+    open(my $curlvh, "-|", exerunner() . shell_quote($CURL) . " --version 2>$dev_null") ||
         die "could not get curl version!";
     my @c = <$curlvh>;
     close($curlvh) || die "could not get curl version!";
index 89cca15dc95d3960216e7c46870559c18a360f0e..dba0cc509b9b15020465811c58884a40d93698e6 100644 (file)
@@ -65,6 +65,9 @@ use globalconfig;
 use pathhelp qw(
     exe_ext
     );
+use testutil qw(
+    exerunner
+    );
 
 our $logfile;  # server log file name, for logmsg
 
@@ -251,7 +254,7 @@ sub server_exe {
     else {
         $cmd = $SRVDIR . $name . exe_ext($ext);
     }
-    return "$cmd";
+    return exerunner() . "$cmd";
 }
 
 
@@ -270,6 +273,9 @@ sub server_exe_args {
     else {
         @cmd = ($SRVDIR . $name . exe_ext($ext));
     }
+    if($ENV{'CURL_TEST_EXE_RUNNER'}) {
+        unshift @cmd, $ENV{'CURL_TEST_EXE_RUNNER'};
+    }
     return @cmd;
 }
 
index 113c90a2b0aea9f3ead4e9da3bb2a11f7492caf7..47054627fc99990b99419c0c3bf6f59d3331f260 100644 (file)
@@ -37,6 +37,7 @@ BEGIN {
         runclient
         runclientoutput
         setlogfunc
+        exerunner
         shell_quote
         subbase64
         subnewlines
@@ -208,6 +209,15 @@ sub runclientoutput {
 #    return @out;
 }
 
+#######################################################################
+# Return custom tool (e.g. wine or qemu) to run curl binaries.
+#
+sub exerunner {
+    if($ENV{'CURL_TEST_EXE_RUNNER'}) {
+        return $ENV{'CURL_TEST_EXE_RUNNER'} . ' ';
+    }
+    return '';
+}
 
 #######################################################################
 # Quote an argument for passing safely to a Bourne shell