Bug 676412 - Skip process stress test on windows, to make test faster. r=bsmedberg, a=testonly
authorWilliam Lachance <wlachance@mozilla.com>
Mon, 15 Aug 2011 13:35:41 -0700
changeset 75306 bd5215405aa91a51a9ca9987b9ab619c00dba57f
parent 75305 f597467fac5e2a1f455994b20625b5bb9e4f2eb3
child 75307 a8e6a5bebe87cdea15237b872c84440c5b29a788
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersbsmedberg, testonly
bugs676412
milestone8.0a1
Bug 676412 - Skip process stress test on windows, to make test faster. r=bsmedberg, a=testonly
xpcom/tests/unit/head_xpcom.js
xpcom/tests/unit/test_nsIProcess.js
xpcom/tests/unit/test_nsIProcess_stress.js
xpcom/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/unit/head_xpcom.js
@@ -0,0 +1,25 @@
+var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
+
+function get_test_program(prog)
+{
+  var progPath = do_get_cwd();
+  progPath.append(prog);
+  if (isWindows)
+    progPath.leafName = progPath.leafName + ".exe";
+  return progPath;
+}
+
+function set_process_running_environment()
+{
+  var envSvc = Components.classes["@mozilla.org/process/environment;1"].
+    getService(Components.interfaces.nsIEnvironment);
+  var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].
+    getService(Components.interfaces.nsIProperties);
+  var greDir = dirSvc.get("GreD", Components.interfaces.nsIFile);
+
+  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
+  // For Linux
+  envSvc.set("LD_LIBRARY_PATH", greDir.path);
+  //XXX: handle windows
+}
+
--- a/xpcom/tests/unit/test_nsIProcess.js
+++ b/xpcom/tests/unit/test_nsIProcess.js
@@ -37,42 +37,16 @@
 const TEST_ARGS = ["mozilla", "firefox", "thunderbird", "seamonkey", "foo",
                    "bar", "argument with spaces", "\"argument with quotes\""];
 
 const TEST_UNICODE_ARGS = ["M\u00F8z\u00EEll\u00E5",
                            "\u041C\u043E\u0437\u0438\u043B\u043B\u0430",
                            "\u09AE\u09CB\u099C\u09BF\u09B2\u09BE",
                            "\uD808\uDE2C\uD808\uDF63\uD808\uDDB7"];
 
-var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
-
-function get_test_program(prog)
-{
-  var progPath = do_get_cwd();
-  progPath.append(prog);
-  if (isWindows)
-    progPath.leafName = progPath.leafName + ".exe";
-  return progPath;
-}
-
-function set_environment()
-{
-  var envSvc = Components.classes["@mozilla.org/process/environment;1"].
-    getService(Components.interfaces.nsIEnvironment);
-  var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].
-    getService(Components.interfaces.nsIProperties);
-  var greDir = dirSvc.get("GreD", Components.interfaces.nsIFile);
-
-  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
-  // For Linux
-  envSvc.set("LD_LIBRARY_PATH", greDir.path);
-  //XXX: handle windows
-}
-
-
 // test if a process can be started, polled for its running status
 // and then killed
 function test_kill()
 {
   var file = get_test_program("TestBlockingProcess");
  
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
@@ -226,46 +200,18 @@ function test_notify_killed()
       do_check_eq(topic, "process-finished");
       do_test_finished();
     }
   });
 
   process.kill();
 }
 
-// test if killing a process that is already finished doesn't crash
-function test_kill_2()
-{
-  var file = get_test_program("TestQuickReturn");
-  var thread = Components.classes["@mozilla.org/thread-manager;1"]
-                         .getService().currentThread;
-
-  for (var i = 0; i < 1000; i++) {
-    var process = Components.classes["@mozilla.org/process/util;1"]
-                          .createInstance(Components.interfaces.nsIProcess);
-    process.init(file);
-
-    process.run(false, [], 0);
-
-    try {
-      process.kill();
-    }
-    catch (e) { }
-
-    // We need to ensure that we process any events on the main thread -
-    // this allow threads to clean up properly and avoid out of memory
-    // errors during the test.
-    while (thread.hasPendingEvents())
-      thread.processNextEvent(false);
-  }
-}
-
 function run_test() {
-  set_environment();
+  set_process_running_environment();
   test_kill();
   test_quick();
   test_arguments();
   test_unicode_arguments();
   test_unicode_app();
   do_test_pending();
   test_notify_blocking();
-  test_kill_2();
 }
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/unit/test_nsIProcess_stress.js
@@ -0,0 +1,27 @@
+function run_test() {
+  set_process_running_environment();
+
+  var file = get_test_program("TestQuickReturn");
+  var thread = Components.classes["@mozilla.org/thread-manager;1"]
+                         .getService().currentThread;
+
+  for (var i = 0; i < 1000; i++) {
+    var process = Components.classes["@mozilla.org/process/util;1"]
+                          .createInstance(Components.interfaces.nsIProcess);
+    process.init(file);
+
+    process.run(false, [], 0);
+
+    try {
+      process.kill();
+    }
+    catch (e) { }
+
+    // We need to ensure that we process any events on the main thread -
+    // this allow threads to clean up properly and avoid out of memory
+    // errors during the test.
+    while (thread.hasPendingEvents())
+      thread.processNextEvent(false);
+  }
+
+}
\ No newline at end of file
--- a/xpcom/tests/unit/xpcshell.ini
+++ b/xpcom/tests/unit/xpcshell.ini
@@ -1,10 +1,10 @@
 [DEFAULT]
-head = 
+head = head_xpcom.js
 tail = 
 
 [test_bug121341.js]
 [test_bug332389.js]
 [test_bug333505.js]
 [test_bug364285-1.js]
 [test_bug374754.js]
 [test_bug476919.js]
@@ -16,15 +16,17 @@ tail =
 [test_hidden_files.js]
 [test_home.js]
 [test_iniProcessor.js]
 [test_ioutil.js]
 [test_localfile.js]
 [test_mac_bundle.js]
 [test_nsIMutableArray.js]
 [test_nsIProcess.js]
+[test_nsIProcess_stress.js]
+skip-if = os == "win" # See bug: 676412
 [test_pipe.js]
 [test_storagestream.js]
 [test_streams.js]
 [test_stringstream.js]
 [test_symlinks.js]
 [test_systemInfo.js]
 [test_versioncomparator.js]