Tests: avoid interleaved output in Upgrade handling tests.

When the testing script is run in verbose mode by prove that redirects stdout,
a garbled verbose mode line from backend can be produced that incorporates TAP
output of an individual test result, which eventually breaks the testing plan.
Notably, this happens when testing sending multiple frames if backend started
to respond before all frames were received.  This is possible due to the line
boundary used as an indicator of last bytes to receive before starting to send.
The fix is to amend the only last frame of many specially, for that purpose.
diff --git a/proxy_upgrade.t b/proxy_upgrade.t
index 609a5c3..d93bbbb 100644
--- a/proxy_upgrade.t
+++ b/proxy_upgrade.t
@@ -98,8 +98,8 @@
 	# send multiple frames
 
 	for my $i (1 .. 10) {
-		upgrade_write($s, ('foo' x 16384) . $i);
-		upgrade_write($s, 'bazz' . $i);
+		upgrade_write($s, ('foo' x 16384) . $i, continue => 1);
+		upgrade_write($s, 'bazz' . $i, continue => $i != 10);
 	}
 
 	for my $i (1 .. 10) {
@@ -177,7 +177,7 @@
 		. ($opts{noheader} ? '' : "Upgrade: foo" . CRLF)
 		. "Connection: Upgrade" . CRLF . CRLF;
 
-	$buf .= $opts{message} . CRLF if defined $opts{message};
+	$buf .= $opts{message} . CRLF . 'FIN' if defined $opts{message};
 
 	local $SIG{PIPE} = 'IGNORE';
 
@@ -237,9 +237,10 @@
 }
 
 sub upgrade_write {
-	my ($s, $message) = @_;
+	my ($s, $message, %extra) = @_;
 
 	$message = $message . CRLF;
+	$message = $message . 'FIN' unless $extra{continue};
 
 	local $SIG{PIPE} = 'IGNORE';
 
@@ -325,7 +326,8 @@
 
 			$unfinished .= $chunk;
 
-			if ($unfinished =~ m/\x0d?\x0a\z/) {
+			if ($unfinished =~ m/\x0d?\x0aFIN\z/) {
+				$unfinished =~ s/FIN\z//;
 				$unfinished =~ s/foo/bar/g;
 				log2o($unfinished);
 				$buffer .= $unfinished;
diff --git a/ssl_proxy_upgrade.t b/ssl_proxy_upgrade.t
index c278875..fb1619d 100644
--- a/ssl_proxy_upgrade.t
+++ b/ssl_proxy_upgrade.t
@@ -118,8 +118,8 @@
 	# send multiple frames
 
 	for my $i (1 .. 10) {
-		upgrade_write($s, ('foo' x 16384) . $i);
-		upgrade_write($s, 'bazz' . $i);
+		upgrade_write($s, ('foo' x 16384) . $i, continue => 1);
+		upgrade_write($s, 'bazz' . $i, continue => $i != 10);
 	}
 
 	for my $i (1 .. 10) {
@@ -185,7 +185,7 @@
 		. ($opts{noheader} ? '' : "Upgrade: foo" . CRLF)
 		. "Connection: Upgrade" . CRLF . CRLF;
 
-	$buf .= $opts{message} . CRLF if defined $opts{message};
+	$buf .= $opts{message} . CRLF . 'FIN' if defined $opts{message};
 
 	local $SIG{PIPE} = 'IGNORE';
 
@@ -251,9 +251,10 @@
 }
 
 sub upgrade_write {
-	my ($s, $message) = @_;
+	my ($s, $message, %extra) = @_;
 
 	$message = $message . CRLF;
+	$message = $message . 'FIN' unless $extra{continue};
 
 	local $SIG{PIPE} = 'IGNORE';
 
@@ -342,7 +343,8 @@
 
 			$unfinished .= $chunk;
 
-			if ($unfinished =~ m/\x0d?\x0a\z/) {
+			if ($unfinished =~ m/\x0d?\x0aFIN\z/) {
+				$unfinished =~ s/FIN\z//;
 				$unfinished =~ s/foo/bar/g;
 				log2o($unfinished);
 				$buffer .= $unfinished;