# HG changeset patch # User Sergey Kandaurov # Date 1510766169 -10800 # Node ID f7eb2875ed451c4c8739733dd53baff97419004f # Parent 4a825ec85c8deb179561042e7ab7571a46197552 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 --- a/proxy_upgrade.t +++ b/proxy_upgrade.t @@ -98,8 +98,8 @@ SKIP: { # 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 @@ sub upgrade_connect { . ($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_getline { } 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 @@ sub upgrade_handle_client { $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 --- a/ssl_proxy_upgrade.t +++ b/ssl_proxy_upgrade.t @@ -118,8 +118,8 @@ SKIP: { # 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 @@ sub upgrade_connect { . ($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_getline { } 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 @@ sub upgrade_handle_client { $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;