mirror of
https://github.com/hanzoai/node-dtrace-provider.git
synced 2026-09-23 23:48:45 +00:00
Shell out to dtrace(1M) before checking the results of tests involving the json() subroutine.
31 lines
905 B
JavaScript
31 lines
905 B
JavaScript
var spawn = require('child_process').spawn;
|
|
|
|
exports.dtraceTest = function(setup, dtargv, test) {
|
|
return function(t) {
|
|
setup();
|
|
|
|
var dtrace = spawn('/usr/sbin/dtrace', dtargv.slice(1));
|
|
|
|
var traces = [];
|
|
var exit_code;
|
|
dtrace.stdout.on('data', function (data) {
|
|
//console.error("DTRACE STDOUT:", data.toString());
|
|
traces.push(data.toString());
|
|
});
|
|
dtrace.stderr.on('data', function (data) {
|
|
//console.error("DTRACE STDERR:", data.toString());
|
|
});
|
|
dtrace.on('exit', function (code) {
|
|
exit_code = code;
|
|
});
|
|
dtrace.on('close', function () {
|
|
traces = traces.join('').split('\n')
|
|
.filter(function (t) { return t.trim().length });
|
|
|
|
test(t, exit_code, traces);
|
|
t.end();
|
|
});
|
|
};
|
|
}
|
|
|