semi-reliable test case for dtrace support
This commit is contained in:
parent
8732764c67
commit
bac8a57663
4 changed files with 38 additions and 27 deletions
35
Makefile
35
Makefile
|
@ -2,6 +2,14 @@
|
||||||
#---- Tools
|
#---- Tools
|
||||||
|
|
||||||
TAP := ./node_modules/.bin/tap
|
TAP := ./node_modules/.bin/tap
|
||||||
|
SUDO := sudo
|
||||||
|
ifeq ($(shell uname -s),SunOS)
|
||||||
|
# On SunOS (e.g. SmartOS) we expect to run the test suite as the
|
||||||
|
# root user -- necessary to run dtrace. Therefore `pfexec` isn't
|
||||||
|
# necessary.
|
||||||
|
SUDO :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---- Files
|
#---- Files
|
||||||
|
@ -50,12 +58,19 @@ publish:
|
||||||
&& git commit -a -m "publish latest docs" \
|
&& git commit -a -m "publish latest docs" \
|
||||||
&& git push origin gh-pages || true)
|
&& git push origin gh-pages || true)
|
||||||
|
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
rm -rf node_modules
|
||||||
|
|
||||||
|
|
||||||
#---- test
|
#---- test
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: $(TAP)
|
test: $(TAP)
|
||||||
TAP=1 $(TAP) $(TEST_FILES)
|
[[ -n "$(SKIP_DTRACE)" ]] || \
|
||||||
[[ -n "$(SKIP_DTRACE)" ]] || sudo TAP=1 $(TAP) test/dtrace.test.js
|
node -e 'require("trentm-dtrace-provider").createDTraceProvider("isthisthingon")' && \
|
||||||
|
$(SUDO) $(TAP) --tap test/dtrace.test.js
|
||||||
|
$(TAP) --tap $(TEST_FILES)
|
||||||
|
|
||||||
# Test will all node supported versions (presumes install locations I use on
|
# Test will all node supported versions (presumes install locations I use on
|
||||||
# my machine).
|
# my machine).
|
||||||
|
@ -67,25 +82,15 @@ testall: test06 test09 test08
|
||||||
.PHONY: test09
|
.PHONY: test09
|
||||||
test09:
|
test09:
|
||||||
@echo "# Test node 0.9.x (with node `$(HOME)/opt/node-0.9/bin/node --version`)"
|
@echo "# Test node 0.9.x (with node `$(HOME)/opt/node-0.9/bin/node --version`)"
|
||||||
[[ -n "$(SKIP_DTRACE)" ]] \
|
PATH="$(HOME)/opt/node-0.9/bin:$(PATH)" make distclean all test
|
||||||
|| PATH="$(HOME)/opt/node-0.9/bin:$(PATH)" npm rebuild dtrace-provider \
|
|
||||||
&& sudo PATH="$(HOME)/opt/node-0.9/bin:$(PATH)" TAP=1 $(TAP) test/dtrace.test.js
|
|
||||||
PATH="$(HOME)/opt/node-0.9/bin:$(PATH)" TAP=1 $(TAP) $(TEST_FILES)
|
|
||||||
.PHONY: test08
|
.PHONY: test08
|
||||||
test08:
|
test08:
|
||||||
@echo "# Test node 0.8.x (with node `$(HOME)/opt/node-0.8/bin/node --version`)"
|
@echo "# Test node 0.8.x (with node `$(HOME)/opt/node-0.8/bin/node --version`)"
|
||||||
[[ -n "$(SKIP_DTRACE)" ]] \
|
PATH="$(HOME)/opt/node-0.8/bin:$(PATH)" make distclean all test
|
||||||
|| PATH="$(HOME)/opt/node-0.8/bin:$(PATH)" npm rebuild dtrace-provider \
|
|
||||||
&& sudo PATH="$(HOME)/opt/node-0.8/bin:$(PATH)" TAP=1 $(TAP) test/dtrace.test.js
|
|
||||||
PATH="$(HOME)/opt/node-0.8/bin:$(PATH)" TAP=1 $(TAP) $(TEST_FILES)
|
|
||||||
.PHONY: test06
|
.PHONY: test06
|
||||||
test06:
|
test06:
|
||||||
@echo "# Test node 0.6.x (with node `$(HOME)/opt/node-0.6/bin/node --version`)"
|
@echo "# Test node 0.6.x (with node `$(HOME)/opt/node-0.6/bin/node --version`)"
|
||||||
[[ -n "$(SKIP_DTRACE)" ]] \
|
PATH="$(HOME)/opt/node-0.6/bin:$(PATH)" make distclean all test
|
||||||
|| PATH="$(HOME)/opt/node-0.6/bin:$(PATH)" npm rebuild dtrace-provider \
|
|
||||||
&& sudo PATH="$(HOME)/opt/node-0.6/bin:$(PATH)" TAP=1 $(TAP) test/dtrace.test.js
|
|
||||||
PATH="$(HOME)/opt/node-0.6/bin:$(PATH)" TAP=1 $(TAP) $(TEST_FILES)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---- check
|
#---- check
|
||||||
|
|
|
@ -26,7 +26,7 @@ var fs = require('fs');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
try {
|
try {
|
||||||
var dtrace = require('dtrace-provider');
|
var dtrace = require('trentm-dtrace-provider');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dtrace = null;
|
dtrace = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"keywords": ["log", "logging", "log4j", "json"],
|
"keywords": ["log", "logging", "log4j", "json"],
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dtrace-provider": "0.2.3"
|
"trentm-dtrace-provider": "0.2.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tap": "0.2.0",
|
"tap": "0.2.0",
|
||||||
|
|
|
@ -15,9 +15,9 @@ var bunyan = require('../lib/bunyan');
|
||||||
var dtracePlats = ['sunos', 'darwin', 'freebsd'];
|
var dtracePlats = ['sunos', 'darwin', 'freebsd'];
|
||||||
var runDtraceTests = true;
|
var runDtraceTests = true;
|
||||||
try {
|
try {
|
||||||
require('dtrace-provider')
|
require('trentm-dtrace-provider')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('# skip dtrace tests: no dtrace-provider module');
|
console.log('# skip dtrace tests: no trentm-dtrace-provider module');
|
||||||
runDtraceTests = false;
|
runDtraceTests = false;
|
||||||
}
|
}
|
||||||
if (!runDtraceTests) {
|
if (!runDtraceTests) {
|
||||||
|
@ -40,10 +40,13 @@ test('basic', function (t) {
|
||||||
|
|
||||||
// Should be '%%s' in that `format` frankly, but node *0.6* doesn't see
|
// Should be '%%s' in that `format` frankly, but node *0.6* doesn't see
|
||||||
// it that way. Node *0.8* has fixed '%%' handling.
|
// it that way. Node *0.8* has fixed '%%' handling.
|
||||||
var dtrace = spawn('dtrace', ['-x', 'strsize=4k', '-qn',
|
var argv = ['dtrace', '-x', 'strsize=4k', '-qn',
|
||||||
format('bunyan%d:::log-*{printf("%s", copyinstr(arg0))}', process.pid)]);
|
format('bunyan%d:::log-*{printf("%s", copyinstr(arg0))}', process.pid)];
|
||||||
|
var dtrace = spawn(argv[0], argv.slice(1));
|
||||||
|
//console.error("ARGV: %j", argv);
|
||||||
var traces = [];
|
var traces = [];
|
||||||
dtrace.stdout.on('data', function (data) {
|
dtrace.stdout.on('data', function (data) {
|
||||||
|
//console.error("STDOUT:", data.toString());
|
||||||
traces.push(data.toString());
|
traces.push(data.toString());
|
||||||
});
|
});
|
||||||
dtrace.stderr.on('data', function (data) {
|
dtrace.stderr.on('data', function (data) {
|
||||||
|
@ -51,7 +54,7 @@ test('basic', function (t) {
|
||||||
});
|
});
|
||||||
dtrace.on('exit', function (code) {
|
dtrace.on('exit', function (code) {
|
||||||
if (code) {
|
if (code) {
|
||||||
console.log("dtrace exited non-zero:", code);
|
console.log("# error: dtrace exited non-zero:", code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,13 +68,16 @@ test('basic', function (t) {
|
||||||
traces = traces.join('').split('\n')
|
traces = traces.join('').split('\n')
|
||||||
.filter(function (t) { return t.trim().length })
|
.filter(function (t) { return t.trim().length })
|
||||||
.map(function (t) { return JSON.parse(t) });
|
.map(function (t) { return JSON.parse(t) });
|
||||||
t.equal(traces.length, 2);
|
t.equal(traces.length, 2,
|
||||||
|
"(If this fails, it is often a timing issue. Please try again.)");
|
||||||
|
if (traces.length) {
|
||||||
t.equal(traces[0].pid, process.pid);
|
t.equal(traces[0].pid, process.pid);
|
||||||
t.equal(traces[0].level, bunyan.DEBUG);
|
t.equal(traces[0].level, bunyan.DEBUG);
|
||||||
t.equal(traces[1].basic, true);
|
t.equal(traces[1].basic, true);
|
||||||
|
}
|
||||||
t.end();
|
t.end();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 1000); // Give dtrace some time to startup. How much?
|
}, 3000); // Give dtrace some time to startup. How much?
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue