From 002ed5f29800282b16c2d9df8480aa7386c93dea Mon Sep 17 00:00:00 2001
From: Yang Tse <yangsita@gmail.com>
Date: Wed, 16 Dec 2009 19:55:35 +0000
Subject: [PATCH] Test harness process control enhancements

---
 tests/ftp.pm       | 6 +++++-
 tests/runtests.pl  | 2 +-
 tests/server/sws.c | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/ftp.pm b/tests/ftp.pm
index 28bbb4ea68..1b45014a6f 100644
--- a/tests/ftp.pm
+++ b/tests/ftp.pm
@@ -85,7 +85,11 @@ sub killpid {
     # stop it, otherwise reap it if this has not been done yet.
     my @signalled;
     my $prev = 0;
-    my @pids = sort({$a <=> $b} split(/\s+/, $pidlist));
+    my @pids = split(' ', $pidlist);
+    if(scalar(@pids) > 2) {
+        my @sorted = sort({$a <=> $b} @pids);
+        @pids = @sorted;
+    }
     foreach my $tmp (@pids) {
         chomp $tmp;
         if($tmp =~ /^(\d+)$/) {
diff --git a/tests/runtests.pl b/tests/runtests.pl
index ace609f722..33def4d915 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -2518,7 +2518,7 @@ sub stopservers {
         my $pid;
         my $prev;
 
-        foreach $pid (split(/\s+/, $pids)) {
+        foreach $pid (split(' ', $pids)) {
             if($pid != $prev) {
                 # no need to kill same pid twice!
                 logmsg sprintf("* kill pid for %s => %d\n",
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 00fd74fe10..5970f470c1 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -927,7 +927,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
       logmsg("Sent off %zd bytes", written);
     }
     /* write to file as well */
-    fwrite(buffer, 1, written, dump);
+    fwrite(buffer, 1, (size_t)written, dump);
     if(got_exit_signal)
       break;
 
-- 
GitLab