From 8a84734774708d55f6a5df868e99c3165073dcad Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Tue, 13 Jan 2009 11:50:40 -0800 Subject: [PATCH] Only run assertion checks in DEBUG builds. (Bug 472557) r=Waldo,bsmedberg --- layout/tools/reftest/reftest.js | 58 +++++++++++++++++---------------- xpcom/base/nsDebugImpl.cpp | 11 +++++++ xpcom/base/nsIDebug2.idl | 9 ++++- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index 4bc40388b2d..833cd47d8e8 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -866,37 +866,39 @@ function DoAssertionCheck() { gClearingForAssertionCheck = false; - // TEMPORARILY DISABLING ASSERTION CHECKS FOR NOW. TO RE-ENABLE, - // USE COMMENTED LINE TO REPLACE FOLLOWING ONE. - // var newAssertionCount = gDebug.assertionCount; - var newAssertionCount = 0; - var numAsserts = newAssertionCount - gAssertionCount; - gAssertionCount = newAssertionCount; + if (gDebug.isDebugBuild) { + // TEMPORARILY DISABLING ASSERTION CHECKS FOR NOW. TO RE-ENABLE, + // USE COMMENTED LINE TO REPLACE FOLLOWING ONE. + // var newAssertionCount = gDebug.assertionCount; + var newAssertionCount = 0; + var numAsserts = newAssertionCount - gAssertionCount; + gAssertionCount = newAssertionCount; - var minAsserts = gURLs[0].minAsserts; - var maxAsserts = gURLs[0].maxAsserts; + var minAsserts = gURLs[0].minAsserts; + var maxAsserts = gURLs[0].maxAsserts; - var expectedAssertions = "expected " + minAsserts; - if (minAsserts != maxAsserts) { - expectedAssertions += " to " + maxAsserts; - } - expectedAssertions += " assertions"; + var expectedAssertions = "expected " + minAsserts; + if (minAsserts != maxAsserts) { + expectedAssertions += " to " + maxAsserts; + } + expectedAssertions += " assertions"; - if (numAsserts < minAsserts) { - ++gTestResults.AssertionUnexpectedFixed; - dump("REFTEST TEST-UNEXPECTED-PASS | " + gURLs[0].prettyPath + - " | assertion count " + numAsserts + " is less than " + - expectedAssertions + "\n"); - } else if (numAsserts > maxAsserts) { - ++gTestResults.AssertionUnexpected; - dump("REFTEST TEST-UNEXPECTED-FAIL | " + gURLs[0].prettyPath + - " | assertion count " + numAsserts + " is more than " + - expectedAssertions + "\n"); - } else if (numAsserts != 0) { - ++gTestResults.AssertionKnown; - dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].prettyPath + - " | assertion count " + numAsserts + " matches " + - expectedAssertions + "\n"); + if (numAsserts < minAsserts) { + ++gTestResults.AssertionUnexpectedFixed; + dump("REFTEST TEST-UNEXPECTED-PASS | " + gURLs[0].prettyPath + + " | assertion count " + numAsserts + " is less than " + + expectedAssertions + "\n"); + } else if (numAsserts > maxAsserts) { + ++gTestResults.AssertionUnexpected; + dump("REFTEST TEST-UNEXPECTED-FAIL | " + gURLs[0].prettyPath + + " | assertion count " + numAsserts + " is more than " + + expectedAssertions + "\n"); + } else if (numAsserts != 0) { + ++gTestResults.AssertionKnown; + dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].prettyPath + + " | assertion count " + numAsserts + " matches " + + expectedAssertions + "\n"); + } } // And start the next test. diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index d1a15b95428..f9ec9732dca 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -137,6 +137,17 @@ nsDebugImpl::Abort(const char *aFile, PRInt32 aLine) return NS_OK; } +NS_IMETHODIMP +nsDebugImpl::GetIsDebugBuild(PRBool* aResult) +{ +#ifdef DEBUG + *aResult = PR_TRUE; +#else + *aResult = PR_FALSE; +#endif + return NS_OK; +} + NS_IMETHODIMP nsDebugImpl::GetAssertionCount(PRInt32* aResult) { diff --git a/xpcom/base/nsIDebug2.idl b/xpcom/base/nsIDebug2.idl index 1a492e83a10..13874a56135 100644 --- a/xpcom/base/nsIDebug2.idl +++ b/xpcom/base/nsIDebug2.idl @@ -39,9 +39,16 @@ #include "nsIDebug.idl" -[scriptable, uuid(15c0b474-fedb-4789-878b-def834b84735)] +[scriptable, uuid(9c9307ed-480a-4f2a-8f29-21378c03bcbc)] interface nsIDebug2 : nsIDebug { + /** + * Whether XPCOM was compiled with DEBUG defined. This often + * correlates to whether other code (e.g., Firefox, XULRunner) was + * compiled with DEBUG defined. + */ + readonly attribute boolean isDebugBuild; + /** * The number of assertions since process start. */