<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46676] trunk/WebKitTools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/46676">46676</a></dd>
<dt>Author</dt> <dd>mrowe@apple.com</dd>
<dt>Date</dt> <dd>2009-08-01 13:05:06 -0700 (Sat, 01 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Bug 27923: run-webkit-tests should not invoke &quot;ps&quot; repeatedly on Mac OS X
Fix &lt;https://bugs.webkit.org/show_bug.cgi?id=27923&gt;.

Reviewed by Sam Weinig.

run-webkit-tests invokes &quot;ps&quot; after each test on Mac OS X to determine whether DumpRenderTree is
in the process of crashing.  We can do the same test more efficiently with a simple call to sysctl.
I couldn't find any built-in way of doing this directly from perl, so we do it from a simple C module
instead.  This speeds up run-webkit-tests by around 8%.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c: Added.
(processIsCrashing):
* DumpRenderTree/mac/PerlSupport/Makefile: Added.
* Scripts/run-webkit-tests:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitToolsChangeLog">trunk/WebKitTools/ChangeLog</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj">trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkWebKitToolsScriptsrunwebkittests">trunk/WebKitTools/Scripts/run-webkit-tests</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/</li>
<li><a href="#trunkWebKitToolsDumpRenderTreemacPerlSupportDumpRenderTreeSupportc">trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreemacPerlSupportMakefile">trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/ChangeLog (46675 => 46676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/ChangeLog        2009-08-01 18:35:49 UTC (rev 46675)
+++ trunk/WebKitTools/ChangeLog        2009-08-01 20:05:06 UTC (rev 46676)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2009-08-01  Mark Rowe  &lt;mrowe@apple.com&gt;
+
+        Reviewed by Sam Weinig.
+
+        Fix &lt;https://bugs.webkit.org/show_bug.cgi?id=27923&gt;.
+        Bug 27923: run-webkit-tests should not invoke &quot;ps&quot; repeatedly on Mac OS X
+
+        run-webkit-tests invokes &quot;ps&quot; after each test on Mac OS X to determine whether DumpRenderTree is
+        in the process of crashing.  We can do the same test more efficiently with a simple call to sysctl.
+        I couldn't find any built-in way of doing this directly from perl, so we do it from a simple C module
+        instead.  This speeds up run-webkit-tests by around 8%.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c: Added.
+        (processIsCrashing):
+        * DumpRenderTree/mac/PerlSupport/Makefile: Added.
+        * Scripts/run-webkit-tests:
+
</ins><span class="cx"> 2009-08-01  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         resolve-ChangeLogs: add error checking to git ls-files command on close()
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeDumpRenderTreexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (46675 => 46676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2009-08-01 18:35:49 UTC (rev 46675)
+++ trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj        2009-08-01 20:05:06 UTC (rev 46676)
</span><span class="lines">@@ -16,6 +16,7 @@
</span><span class="cx">                                 A84F609108B1370E00E9745F /* PBXTargetDependency */,
</span><span class="cx">                                 A84F608F08B1370E00E9745F /* PBXTargetDependency */,
</span><span class="cx">                                 141BF238096A451E00E0753C /* PBXTargetDependency */,
</span><ins>+                                5DC82A701023C93D00FD1D3B /* PBXTargetDependency */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = All;
</span><span class="cx">                         productName = All;
</span><span class="lines">@@ -122,6 +123,13 @@
</span><span class="cx">                         remoteGlobalIDString = 141BF21E096A441D00E0753C;
</span><span class="cx">                         remoteInfo = TestNetscapePlugIn;
</span><span class="cx">                 };
</span><ins>+                5DC82A6F1023C93D00FD1D3B /* PBXContainerItemProxy */ = {
+                        isa = PBXContainerItemProxy;
+                        containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+                        proxyType = 1;
+                        remoteGlobalIDString = 5DC82A661023C8DE00FD1D3B;
+                        remoteInfo = &quot;DumpRenderTree Perl Support&quot;;
+                };
</ins><span class="cx">                 A84F608E08B1370E00E9745F /* PBXContainerItemProxy */ = {
</span><span class="cx">                         isa = PBXContainerItemProxy;
</span><span class="cx">                         containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
</span><span class="lines">@@ -535,6 +543,23 @@
</span><span class="cx">                 };
</span><span class="cx"> /* End PBXHeadersBuildPhase section */
</span><span class="cx"> 
</span><ins>+/* Begin PBXLegacyTarget section */
+                5DC82A661023C8DE00FD1D3B /* DumpRenderTree Perl Support */ = {
+                        isa = PBXLegacyTarget;
+                        buildArgumentsString = &quot;$(ACTION)&quot;;
+                        buildConfigurationList = 5DC82A6E1023C92A00FD1D3B /* Build configuration list for PBXLegacyTarget &quot;DumpRenderTree Perl Support&quot; */;
+                        buildPhases = (
+                        );
+                        buildToolPath = /usr/bin/make;
+                        buildWorkingDirectory = &quot;$(SRCROOT)/mac/PerlSupport&quot;;
+                        dependencies = (
+                        );
+                        name = &quot;DumpRenderTree Perl Support&quot;;
+                        passBuildSettingsInEnvironment = 1;
+                        productName = &quot;DumpRenderTree Perl Support&quot;;
+                };
+/* End PBXLegacyTarget section */
+
</ins><span class="cx"> /* Begin PBXNativeTarget section */
</span><span class="cx">                 141BF21E096A441D00E0753C /* TestNetscapePlugIn */ = {
</span><span class="cx">                         isa = PBXNativeTarget;
</span><span class="lines">@@ -608,6 +633,7 @@
</span><span class="cx">                                 9340994A08540CAE007F3BC8 /* DumpRenderTree */,
</span><span class="cx">                                 B5A7525A08AF4A4A00138E45 /* ImageDiff */,
</span><span class="cx">                                 141BF21E096A441D00E0753C /* TestNetscapePlugIn */,
</span><ins>+                                5DC82A661023C8DE00FD1D3B /* DumpRenderTree Perl Support */,
</ins><span class="cx">                         );
</span><span class="cx">                 };
</span><span class="cx"> /* End PBXProject section */
</span><span class="lines">@@ -689,6 +715,11 @@
</span><span class="cx">                         target = 141BF21E096A441D00E0753C /* TestNetscapePlugIn */;
</span><span class="cx">                         targetProxy = 141BF237096A451E00E0753C /* PBXContainerItemProxy */;
</span><span class="cx">                 };
</span><ins>+                5DC82A701023C93D00FD1D3B /* PBXTargetDependency */ = {
+                        isa = PBXTargetDependency;
+                        target = 5DC82A661023C8DE00FD1D3B /* DumpRenderTree Perl Support */;
+                        targetProxy = 5DC82A6F1023C93D00FD1D3B /* PBXContainerItemProxy */;
+                };
</ins><span class="cx">                 A84F608F08B1370E00E9745F /* PBXTargetDependency */ = {
</span><span class="cx">                         isa = PBXTargetDependency;
</span><span class="cx">                         target = B5A7525A08AF4A4A00138E45 /* ImageDiff */;
</span><span class="lines">@@ -745,6 +776,27 @@
</span><span class="cx">                         };
</span><span class="cx">                         name = Release;
</span><span class="cx">                 };
</span><ins>+                5DC82A671023C8DE00FD1D3B /* Debug */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                PRODUCT_NAME = &quot;DumpRenderTree Perl Support&quot;;
+                        };
+                        name = Debug;
+                };
+                5DC82A681023C8DE00FD1D3B /* Release */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                PRODUCT_NAME = &quot;DumpRenderTree Perl Support&quot;;
+                        };
+                        name = Release;
+                };
+                5DC82A691023C8DE00FD1D3B /* Production */ = {
+                        isa = XCBuildConfiguration;
+                        buildSettings = {
+                                PRODUCT_NAME = &quot;DumpRenderTree Perl Support&quot;;
+                        };
+                        name = Production;
+                };
</ins><span class="cx">                 90CBC3500F748B1300A712B7 /* Production */ = {
</span><span class="cx">                         isa = XCBuildConfiguration;
</span><span class="cx">                         baseConfigurationReference = BCB281EE0CFA713D007E533E /* Base.xcconfig */;
</span><span class="lines">@@ -871,6 +923,16 @@
</span><span class="cx">                         defaultConfigurationIsVisible = 0;
</span><span class="cx">                         defaultConfigurationName = Production;
</span><span class="cx">                 };
</span><ins>+                5DC82A6E1023C92A00FD1D3B /* Build configuration list for PBXLegacyTarget &quot;DumpRenderTree Perl Support&quot; */ = {
+                        isa = XCConfigurationList;
+                        buildConfigurations = (
+                                5DC82A671023C8DE00FD1D3B /* Debug */,
+                                5DC82A681023C8DE00FD1D3B /* Release */,
+                                5DC82A691023C8DE00FD1D3B /* Production */,
+                        );
+                        defaultConfigurationIsVisible = 0;
+                        defaultConfigurationName = Production;
+                };
</ins><span class="cx">                 A84F609208B1371400E9745F /* Build configuration list for PBXAggregateTarget &quot;All&quot; */ = {
</span><span class="cx">                         isa = XCConfigurationList;
</span><span class="cx">                         buildConfigurations = (
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreemacPerlSupportDumpRenderTreeSupportc"></a>
<div class="addfile"><h4>Added: trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c (0 => 46676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c                                (rev 0)
+++ trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c        2009-08-01 20:05:06 UTC (rev 46676)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &lt;sys/sysctl.h&gt;
+
+int processIsCrashing(int pid)
+{
+    int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
+    struct kinfo_proc info;
+    size_t bufferSize = sizeof(info);
+    if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &amp;info, &amp;bufferSize, 0, 0)) {
+        perror(&quot;sysctl&quot;);
+        return 0;
+    }
+
+    struct extern_proc proc = info.kp_proc;
+
+    // The process is crashing if it is waiting to exit, is not a zombie, and has a non-zero exit code.
+    return proc.p_stat != SZOMB &amp;&amp; (proc.p_flag &amp; P_WEXIT) &amp;&amp; proc.p_xstat;
+}
</ins></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreemacPerlSupportMakefile"></a>
<div class="addfile"><h4>Added: trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile (0 => 46676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile                                (rev 0)
+++ trunk/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile        2009-08-01 20:05:06 UTC (rev 46676)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+
+CONFIGURATION_BUILD_DIR ?= .
+OUTPUT_DIR=$(CONFIGURATION_BUILD_DIR)
+
+WRAPPER=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree/DumpRenderTreeSupport_wrap.c
+PERL_MODULE=$(OUTPUT_DIR)/DumpRenderTreeSupport.pm
+DYLIB=$(OUTPUT_DIR)/DumpRenderTreeSupport.dylib
+
+all: $(DYLIB) $(PERL_MODULE)
+
+clean:
+        rm -f $(WRAPPER) $(PERL_MODULE) $(DYLIB)
+
+$(WRAPPER) $(PERL_MODULE): DumpRenderTreeSupport.c
+        mkdir -p $$(dirname $(WRAPPER))
+        swig -o $(WRAPPER) -outdir $(OUTPUT_DIR) -perl -module DumpRenderTreeSupport $&lt;
+
+$(DYLIB): DumpRenderTreeSupport.c $(WRAPPER)
+        gcc -g -shared -o $(DYLIB) `perl -MExtUtils::Embed -eperl_inc` `perl -MExtUtils::Embed -eldopts` $^
</ins></span></pre></div>
<a id="trunkWebKitToolsScriptsrunwebkittests"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/Scripts/run-webkit-tests (46675 => 46676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/Scripts/run-webkit-tests        2009-08-01 18:35:49 UTC (rev 46675)
+++ trunk/WebKitTools/Scripts/run-webkit-tests        2009-08-01 20:05:06 UTC (rev 46676)
</span><span class="lines">@@ -294,6 +294,11 @@
</span><span class="cx"> $productDir .= &quot;/bin&quot; if isQt();
</span><span class="cx"> $productDir .= &quot;/Programs&quot; if isGtk();
</span><span class="cx"> 
</span><ins>+if (isAppleMacWebKit()) {
+    push @INC, $productDir;
+    eval 'use DumpRenderTreeSupport;';
+}
+
</ins><span class="cx"> chdirWebKit();
</span><span class="cx"> 
</span><span class="cx"> if (!defined($root)) {
</span><span class="lines">@@ -1357,12 +1362,7 @@
</span><span class="cx">     # On Mac OS X, crashing may be significantly delayed by crash reporter.
</span><span class="cx">     return 0 unless isAppleMacWebKit();
</span><span class="cx"> 
</span><del>-    my $tryingToExit = 0;
-    open PS, &quot;ps -o state -p $dumpToolPID |&quot;;
-    &lt;PS&gt;; # skip header
-    $tryingToExit = 1 if &lt;PS&gt; =~ /E/;
-    close PS;
-    return $tryingToExit;
</del><ins>+    return DumpRenderTreeSupport::processIsCrashing($dumpToolPID);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> sub openHTTPDIfNeeded()
</span></span></pre>
</div>
</div>

</body>
</html>