2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2011-10-13 21:36:28 +08:00
|
|
|
// Original test written by Jakub Lekstan <kuebzky@gmail.com>
|
|
|
|
|
|
|
|
// FIXME add sunos support
|
2013-02-24 11:06:14 +08:00
|
|
|
if ('linux freebsd darwin'.indexOf(process.platform) === -1) {
|
2012-01-18 02:43:34 +08:00
|
|
|
console.error('Skipping test, platform not supported.');
|
2011-10-13 21:36:28 +08:00
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
|
2012-02-20 20:22:12 +08:00
|
|
|
var common = require('../common');
|
2011-10-13 21:36:28 +08:00
|
|
|
var assert = require('assert');
|
|
|
|
var exec = require('child_process').exec;
|
|
|
|
|
2013-07-25 18:24:40 +08:00
|
|
|
// The title shouldn't be too long; libuv's uv_set_process_title() out of
|
|
|
|
// security considerations no longer overwrites envp, only argv, so the
|
|
|
|
// maximum title length is possibly quite short.
|
|
|
|
var title = 'testme';
|
2011-10-13 21:36:28 +08:00
|
|
|
|
|
|
|
assert.notEqual(process.title, title);
|
|
|
|
process.title = title;
|
|
|
|
assert.equal(process.title, title);
|
|
|
|
|
|
|
|
exec('ps -p ' + process.pid + ' -o args=', function(error, stdout, stderr) {
|
|
|
|
assert.equal(error, null);
|
|
|
|
assert.equal(stderr, '');
|
2012-12-03 10:08:17 +08:00
|
|
|
|
|
|
|
// freebsd always add ' (procname)' to the process title
|
2015-01-13 21:28:56 +08:00
|
|
|
if (process.platform === 'freebsd') title += ' (iojs)';
|
2012-12-03 10:08:17 +08:00
|
|
|
|
2011-10-15 08:05:33 +08:00
|
|
|
// omitting trailing whitespace and \n
|
|
|
|
assert.equal(stdout.replace(/\s+$/, ''), title);
|
2011-10-13 21:36:28 +08:00
|
|
|
});
|