Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormisterpoe <raymondksi@gmail.com>2016-08-06 00:04:25 +0300
committerItalo A. Casas <me@italoacasas.com>2017-03-01 03:22:19 +0300
commitbd4ccc892c0413439c3d068485cbfb49ea78b842 (patch)
treedbcdd1c827f2232072189258884a5d288ce4322d /test
parent1c7f221ef5bc5a531d52cbea1706c5581fba1e4a (diff)
src: add tracing controller
This commit adds support for trace-event tracing to Node.js. It provides a mechanism to centralize tracing information generated by V8, Node core, and userspace code. It includes: - A trace writer responsible for serializing traces and cycling the output files so that no individual file becomes to large. - A buffer for aggregating traces to allow for batched flushes. - An agent which initializes the tracing controller and ensures that trace serialization is done on a separate thread. - A set of macros for generating trace events. - Tests and documentation. Author: Raymond Kang <raymondksi@gmail.com> Author: Kelvin Jin <kelvinjin@google.com> Author: Matthew Loring <mattloring@google.com> Author: Jason Ginchereau <jasongin@microsoft.com> PR-URL: https://github.com/nodejs/node/pull/11106 Reviewed-By: Josh Gavant <josh.gavant@outlook.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-trace-event.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/parallel/test-trace-event.js b/test/parallel/test-trace-event.js
new file mode 100644
index 00000000000..18734705834
--- /dev/null
+++ b/test/parallel/test-trace-event.js
@@ -0,0 +1,35 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const cp = require('child_process');
+const fs = require('fs');
+
+const CODE = 'for (var i = 0; i < 100000; i++) { "test" + i }';
+const FILE_NAME = 'node_trace.1.log';
+
+common.refreshTmpDir();
+process.chdir(common.tmpDir);
+
+const proc_no_categories = cp.spawn(process.execPath,
+ [ '--trace-events-enabled', '--trace-event-categories', '""', '-e', CODE ]);
+
+proc_no_categories.once('exit', common.mustCall(() => {
+ assert(!common.fileExists(FILE_NAME));
+
+ const proc = cp.spawn(process.execPath,
+ [ '--trace-events-enabled', '-e', CODE ]);
+
+ proc.once('exit', common.mustCall(() => {
+ assert(common.fileExists(FILE_NAME));
+ fs.readFile(FILE_NAME, (err, data) => {
+ const traces = JSON.parse(data.toString()).traceEvents;
+ assert(traces.length > 0);
+ // Values that should be present on all runs to approximate correctness.
+ assert(traces.some((trace) => { return trace.pid === proc.pid; }));
+ assert(traces.some((trace) => { return trace.cat === 'v8'; }));
+ assert(traces.some((trace) => {
+ return trace.name === 'V8.ScriptCompiler';
+ }));
+ });
+ }));
+}));