2010-12-05 00:20:34 +01:00
|
|
|
var common = require('../common');
|
2010-12-05 23:33:52 +01:00
|
|
|
var assert = require('assert');
|
2010-03-17 22:00:17 +01:00
|
|
|
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
var SIZE = 1000 * 1024;
|
|
|
|
var N = 40;
|
|
|
|
var finished = false;
|
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
function doSpawn(i) {
|
|
|
|
var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
|
2010-03-17 22:00:17 +01:00
|
|
|
var count = 0;
|
|
|
|
|
|
|
|
child.stdout.setEncoding('ascii');
|
2010-12-03 02:03:18 +01:00
|
|
|
child.stdout.addListener('data', function(chunk) {
|
2010-03-17 22:00:17 +01:00
|
|
|
count += chunk.length;
|
|
|
|
});
|
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
child.stderr.addListener('data', function(chunk) {
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log('stderr: ' + chunk);
|
2010-03-17 22:00:17 +01:00
|
|
|
});
|
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
child.addListener('exit', function() {
|
2010-03-17 22:00:17 +01:00
|
|
|
assert.equal(SIZE + 1, count); // + 1 for \n
|
|
|
|
if (i < N) {
|
2010-12-03 02:03:18 +01:00
|
|
|
doSpawn(i + 1);
|
2010-03-17 22:00:17 +01:00
|
|
|
} else {
|
|
|
|
finished = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doSpawn(0);
|
|
|
|
|
2010-12-03 02:03:18 +01:00
|
|
|
process.addListener('exit', function() {
|
2010-03-17 22:00:17 +01:00
|
|
|
assert.ok(finished);
|
|
|
|
});
|