2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
2010-12-06 06:33:52 +08:00
|
|
|
var assert = require('assert');
|
2010-03-18 05:00:17 +08:00
|
|
|
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
var SIZE = 1000 * 1024;
|
|
|
|
var N = 40;
|
|
|
|
var finished = false;
|
|
|
|
|
2010-12-03 09:03:18 +08:00
|
|
|
function doSpawn(i) {
|
|
|
|
var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
|
2010-03-18 05:00:17 +08:00
|
|
|
var count = 0;
|
|
|
|
|
|
|
|
child.stdout.setEncoding('ascii');
|
2011-10-15 07:08:36 +08:00
|
|
|
child.stdout.on('data', function(chunk) {
|
2010-03-18 05:00:17 +08:00
|
|
|
count += chunk.length;
|
|
|
|
});
|
|
|
|
|
2011-10-15 07:08:36 +08:00
|
|
|
child.stderr.on('data', function(chunk) {
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log('stderr: ' + chunk);
|
2010-03-18 05:00:17 +08:00
|
|
|
});
|
|
|
|
|
2012-06-14 04:10:59 +08:00
|
|
|
child.on('close', function() {
|
2011-10-29 09:30:03 +08:00
|
|
|
// + 1 for \n or + 2 for \r\n on Windows
|
2015-07-29 19:48:04 +08:00
|
|
|
assert.equal(SIZE + (common.isWindows ? 2 : 1), count);
|
2010-03-18 05:00:17 +08:00
|
|
|
if (i < N) {
|
2010-12-03 09:03:18 +08:00
|
|
|
doSpawn(i + 1);
|
2010-03-18 05:00:17 +08:00
|
|
|
} else {
|
|
|
|
finished = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doSpawn(0);
|
|
|
|
|
2011-10-15 07:08:36 +08:00
|
|
|
process.on('exit', function() {
|
2010-03-18 05:00:17 +08:00
|
|
|
assert.ok(finished);
|
|
|
|
});
|