3 # Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 # its contributors may be used to endorse or promote products derived
16 # from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # A script to semi-automatically run iExploder tests.
40 use lib $FindBin::Bin;
41 use webkitperl::httpd;
44 sub configureAndOpenHTTPDIfNeeded();
45 sub runSafariWithIExploder();
51 my $iExploderTestDirectory = "/tmp/iExploderTest";
54 'guard-malloc|g' => \$guardMalloc,
55 'get=s' => \$downloadTest,
56 'port=i' => \$httpdPort
61 my $productDir = productDir();
68 configureAndOpenHTTPDIfNeeded();
71 system "/usr/bin/curl -o ~/Desktop/iexploder$downloadTest.html \"http://127.0.0.1:$httpdPort/iexploder.cgi?lookup=1&test=$downloadTest\"";
72 print "Saved the test as iexploder$downloadTest.html on the desktop\n";
74 runSafariWithIExploder();
75 print "Last generated tests:\n";
76 system "grep 'iexploder.cgi' $iExploderTestDirectory/access_log.txt | tail -n -5 | awk -F'[ =&\\?]' '{if (\$8 == \"lookup\") print \$11; else print \$9}'";
79 rmtree $iExploderTestDirectory;
80 $isHttpdOpen = !closeHTTPD();
82 sub runSafariWithIExploder()
86 $redirectTo = "http://127.0.0.1:$httpdPort/iexploder.cgi?lookup=1&test=$ARGV[0]";
88 $redirectTo = "http://127.0.0.1:$httpdPort/index.html";
91 open REDIRECT_HTML, ">", "$iExploderTestDirectory/redirect.html" or die;
92 print REDIRECT_HTML "<html>\n";
93 print REDIRECT_HTML " <head>\n";
94 print REDIRECT_HTML " <meta http-equiv=\"refresh\" content=\"1;URL=$redirectTo\" />\n";
95 print REDIRECT_HTML " <script type=\"text/javascript\">\n";
96 print REDIRECT_HTML " document.location = \"$redirectTo\";\n";
97 print REDIRECT_HTML " </script>\n";
98 print REDIRECT_HTML " </head>\n";
99 print REDIRECT_HTML " <body>\n";
100 print REDIRECT_HTML " </body>\n";
101 print REDIRECT_HTML "</html>\n";
104 if (!isAppleWebKit()) {
105 system "Tools/Scripts/run-launcher", "$iExploderTestDirectory/redirect.html";
108 $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc;
109 system "Tools/Scripts/run-safari", "-NSOpen", "$iExploderTestDirectory/redirect.html";
113 sub configureAndOpenHTTPDIfNeeded()
115 return if $isHttpdOpen;
116 mkdir $iExploderTestDirectory;
117 my $webkitDirectory = getcwd();
118 my $testDirectory = $webkitDirectory . "/LayoutTests";
119 my $iExploderDirectory = $webkitDirectory . "/Tools/iExploder/iExploder-1.3.2";
121 my $httpdConfig = getHTTPDConfigPathForTestDirectory($testDirectory);
123 my $documentRoot = "$iExploderDirectory/htdocs";
124 my $typesConfig = "$testDirectory/http/conf/mime.types";
125 my $sslCertificate = "$testDirectory/http/conf/webkit-httpd.pem";
126 my $listen = "127.0.0.1:$httpdPort";
130 "-f", "$httpdConfig",
131 "-C", "DocumentRoot \"$documentRoot\"",
132 "-C", "Listen $listen",
133 "-c", "TypesConfig \"$typesConfig\"",
134 "-c", "CustomLog \"$iExploderTestDirectory/access_log.txt\" common",
135 "-c", "ErrorLog \"$iExploderTestDirectory/error_log.txt\"",
136 "-c", "SSLCertificateFile \"$sslCertificate\"",
137 # Apache wouldn't run CGIs with permissions==700 otherwise
141 $isHttpdOpen = openHTTPD(@args);