11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Tests --heap-prof-dir and --heap-prof-name work together. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst common = require('../common'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 81cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst assert = require('assert'); 111cb0ef41Sopenharmony_ciconst fs = require('fs'); 121cb0ef41Sopenharmony_ciconst path = require('path'); 131cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciconst { 181cb0ef41Sopenharmony_ci getHeapProfiles, 191cb0ef41Sopenharmony_ci verifyFrames, 201cb0ef41Sopenharmony_ci kHeapProfInterval, 211cb0ef41Sopenharmony_ci env 221cb0ef41Sopenharmony_ci} = require('../common/prof'); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci{ 251cb0ef41Sopenharmony_ci tmpdir.refresh(); 261cb0ef41Sopenharmony_ci const dir = path.join(tmpdir.path, 'prof'); 271cb0ef41Sopenharmony_ci const file = path.join(dir, 'test.heapprofile'); 281cb0ef41Sopenharmony_ci const output = spawnSync(process.execPath, [ 291cb0ef41Sopenharmony_ci '--heap-prof', 301cb0ef41Sopenharmony_ci '--heap-prof-name', 311cb0ef41Sopenharmony_ci 'test.heapprofile', 321cb0ef41Sopenharmony_ci '--heap-prof-dir', 331cb0ef41Sopenharmony_ci dir, 341cb0ef41Sopenharmony_ci '--heap-prof-interval', 351cb0ef41Sopenharmony_ci kHeapProfInterval, 361cb0ef41Sopenharmony_ci fixtures.path('workload', 'allocation.js'), 371cb0ef41Sopenharmony_ci ], { 381cb0ef41Sopenharmony_ci cwd: tmpdir.path, 391cb0ef41Sopenharmony_ci env 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci if (output.status !== 0) { 421cb0ef41Sopenharmony_ci console.log(output.stderr.toString()); 431cb0ef41Sopenharmony_ci } 441cb0ef41Sopenharmony_ci assert.strictEqual(output.status, 0); 451cb0ef41Sopenharmony_ci assert(fs.existsSync(dir)); 461cb0ef41Sopenharmony_ci const profiles = getHeapProfiles(dir); 471cb0ef41Sopenharmony_ci assert.deepStrictEqual(profiles, [file]); 481cb0ef41Sopenharmony_ci verifyFrames(output, file, 'runAllocation'); 491cb0ef41Sopenharmony_ci} 50