1'use strict';
2
3// This tests that --cpu-prof-name can be used to specify the
4// name of the generated CPU profile.
5
6const common = require('../common');
7const fixtures = require('../common/fixtures');
8common.skipIfInspectorDisabled();
9
10const assert = require('assert');
11const path = require('path');
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// --cpu-prof-name
23{
24  tmpdir.refresh();
25  const file = path.join(tmpdir.path, 'test.cpuprofile');
26  const output = spawnSync(process.execPath, [
27    '--cpu-prof',
28    '--cpu-prof-interval',
29    kCpuProfInterval,
30    '--cpu-prof-name',
31    'test.cpuprofile',
32    fixtures.path('workload', 'fibonacci.js'),
33  ], {
34    cwd: tmpdir.path,
35    env
36  });
37  if (output.status !== 0) {
38    console.log(output.stderr.toString());
39  }
40  assert.strictEqual(output.status, 0);
41  const profiles = getCpuProfiles(tmpdir.path);
42  assert.deepStrictEqual(profiles, [file]);
43  verifyFrames(output, file, 'fibonacci.js');
44}
45