From e45c1cdad9627f8b5f50f55c4a9642c1703a616a Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 25 Aug 2010 14:36:30 +0100 Subject: Add LayoutTests/http/tests/resources at r65615 These scripts are required to run the http tests, eg http/tests/appcache/fail-on-update.html Change-Id: I6173fcb9bc0d77a5cfc94fce45d02b1704ee6306 --- .../http/tests/resources/network-simulator.php | 143 +++++++++++++++++++++ LayoutTests/http/tests/resources/notify-done.html | 7 + .../http/tests/resources/portabilityLayer.php | 35 +++++ .../tests/resources/post-and-verify-hybrid.cgi | 86 +++++++++++++ .../http/tests/resources/post-and-verify.cgi | 30 +++++ LayoutTests/http/tests/resources/redirect.php | 16 +++ .../http/tests/resources/reset-temp-file.php | 19 +++ LayoutTests/http/tests/resources/silence.mpg | Bin 0 -> 33227 bytes .../http/tests/resources/touch-temp-file.php | 22 ++++ LayoutTests/http/tests/resources/tripmine.php | 63 +++++++++ .../http/tests/resources/write-temp-file.php | 17 +++ 11 files changed, 438 insertions(+) create mode 100644 LayoutTests/http/tests/resources/network-simulator.php create mode 100644 LayoutTests/http/tests/resources/notify-done.html create mode 100755 LayoutTests/http/tests/resources/portabilityLayer.php create mode 100755 LayoutTests/http/tests/resources/post-and-verify-hybrid.cgi create mode 100755 LayoutTests/http/tests/resources/post-and-verify.cgi create mode 100644 LayoutTests/http/tests/resources/redirect.php create mode 100755 LayoutTests/http/tests/resources/reset-temp-file.php create mode 100644 LayoutTests/http/tests/resources/silence.mpg create mode 100644 LayoutTests/http/tests/resources/touch-temp-file.php create mode 100644 LayoutTests/http/tests/resources/tripmine.php create mode 100644 LayoutTests/http/tests/resources/write-temp-file.php (limited to 'LayoutTests/http') diff --git a/LayoutTests/http/tests/resources/network-simulator.php b/LayoutTests/http/tests/resources/network-simulator.php new file mode 100644 index 0000000..3f1201f --- /dev/null +++ b/LayoutTests/http/tests/resources/network-simulator.php @@ -0,0 +1,143 @@ + diff --git a/LayoutTests/http/tests/resources/notify-done.html b/LayoutTests/http/tests/resources/notify-done.html new file mode 100644 index 0000000..8d692ed --- /dev/null +++ b/LayoutTests/http/tests/resources/notify-done.html @@ -0,0 +1,7 @@ + + diff --git a/LayoutTests/http/tests/resources/portabilityLayer.php b/LayoutTests/http/tests/resources/portabilityLayer.php new file mode 100755 index 0000000..e2fdc2d --- /dev/null +++ b/LayoutTests/http/tests/resources/portabilityLayer.php @@ -0,0 +1,35 @@ + diff --git a/LayoutTests/http/tests/resources/post-and-verify-hybrid.cgi b/LayoutTests/http/tests/resources/post-and-verify-hybrid.cgi new file mode 100755 index 0000000..2cc826a --- /dev/null +++ b/LayoutTests/http/tests/resources/post-and-verify-hybrid.cgi @@ -0,0 +1,86 @@ +#!/usr/bin/perl -w + +use Config; + +print "Content-type: text/plain\n\n"; + +if ($ENV{'REQUEST_METHOD'} eq "POST") { + if ($ENV{'CONTENT_LENGTH'}) { + read(STDIN, $postData, $ENV{'CONTENT_LENGTH'}) || die "Could not get post data\n"; + } else { + $postData = ""; + } + + @list = split(/&/, $ENV{'QUERY_STRING'}); + @values; + $values{'start'} = 0; + $values{'length'} = -1; + $values{'convert_newlines'} = 0; + foreach $element (@list) { + ($key, $value) = split(/=/, $element); + $values{$key} = $value; + } + + # 'items' parameter would look like: + # := (',')* + # := | + # := "file": + # := "data": + @items = split(/,/, $values{'items'}); + $expectedData = ""; + $readPos = $values{'start'}; + $remainingLength = $values{'length'}; + foreach $item (@items) { + my ($type, $data) = split(/:/, $item); + my $size; + if ($type eq "data") { + $data =~ s/%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; + $size = length($data); + if ($readPos > 0) { + if ($readPos > $size) { + $readPos -= $size; + next; + } + $data = substr($data, $readPos); + } + $data = substr($data, 0, $remainingLength) if ($remainingLength > 0); + } else { + $path = $data; + open(FILE, $path) || next; + $size = -s $path; + if ($readPos > 0) { + if ($readPos > $size) { + $readPos -= $size; + next; + } + seek(FILE, $readPos, 0); + } + if ($remainingLength > 0) { + read(FILE, $data, $remainingLength); + } else { + local $/ = undef; + $data = ; + } + close(FILE); + } + $readPos -= $size; + $expectedData .= $data; + if ($remainingLength > 0) { + $remainingLength -= length($data); + last if $remainingLength <= 0; + } + } + + if ($values{'convert_newlines'}) { + $nativeEnding = ($Config{osname} =~ /(MSWin|cygwin)/) ? "\r\n" : "\n"; + $postData =~ s/$nativeEnding/[NL]/g; + } + + if ($postData eq $expectedData) { + print "OK"; + } else { + print "FAILED"; + } +} else { + print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n"; +} diff --git a/LayoutTests/http/tests/resources/post-and-verify.cgi b/LayoutTests/http/tests/resources/post-and-verify.cgi new file mode 100755 index 0000000..2c7aa62 --- /dev/null +++ b/LayoutTests/http/tests/resources/post-and-verify.cgi @@ -0,0 +1,30 @@ +#!/usr/bin/perl -w + +print "Content-type: text/plain\n\n"; + +if ($ENV{'REQUEST_METHOD'} eq "POST") { + if ($ENV{'CONTENT_LENGTH'}) { + read(STDIN, $postData, $ENV{'CONTENT_LENGTH'}) || die "Could not get post data\n"; + } else { + $postData = ""; + } + + @list = split(/&/, $ENV{'QUERY_STRING'}); + foreach $element (@list) { + ($key, $value) = split(/=/, $element); + $values{$key} = $value; + } + + open FILE, $values{'path'} || die("Could not open file\n"); + seek FILE, $values{'start'}, 0; + read FILE, $expectedData, $values{'length'}; + close(FILE); + + if ($postData eq $expectedData) { + print "OK"; + } else { + print "FAILED"; + } +} else { + print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n"; +} diff --git a/LayoutTests/http/tests/resources/redirect.php b/LayoutTests/http/tests/resources/redirect.php new file mode 100644 index 0000000..cfeb37d --- /dev/null +++ b/LayoutTests/http/tests/resources/redirect.php @@ -0,0 +1,16 @@ + diff --git a/LayoutTests/http/tests/resources/reset-temp-file.php b/LayoutTests/http/tests/resources/reset-temp-file.php new file mode 100755 index 0000000..186376b --- /dev/null +++ b/LayoutTests/http/tests/resources/reset-temp-file.php @@ -0,0 +1,19 @@ + diff --git a/LayoutTests/http/tests/resources/silence.mpg b/LayoutTests/http/tests/resources/silence.mpg new file mode 100644 index 0000000..b6bbf20 Binary files /dev/null and b/LayoutTests/http/tests/resources/silence.mpg differ diff --git a/LayoutTests/http/tests/resources/touch-temp-file.php b/LayoutTests/http/tests/resources/touch-temp-file.php new file mode 100644 index 0000000..d2829df --- /dev/null +++ b/LayoutTests/http/tests/resources/touch-temp-file.php @@ -0,0 +1,22 @@ + diff --git a/LayoutTests/http/tests/resources/tripmine.php b/LayoutTests/http/tests/resources/tripmine.php new file mode 100644 index 0000000..635dea6 --- /dev/null +++ b/LayoutTests/http/tests/resources/tripmine.php @@ -0,0 +1,63 @@ + diff --git a/LayoutTests/http/tests/resources/write-temp-file.php b/LayoutTests/http/tests/resources/write-temp-file.php new file mode 100644 index 0000000..7abe358 --- /dev/null +++ b/LayoutTests/http/tests/resources/write-temp-file.php @@ -0,0 +1,17 @@ + -- cgit v1.1