summaryrefslogtreecommitdiff
path: root/test/abort/test-abort-backtrace.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-05-16 15:41:37 -0400
committerBen Noordhuis <info@bnoordhuis.nl>2016-06-29 13:50:22 +0200
commit64edd064b880ff8ce3bcc85d68e0100c8d987fa0 (patch)
tree5faeca63f06a5552a4481288a576b23a679740ac /test/abort/test-abort-backtrace.js
parente574f5b7008e43009a365b5535f49d39fcc020f5 (diff)
downloadandroid-node-v8-64edd064b880ff8ce3bcc85d68e0100c8d987fa0.tar.gz
android-node-v8-64edd064b880ff8ce3bcc85d68e0100c8d987fa0.tar.bz2
android-node-v8-64edd064b880ff8ce3bcc85d68e0100c8d987fa0.zip
test: add abort test for backtrace validation
This commit adds a test that validates backtraces which are printed on fatal errors. PR-URL: https://github.com/nodejs/node/pull/6734 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/abort/test-abort-backtrace.js')
-rw-r--r--test/abort/test-abort-backtrace.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/abort/test-abort-backtrace.js b/test/abort/test-abort-backtrace.js
new file mode 100644
index 0000000000..7f72ee8e71
--- /dev/null
+++ b/test/abort/test-abort-backtrace.js
@@ -0,0 +1,24 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const cp = require('child_process');
+
+if (common.isWindows) {
+ common.skip('Backtraces unimplemented on Windows.');
+ return;
+}
+
+if (process.argv[2] === 'child') {
+ process.abort();
+} else {
+ const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
+ const frames =
+ child.stderr.toString().trimRight().split('\n').map((s) => s.trim());
+
+ assert.strictEqual(child.stdout.toString(), '');
+ assert.ok(frames.length > 0);
+ // All frames should start with a frame number.
+ assert.ok(frames.every((frame, index) => frame.startsWith(`${index + 1}:`)));
+ // At least some of the frames should include the binary name.
+ assert.ok(frames.some((frame) => frame.includes(`[${process.execPath}]`)));
+}