Title: [131761] trunk/Tools
Revision
131761
Author
[email protected]
Date
2012-10-18 09:19:09 -0700 (Thu, 18 Oct 2012)

Log Message

[BlackBerry] Dump DRT output to stdout if test is passed as command line argument
https://bugs.webkit.org/show_bug.cgi?id=99150

Patch by Xiaobo Wang <[email protected]> on 2012-10-18
Reviewed by Rob Buis.

Fixed some code style errors as well.

* DumpRenderTree/blackberry/DumpRenderTree.cpp:
(BlackBerry::WebKit::DumpRenderTree::runTest):
(BlackBerry::WebKit::DumpRenderTree::runRemainingTests):
(BlackBerry::WebKit::DumpRenderTree::runTests):
(BlackBerry::WebKit::DumpRenderTree::isHTTPTest):
(BlackBerry::WebKit::DumpRenderTree::dump):
(BlackBerry::WebKit::DumpRenderTree::addMessageToConsole):
* DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
(DumpRenderTree):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (131760 => 131761)


--- trunk/Tools/ChangeLog	2012-10-18 16:08:49 UTC (rev 131760)
+++ trunk/Tools/ChangeLog	2012-10-18 16:19:09 UTC (rev 131761)
@@ -1,3 +1,22 @@
+2012-10-18  Xiaobo Wang  <[email protected]>
+
+        [BlackBerry] Dump DRT output to stdout if test is passed as command line argument
+        https://bugs.webkit.org/show_bug.cgi?id=99150
+
+        Reviewed by Rob Buis.
+
+        Fixed some code style errors as well.
+
+        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
+        (BlackBerry::WebKit::DumpRenderTree::runTest):
+        (BlackBerry::WebKit::DumpRenderTree::runRemainingTests):
+        (BlackBerry::WebKit::DumpRenderTree::runTests):
+        (BlackBerry::WebKit::DumpRenderTree::isHTTPTest):
+        (BlackBerry::WebKit::DumpRenderTree::dump):
+        (BlackBerry::WebKit::DumpRenderTree::addMessageToConsole):
+        * DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
+        (DumpRenderTree):
+
 2012-10-18  Simon Hausmann  <[email protected]>
 
         [Qt] Improved support for silent builds

Modified: trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp (131760 => 131761)


--- trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-10-18 16:08:49 UTC (rev 131760)
+++ trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-10-18 16:19:09 UTC (rev 131761)
@@ -77,6 +77,7 @@
 WebCore::Frame* mainFrame = 0;
 WebCore::Frame* topLoadingFrame = 0;
 bool waitForPolicy = false;
+bool runFromCommandLine = false;
 
 // FIXME: Assuming LayoutTests has been copied to /developer/LayoutTests/
 static const char* const kSDCLayoutTestsURI = "file:///developer/LayoutTests/";
@@ -176,20 +177,21 @@
 
 void DumpRenderTree::runTest(const String& url)
 {
-    createFile(m_resultsDir + *m_currentTest + ".dump.crash");
-
     mainFrame->loader()->stopForUserCancel();
     resetToConsistentStateBeforeTesting();
     if (shouldLogFrameLoadDelegates(url))
         gTestRunner->setDumpFrameLoadCallbacks(true);
-    String stdoutFile = m_resultsDir + *m_currentTest + ".dump";
-    String stderrFile = m_resultsDir + *m_currentTest + ".stderr";
+    if (!runFromCommandLine) {
+        createFile(m_resultsDir + *m_currentTest + ".dump.crash");
 
-    // FIXME: we should preserve the original stdout and stderr here but aren't doing
-    // that yet due to issues with dup, etc.
-    freopen(stdoutFile.utf8().data(), "wb", stdout);
-    freopen(stderrFile.utf8().data(), "wb", stderr);
+        String stdoutFile = m_resultsDir + *m_currentTest + ".dump";
+        String stderrFile = m_resultsDir + *m_currentTest + ".stderr";
 
+        // FIXME: we should preserve the original stdout and stderr here but aren't doing
+        // that yet due to issues with dup, etc.
+        freopen(stdoutFile.utf8().data(), "wb", stdout);
+        freopen(stderrFile.utf8().data(), "wb", stderr);
+    }
     FILE* current = fopen(m_currentTestFile.utf8().data(), "w");
     fwrite(m_currentTest->utf8().data(), 1, m_currentTest->utf8().length(), current);
     fclose(current);
@@ -219,6 +221,11 @@
 
 void DumpRenderTree::runRemainingTests()
 {
+    if (runFromCommandLine) {
+        doneDrt();
+        return;
+    }
+
     // FIXME: fflush should not be necessary but is temporarily required due to a bug in stdio output.
     fflush(stdout);
     fflush(stderr);
@@ -328,9 +335,14 @@
 
     mainFrame = DumpRenderTreeSupport::corePage(m_page)->mainFrame();
 
-    // Get Test file name from PPS: /pps/services/drt/input
-    // Example: test_file::fast/js/arguments.html
-    waitForTest();
+    if (getenv("drtTestFile")) {
+        runFromCommandLine = true;
+        addTest(testFile);
+    } else {
+        // Get Test file name from PPS: /pps/services/drt/input
+        // Example: test_file::fast/js/arguments.html
+        waitForTest();
+    }
 }
 
 void DumpRenderTree::addTest(const char* testFile)
@@ -381,7 +393,7 @@
     String testLower = test.lower();
     int lenHttpTestSyntax = strlen(httpTestSyntax);
     return testLower.substring(0, lenHttpTestSyntax) == httpTestSyntax
-            && testLower.substring(lenHttpTestSyntax, strlen(localTestSyntax)) != localTestSyntax;
+        && testLower.substring(lenHttpTestSyntax, strlen(localTestSyntax)) != localTestSyntax;
 }
 
 void DumpRenderTree::invalidateAnyPreviousWaitToDumpWatchdog()
@@ -500,12 +512,13 @@
     if (m_dumpPixels && !dumpAsText && gTestRunner->generatePixelResults())
         dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner->expectedPixelHash());
 
-    String crashFile = dumpFile + ".crash";
-    unlink(crashFile.utf8().data());
+    if (!runFromCommandLine) {
+        String crashFile = dumpFile + ".crash";
+        unlink(crashFile.utf8().data());
 
-    String doneFile =  m_resultsDir + *m_currentTest + ".done";
-    createFile(doneFile);
-
+        String doneFile =  m_resultsDir + *m_currentTest + ".done";
+        createFile(doneFile);
+    }
     testDone = true;
     runRemainingTests();
 }
@@ -641,7 +654,7 @@
 }
 
 // ChromeClient delegates.
-void DumpRenderTree::addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID)
+void DumpRenderTree::addMessageToConsole(const String& message, unsigned lineNumber, const String& sourceID)
 {
     printf("CONSOLE MESSAGE: ");
     if (lineNumber)
@@ -653,7 +666,7 @@
         String remaining = message.substring(pos);
         String fileName;
         int indexFile = remaining.reverseFind('/') + 1;
-        if (indexFile > 0 && indexFile < remaining.length())
+        if (indexFile > 0 && unsigned(indexFile) < remaining.length())
             fileName = remaining.substring(indexFile);
         else
             fileName = "file:";

Modified: trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h (131760 => 131761)


--- trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h	2012-10-18 16:08:49 UTC (rev 131760)
+++ trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h	2012-10-18 16:19:09 UTC (rev 131761)
@@ -77,7 +77,7 @@
     void didReceiveResponseForFrame(WebCore::Frame*, const WebCore::ResourceResponse&);
 
     // ChromeClient delegates
-    void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID);
+    void addMessageToConsole(const String& message, unsigned lineNumber, const String& sourceID);
     void runJavaScriptAlert(const String& message);
     bool runJavaScriptConfirm(const String& message);
     String runJavaScriptPrompt(const String& message, const String& defaultValue);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to