Skip to content

Commit 0cd9b09

Browse files
sebastianasgstrauss
authored andcommitted
[tests] do not test for exact compress zlib size
If zlibg-ng instead of zlib is used then the testsuite fails because the resulting compressed content has a different size. Alter the test and expect that the compressed content is less than half the size of the input. x-ref: lighttpd: FTBFS with zlib-ng https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1088683 Co-authored-by: Glenn Strauss <gstrauss@gluelogic.com> Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
1 parent fd6b4bb commit 0cd9b09

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

tests/LightyTest.pm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ sub handle_http {
460460
(my $k = $_) =~ tr/[A-Z]/[a-z]/;
461461

462462
my $verify_value = 1;
463+
my $verify_less_than = 0;
463464
my $key_inverted = 0;
464465

465466
if (substr($k, 0, 1) eq '+') {
@@ -470,6 +471,10 @@ sub handle_http {
470471
$k = substr($k, 1);
471472
$key_inverted = 1;
472473
$verify_value = 0; ## skip the value check
474+
} elsif (substr($k, 0, 1) eq '<') {
475+
## the value must be less than
476+
$k = substr($k, 1);
477+
$verify_less_than = 1;
473478
}
474479

475480
if ($key_inverted) {
@@ -492,6 +497,13 @@ sub handle_http {
492497
$href->{$_}, $resp_hdr{$k}, $1));
493498
return -1;
494499
}
500+
} elsif ($verify_less_than) {
501+
if ($resp_hdr{$k} >= $href->{$_}) {
502+
diag(sprintf(
503+
"\nresponse-header failed: expected '%s' > '%s'",
504+
$href->{$_}, $resp_hdr{$k}));
505+
return -1;
506+
}
495507
} elsif ($href->{$_} ne $resp_hdr{$k}) {
496508
diag(sprintf(
497509
"\nresponse-header failed: expected '%s', got '%s'",

tests/request.t

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,15 @@ EOF
14051405
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '' } ];
14061406
ok($tf->handle_http($t) == 0, 'Vary is set');
14071407

1408+
# The compressed content should be less than half of the original content size for the specific index.html content used in these tests.
1409+
14081410
$t->{REQUEST} = ( <<EOF
14091411
GET /index.html HTTP/1.0
14101412
Accept-Encoding: deflate
14111413
Host: deflate.example.org
14121414
EOF
14131415
);
1414-
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => qr/^129[34]$/, '+Content-Encoding' => '' } ];
1416+
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '<Content-Length' => '2174', '+Content-Encoding' => '' } ];
14151417
ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
14161418

14171419
$t->{REQUEST} = ( <<EOF
@@ -1420,7 +1422,7 @@ Accept-Encoding: deflate
14201422
Host: deflate-cache.example.org
14211423
EOF
14221424
);
1423-
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => qr/^129[34]$/, '+Content-Encoding' => '' } ];
1425+
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '<Content-Length' => '2174', '+Content-Encoding' => '' } ];
14241426
ok($tf->handle_http($t) == 0, 'deflate - Content-Length and Content-Encoding is set');
14251427

14261428
$t->{REQUEST} = ( <<EOF
@@ -1429,7 +1431,7 @@ Accept-Encoding: gzip
14291431
Host: deflate.example.org
14301432
EOF
14311433
);
1432-
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => qr/^130[56]$/, '+Content-Encoding' => '' } ];
1434+
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '<Content-Length' => '2174', '+Content-Encoding' => '' } ];
14331435
ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
14341436

14351437
$t->{REQUEST} = ( <<EOF
@@ -1438,7 +1440,7 @@ Accept-Encoding: gzip
14381440
Host: deflate-cache.example.org
14391441
EOF
14401442
);
1441-
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', 'Content-Length' => qr/^130[56]$/, '+Content-Encoding' => '' } ];
1443+
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Vary' => '', '<Content-Length' => '2174', '+Content-Encoding' => '' } ];
14421444
ok($tf->handle_http($t) == 0, 'gzip - Content-Length and Content-Encoding is set');
14431445

14441446

0 commit comments

Comments
 (0)