1'use strict'; 2 3// This tests that --cpu-prof generates CPU profile when event 4// loop is drained. 5// TODO(joyeecheung): share the fixtures with v8 coverage tests 6 7const common = require('../common'); 8const fixtures = require('../common/fixtures'); 9common.skipIfInspectorDisabled(); 10 11const assert = require('assert'); 12const { spawnSync } = require('child_process'); 13 14const tmpdir = require('../common/tmpdir'); 15const { 16 getCpuProfiles, 17 kCpuProfInterval, 18 env, 19 verifyFrames 20} = require('../common/cpu-prof'); 21 22{ 23 tmpdir.refresh(); 24 const output = spawnSync(process.execPath, [ 25 '--cpu-prof', 26 '--cpu-prof-interval', 27 kCpuProfInterval, 28 fixtures.path('workload', 'fibonacci.js'), 29 ], { 30 cwd: tmpdir.path, 31 env 32 }); 33 if (output.status !== 0) { 34 console.log(output.stderr.toString()); 35 } 36 assert.strictEqual(output.status, 0); 37 const profiles = getCpuProfiles(tmpdir.path); 38 assert.strictEqual(profiles.length, 1); 39 verifyFrames(output, profiles[0], 'fibonacci.js'); 40} 41