Bug 1306329 part B - Remove a few crashreporter tests which can no longer be implemented without linking to internal symbols. r=ted draft
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 11 Nov 2016 12:57:09 -0500
changeset 447528 d4dcfe752b3b6ae69b677704afa265a3b41119a9
parent 447527 d32e3567f027fa27e895ed51213489df1afd9aa7
child 447529 9900e939a1078a6ad39312bbe3dfc758aa488ac8
push id38073
push userbsmedberg@mozilla.com
push dateMon, 05 Dec 2016 20:27:48 +0000
reviewersted
bugs1306329
milestone53.0a1
Bug 1306329 part B - Remove a few crashreporter tests which can no longer be implemented without linking to internal symbols. r=ted MozReview-Commit-ID: ChP1nRo2alE
toolkit/crashreporter/test/CrashTestUtils.jsm
toolkit/crashreporter/test/nsTestCrasher.cpp
toolkit/crashreporter/test/unit/test_crash_runtimeabort.js
toolkit/crashreporter/test/unit/test_crashreporter_crash_profile_lock.js
toolkit/crashreporter/test/unit/test_event_files.js
toolkit/crashreporter/test/unit/xpcshell.ini
toolkit/crashreporter/test/unit_ipc/test_content_annotation.js
--- a/toolkit/crashreporter/test/CrashTestUtils.jsm
+++ b/toolkit/crashreporter/test/CrashTestUtils.jsm
@@ -1,17 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 this.EXPORTED_SYMBOLS = ["CrashTestUtils"];
 
 this.CrashTestUtils = {
   // These will be defined using ctypes APIs below.
   crash: null,
-  lockDir: null,
   dumpHasStream: null,
   dumpHasInstructionPointerMemory: null,
 
   // Constants for crash()
   // Keep these in sync with nsTestCrasher.cpp!
   CRASH_INVALID_POINTER_DEREF: 0,
   CRASH_PURE_VIRTUAL_CALL:     1,
   CRASH_RUNTIMEABORT:          2,
@@ -36,22 +35,16 @@ var lib = ctypes.open(file.path);
 CrashTestUtils.crash = lib.declare("Crash",
                                    ctypes.default_abi,
                                    ctypes.void_t,
                                    ctypes.int16_t);
 CrashTestUtils.saveAppMemory = lib.declare("SaveAppMemory",
                                            ctypes.default_abi,
                                            ctypes.uint64_t);
 
-CrashTestUtils.lockDir = lib.declare("LockDir",
-                                     ctypes.default_abi,
-                                     ctypes.voidptr_t,   // nsILocalFile*
-                                     ctypes.voidptr_t);  // nsISupports*
-
-
 try {
   CrashTestUtils.TryOverrideExceptionHandler = lib.declare("TryOverrideExceptionHandler",
                                                            ctypes.default_abi,
                                                            ctypes.void_t);
 }
 catch (ex) {}
 
 CrashTestUtils.dumpHasStream = lib.declare("DumpHasStream",
--- a/toolkit/crashreporter/test/nsTestCrasher.cpp
+++ b/toolkit/crashreporter/test/nsTestCrasher.cpp
@@ -1,14 +1,13 @@
 #include "mozilla/Assertions.h"
 
 #include <stdio.h>
 
 #include "nscore.h"
-#include "nsXULAppAPI.h"
 #include "nsExceptionHandler.h"
 #include "mozilla/Unused.h"
 
 /*
  * This pure virtual call example is from MSDN
  */
 class A;
 
@@ -38,17 +37,16 @@ void PureVirtualCall()
   // generates a pure virtual function call
   B b;
   b.use(); // make sure b's actually used
 }
 
 // Keep these in sync with CrashTestUtils.jsm!
 const int16_t CRASH_INVALID_POINTER_DEREF = 0;
 const int16_t CRASH_PURE_VIRTUAL_CALL     = 1;
-const int16_t CRASH_RUNTIMEABORT          = 2;
 const int16_t CRASH_OOM                   = 3;
 const int16_t CRASH_MOZ_CRASH             = 4;
 const int16_t CRASH_ABORT                 = 5;
 
 extern "C" NS_EXPORT
 void Crash(int16_t how)
 {
   switch (how) {
@@ -58,20 +56,16 @@ void Crash(int16_t how)
     // not reached
     break;
   }
   case CRASH_PURE_VIRTUAL_CALL: {
     PureVirtualCall();
     // not reached
     break;
   }
-  case CRASH_RUNTIMEABORT: {
-    NS_RUNTIMEABORT("Intentional crash");
-    break;
-  }
   case CRASH_OOM: {
     mozilla::Unused << moz_xmalloc((size_t) -1);
     mozilla::Unused << moz_xmalloc((size_t) -1);
     mozilla::Unused << moz_xmalloc((size_t) -1);
     break;
   }
   case CRASH_MOZ_CRASH: {
     MOZ_CRASH();
@@ -81,24 +75,16 @@ void Crash(int16_t how)
     abort();
     break;
   }
   default:
     break;
   }
 }
 
-extern "C" NS_EXPORT
-nsISupports* LockDir(nsIFile *directory)
-{
-  nsISupports* lockfile = nullptr;
-  XRE_LockProfileDirectory(directory, &lockfile);
-  return lockfile;
-}
-
 char testData[32];
 
 extern "C" NS_EXPORT
 uint64_t SaveAppMemory()
 {
   for (size_t i=0; i<sizeof(testData); i++)
     testData[i] = i;
 
deleted file mode 100644
--- a/toolkit/crashreporter/test/unit/test_crash_runtimeabort.js
+++ /dev/null
@@ -1,21 +0,0 @@
-function run_test()
-{
-  if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
-    dump("INFO | test_crash_runtimeabort.js | Can't test crashreporter in a non-libxul build.\n");
-    return;
-  }
-
-  // Try crashing with a runtime abort
-  do_crash(function() {
-             crashType = CrashTestUtils.CRASH_RUNTIMEABORT;
-             crashReporter.annotateCrashReport("TestKey", "TestValue");
-           },
-           function(mdump, extra) {
-             do_check_eq(extra.TestKey, "TestValue");
-             do_check_true(/xpcom_runtime_abort/.test(extra.Notes));
-             do_check_false("OOMAllocationSize" in extra);
-             do_check_true(/Intentional crash/.test(extra.AbortMessage));
-           },
-          // process will exit with a zero exit status
-          true);
-}
deleted file mode 100644
--- a/toolkit/crashreporter/test/unit/test_crashreporter_crash_profile_lock.js
+++ /dev/null
@@ -1,26 +0,0 @@
-function run_test()
-{
-  if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
-    dump("INFO | test_crashreporter.js | Can't test crashreporter in a non-libxul build.\n");
-    return;
-  }
-
-  // lock a profile directory, crash, and ensure that
-  // the profile lock signal handler doesn't interfere with
-  // writing a minidump
-  do_crash(function() {
-             let env = Components.classes["@mozilla.org/process/environment;1"]
-               .getService(Components.interfaces.nsIEnvironment);
-             // the python harness sets this in the environment for us
-             let profd = env.get("XPCSHELL_TEST_PROFILE_DIR");
-             let dir = Components.classes["@mozilla.org/file/local;1"]
-               .createInstance(Components.interfaces.nsILocalFile);
-             dir.initWithPath(profd);
-             let lock = CrashTestUtils.lockDir(dir);
-             // when we crash, the lock file should be cleaned up
-           },
-           function(mdump, extra) {
-             // if we got here, we have a minidump, so that's all we wanted
-             do_check_true(true);
-           });
-}
--- a/toolkit/crashreporter/test/unit/test_event_files.js
+++ b/toolkit/crashreporter/test/unit/test_event_files.js
@@ -25,17 +25,17 @@ add_task(function* test_main_process_cra
   let basename;
   let deferred = Promise.defer();
   do_crash(
     function() {
       // TelemetrySession setup will trigger the session annotation
       let scope = {};
       Components.utils.import("resource://gre/modules/TelemetryController.jsm", scope);
       scope.TelemetryController.testSetup();
-      crashType = CrashTestUtils.CRASH_RUNTIMEABORT;
+      crashType = CrashTestUtils.CRASH_MOZ_CRASH;
       crashReporter.annotateCrashReport("ShutdownProgress", "event-test");
     },
     (minidump, extra) => {
       basename = minidump.leafName;
       cm._eventsDirs = [getEventDir()];
       cm.aggregateEventsFiles().then(deferred.resolve, deferred.reject);
     },
     true);
--- a/toolkit/crashreporter/test/unit/xpcshell.ini
+++ b/toolkit/crashreporter/test/unit/xpcshell.ini
@@ -3,33 +3,31 @@ head = head_crashreporter.js
 tail =
 skip-if = toolkit == 'android'
 support-files =
   crasher_subprocess_head.js
   crasher_subprocess_tail.js
 
 [test_crash_moz_crash.js]
 [test_crash_purevirtual.js]
-[test_crash_runtimeabort.js]
 [test_crash_after_js_oom_reported.js]
 [test_crash_after_js_oom_recovered.js]
 [test_crash_after_js_oom_reported_2.js]
 [test_crash_after_js_large_allocation_failure.js]
 [test_crash_after_js_large_allocation_failure_reporting.js]
 [test_crash_oom.js]
 [test_oom_annotation_windows.js]
 skip-if = os != 'win'
 
 [test_crash_abort.js]
 skip-if = os == 'win'
 
 [test_crash_with_memory_report.js]
 [test_crashreporter.js]
 [test_crashreporter_crash.js]
-[test_crashreporter_crash_profile_lock.js]
 [test_override_exception_handler.js]
 skip-if = os != 'win'
 
 [test_crashreporter_appmem.js]
 # we need to skip this due to bug 838613
 skip-if = (os != 'win' && os != 'linux') || (os=='linux' && bits==32)
 
 [test_crash_AsyncShutdown.js]
--- a/toolkit/crashreporter/test/unit_ipc/test_content_annotation.js
+++ b/toolkit/crashreporter/test/unit_ipc/test_content_annotation.js
@@ -4,17 +4,17 @@ function run_test()
 {
   if (!("@mozilla.org/toolkit/crash-reporter;1" in Components.classes)) {
     dump("INFO | test_content_annotation.js | Can't test crashreporter in a non-libxul build.\n");
     return;
   }
 
   // Try crashing with a runtime abort
   do_content_crash(function() {
-                     crashType = CrashTestUtils.CRASH_RUNTIMEABORT;
+                     crashType = CrashTestUtils.CRASH_MOZ_CRASH;
                      crashReporter.annotateCrashReport("TestKey", "TestValue");
                      crashReporter.appendAppNotesToCrashReport("!!!foo!!!");
                    },
                    function(mdump, extra) {
                      do_check_eq(extra.TestKey, "TestValue");
                      do_check_true('StartupTime' in extra);
                      do_check_true('ProcessType' in extra);
                      do_check_neq(extra.Notes.indexOf("!!!foo!!!"), -1);