Add test-child-process-fork-exec-path.js and test-child-process-fork-net2.js

Reviewed-by: asquare
This commit is contained in:
Kinsley Wong 2014-01-08 18:06:49 -08:00
parent 4262128dba
commit 01615930dd
4 changed files with 62 additions and 0 deletions

View File

@ -282,6 +282,8 @@
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-chdir.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-child-process-fork-dgram.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-child-process-fork-exec-argv.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-child-process-fork-exec-path.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-child-process-fork-net2.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-cluster-http-pipe.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-dgram-address.js"/>
<apply-diff src="test/simple" mod="${test.dir}/simple" name="test-dgram-broadcast-multi-process.js"/>
@ -374,6 +376,8 @@
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-chdir.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-child-process-fork-dgram.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-child-process-fork-exec-argv.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-child-process-fork-exec-path.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-child-process-fork-net2.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-cluster-http-pipe.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-dgram-address.js"/>
<apply-patch-file target="${test.dir}/simple" dir="test/simple" name="test-dgram-broadcast-multi-process.js"/>

View File

@ -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) {

View File

@ -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');
});
}

View File

@ -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 \