2010-07-16 02:47:25 +08:00
|
|
|
common = require("../common");
|
|
|
|
assert = common.assert
|
2010-03-18 05:00:17 +08:00
|
|
|
var exec = require('child_process').exec;
|
2009-09-15 21:42:16 +08:00
|
|
|
success_count = 0;
|
|
|
|
error_count = 0;
|
|
|
|
|
2010-02-20 08:55:46 +08:00
|
|
|
exec("ls /", function (err, stdout, stderr) {
|
|
|
|
if (err) {
|
|
|
|
error_count++;
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("error!: " + err.code);
|
|
|
|
console.log("stdout: " + JSON.stringify(stdout));
|
|
|
|
console.log("stderr: " + JSON.stringify(stderr));
|
2010-04-15 02:59:24 +08:00
|
|
|
assert.equal(false, err.killed);
|
2010-02-20 08:55:46 +08:00
|
|
|
} else {
|
|
|
|
success_count++;
|
2010-10-12 07:09:02 +08:00
|
|
|
console.dir(stdout);
|
2010-02-20 08:55:46 +08:00
|
|
|
}
|
2009-09-15 21:42:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-02-20 08:55:46 +08:00
|
|
|
exec("ls /DOES_NOT_EXIST", function (err, stdout, stderr) {
|
|
|
|
if (err) {
|
|
|
|
error_count++;
|
|
|
|
assert.equal("", stdout);
|
|
|
|
assert.equal(true, err.code != 0);
|
2010-04-15 02:59:24 +08:00
|
|
|
assert.equal(false, err.killed);
|
2010-04-28 21:04:08 +08:00
|
|
|
assert.strictEqual(null, err.signal);
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("error code: " + err.code);
|
|
|
|
console.log("stdout: " + JSON.stringify(stdout));
|
|
|
|
console.log("stderr: " + JSON.stringify(stderr));
|
2010-02-20 08:55:46 +08:00
|
|
|
} else {
|
|
|
|
success_count++;
|
2010-10-12 07:09:02 +08:00
|
|
|
console.dir(stdout);
|
2010-02-20 08:55:46 +08:00
|
|
|
assert.equal(true, stdout != "");
|
|
|
|
}
|
2009-09-15 21:42:16 +08:00
|
|
|
});
|
|
|
|
|
2010-04-15 02:59:24 +08:00
|
|
|
exec("sleep 10", { timeout: 50 }, function (err, stdout, stderr) {
|
|
|
|
assert.ok(err);
|
|
|
|
assert.ok(err.killed);
|
2010-04-28 21:04:08 +08:00
|
|
|
assert.equal(err.signal, 'SIGKILL');
|
2010-04-15 02:59:24 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
exec('python -c "print 200000*\'C\'"', { maxBuffer: 1000 }, function (err, stdout, stderr) {
|
|
|
|
assert.ok(err);
|
|
|
|
assert.ok(err.killed);
|
2010-04-28 21:04:08 +08:00
|
|
|
assert.equal(err.signal, 'SIGKILL');
|
2010-04-15 02:59:24 +08:00
|
|
|
});
|
2009-09-15 21:42:16 +08:00
|
|
|
|
|
|
|
process.addListener("exit", function () {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(1, success_count);
|
|
|
|
assert.equal(1, error_count);
|
2009-09-15 21:42:16 +08:00
|
|
|
});
|