Test arguments with spaces and quotes in nsIProcess. r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 23 Jun 2009 11:33:41 +0100
changeset 29472 28aa23105a9e238ce28fc7bbbdb5fccc27db325b
parent 29471 c575412d976a43a4b9f5fe63606c6413e910fa0a
child 29473 96af546571024697232b1e09495be823b55d8f53
push id7651
push userdtownsend@mozilla.com
push dateTue, 23 Jun 2009 10:34:00 +0000
treeherdermozilla-central@28aa23105a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobstrong
milestone1.9.2a1pre
Test arguments with spaces and quotes in nsIProcess. r=robstrong
xpcom/tests/TestArguments.cpp
xpcom/tests/unit/test_nsIProcess.js
--- a/xpcom/tests/TestArguments.cpp
+++ b/xpcom/tests/TestArguments.cpp
@@ -1,21 +1,25 @@
 #include <string.h>
 
 int main(int argc, char* argv[]) {
-  if (argc != 7)
+  if (argc != 9)
       return -1;
 
   if (strcmp("mozilla", argv[1]) != 0)
       return 1;
   if (strcmp("firefox", argv[2]) != 0)
       return 2;
   if (strcmp("thunderbird", argv[3]) != 0)
       return 3;
   if (strcmp("seamonkey", argv[4]) != 0)
       return 4;
   if (strcmp("foo", argv[5]) != 0)
       return 5;
   if (strcmp("bar", argv[6]) != 0)
       return 6;
+  if (strcmp("argument with spaces", argv[7]) != 0)
+      return 7;
+  if (strcmp("\"argument with quotes\"", argv[8]) != 0)
+      return 8;
   
   return 0;
 } 
--- a/xpcom/tests/unit/test_nsIProcess.js
+++ b/xpcom/tests/unit/test_nsIProcess.js
@@ -29,16 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 // nsIProcess unit test
+const TEST_ARGS = ["mozilla", "firefox", "thunderbird", "seamonkey", "foo",
+                   "bar", "argument with spaces", "\"argument with quotes\""];
 
 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)
@@ -115,19 +117,17 @@ function test_quick()
 function test_arguments()
 {
   var file = get_test_program("TestArguments");
   
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
   process.init(file);
   
-  var args= ["mozilla", "firefox", "thunderbird", "seamonkey", "foo", "bar"];
-  
-  process.run(true, args, args.length);
+  process.run(true, TEST_ARGS, TEST_ARGS.length);
   
   do_check_eq(process.exitValue, 0);
 }
 
 // test if we get notified about a blocking process
 function test_notify_blocking()
 {
   var file = get_test_program("TestQuickReturn");
@@ -150,17 +150,17 @@ function test_notify_blocking()
 function test_notify_nonblocking()
 {
   var file = get_test_program("TestArguments");
 
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
   process.init(file);
 
-  process.runAsync(["mozilla", "firefox", "thunderbird", "seamonkey", "foo", "bar"], 6, {
+  process.runAsync(TEST_ARGS, TEST_ARGS.length, {
     observe: function(subject, topic, data) {
       process = subject.QueryInterface(Components.interfaces.nsIProcess);
       do_check_eq(topic, "process-finished");
       do_check_eq(process.exitValue, 0);
       test_notify_killed();
     }
   });
 }