From 01615930dd6060b09952059625f82820dec1c22c Mon Sep 17 00:00:00 2001 From: Kinsley Wong Date: Wed, 8 Jan 2014 18:06:49 -0800 Subject: [PATCH] Add test-child-process-fork-exec-path.js and test-child-process-fork-net2.js Reviewed-by: asquare --- build.xml | 4 +++ ...test-child-process-fork-exec-path.js.patch | 36 +++++++++++++++++++ .../test-child-process-fork-net2.js.patch | 20 +++++++++++ project.properties | 2 ++ 4 files changed, 62 insertions(+) create mode 100644 patches/test/simple/test-child-process-fork-exec-path.js.patch create mode 100644 patches/test/simple/test-child-process-fork-net2.js.patch diff --git a/build.xml b/build.xml index 68bf535..e24f8b5 100644 --- a/build.xml +++ b/build.xml @@ -282,6 +282,8 @@ + + @@ -374,6 +376,8 @@ + + diff --git a/patches/test/simple/test-child-process-fork-exec-path.js.patch b/patches/test/simple/test-child-process-fork-exec-path.js.patch new file mode 100644 index 0000000..74114a6 --- /dev/null +++ b/patches/test/simple/test-child-process-fork-exec-path.js.patch @@ -0,0 +1,36 @@ +--- ../nodejs/test/simple/test-child-process-fork-exec-path.js 2014-01-06 13:25:28.892762580 -0800 ++++ test/simple/test-child-process-fork-exec-path.js 2014-01-08 17:22:08.598482327 -0800 +@@ -26,11 +26,11 @@ + var common = require('../common'); + var msg = {test: 'this'}; + var nodePath = process.execPath; +-var copyPath = path.join(common.tmpDir, 'node-copy.exe'); ++var copyPath = path.join(common.tmpDir, 'node-copy.sh'); + + if (process.env.FORK) { + assert(process.send); +- assert.equal(process.argv[0], copyPath); ++ assert.equal(process.argv[0], fs.readFileSync(copyPath)); + process.send(msg); + process.exit(); + } +@@ -41,14 +41,17 @@ + catch (e) { + if (e.code !== 'ENOENT') throw e; + } +- fs.writeFileSync(copyPath, fs.readFileSync(nodePath)); ++ ++ // Since process.execPath is the java command-line, write the ++ // entire java command-line to copyPath and in the child read it back as the execPath ++ fs.writeFileSync(copyPath, nodePath); + fs.chmodSync(copyPath, '0755'); + + // slow but simple + var envCopy = JSON.parse(JSON.stringify(process.env)); + envCopy.FORK = 'true'; + var child = require('child_process').fork(__filename, { +- execPath: copyPath, ++ execPath: fs.readFileSync(copyPath), + env: envCopy + }); + child.on('message', common.mustCall(function(recv) { diff --git a/patches/test/simple/test-child-process-fork-net2.js.patch b/patches/test/simple/test-child-process-fork-net2.js.patch new file mode 100644 index 0000000..f5fb805 --- /dev/null +++ b/patches/test/simple/test-child-process-fork-net2.js.patch @@ -0,0 +1,20 @@ +--- ../nodejs/test/simple/test-child-process-fork-net2.js 2014-01-06 13:25:28.892762580 -0800 ++++ test/simple/test-child-process-fork-net2.js 2014-01-08 16:48:23.402463700 -0800 +@@ -161,14 +161,14 @@ + child1.send('close'); + child2.send('close'); + child3.disconnect(); +- }, 200); ++ }, 3000); + }; + + process.on('exit', function() { + assert.equal(disconnected, count); + assert.equal(connected, count); + assert.ok(closeEmitted); +- assert.ok(timeElasped >= 190 && timeElasped <= 1000, +- 'timeElasped was not between 190 and 1000 ms'); ++ assert.ok(timeElasped >= 190 && timeElasped <= 4000, ++ 'timeElasped was not between 190 and 4000 ms'); + }); + } diff --git a/project.properties b/project.properties index 533f53e..4e8d394 100644 --- a/project.properties +++ b/project.properties @@ -111,8 +111,10 @@ source.test.simple.list = \ test-child-process-fork-close.js \ test-child-process-fork-dgram.js \ test-child-process-fork-exec-argv.js \ + test-child-process-fork-exec-path.js \ test-child-process-fork-getconnections.js \ test-child-process-fork-net.js \ + test-child-process-fork-net2.js \ test-child-process-fork-ref.js \ test-child-process-fork-ref2.js \ test-child-process-fork.js \