11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// This tests that --cpu-prof generates CPU profile from worker 41cb0ef41Sopenharmony_ci// when execArgv is set. 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst common = require('../common'); 71cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 81cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst assert = require('assert'); 111cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 141cb0ef41Sopenharmony_ciconst { 151cb0ef41Sopenharmony_ci getCpuProfiles, 161cb0ef41Sopenharmony_ci kCpuProfInterval, 171cb0ef41Sopenharmony_ci verifyFrames 181cb0ef41Sopenharmony_ci} = require('../common/cpu-prof'); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci tmpdir.refresh(); 221cb0ef41Sopenharmony_ci const output = spawnSync(process.execPath, [ 231cb0ef41Sopenharmony_ci fixtures.path('workload', 'fibonacci-worker-argv.js'), 241cb0ef41Sopenharmony_ci ], { 251cb0ef41Sopenharmony_ci cwd: tmpdir.path, 261cb0ef41Sopenharmony_ci env: { 271cb0ef41Sopenharmony_ci ...process.env, 281cb0ef41Sopenharmony_ci CPU_PROF_INTERVAL: kCpuProfInterval 291cb0ef41Sopenharmony_ci } 301cb0ef41Sopenharmony_ci }); 311cb0ef41Sopenharmony_ci if (output.status !== 0) { 321cb0ef41Sopenharmony_ci console.log(output.stderr.toString()); 331cb0ef41Sopenharmony_ci } 341cb0ef41Sopenharmony_ci assert.strictEqual(output.status, 0); 351cb0ef41Sopenharmony_ci const profiles = getCpuProfiles(tmpdir.path); 361cb0ef41Sopenharmony_ci assert.strictEqual(profiles.length, 1); 371cb0ef41Sopenharmony_ci verifyFrames(output, profiles[0], 'fibonacci.js'); 381cb0ef41Sopenharmony_ci} 39