11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Tests invalid --heap-prof CLI arguments. 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 { spawnSync } = require('child_process'); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst { 161cb0ef41Sopenharmony_ci kHeapProfInterval, 171cb0ef41Sopenharmony_ci env 181cb0ef41Sopenharmony_ci} = require('../common/prof'); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci// Tests --heap-prof-name without --heap-prof. 211cb0ef41Sopenharmony_ci{ 221cb0ef41Sopenharmony_ci tmpdir.refresh(); 231cb0ef41Sopenharmony_ci const output = spawnSync(process.execPath, [ 241cb0ef41Sopenharmony_ci '--heap-prof-name', 251cb0ef41Sopenharmony_ci 'test.heapprofile', 261cb0ef41Sopenharmony_ci fixtures.path('workload', 'allocation.js'), 271cb0ef41Sopenharmony_ci ], { 281cb0ef41Sopenharmony_ci cwd: tmpdir.path, 291cb0ef41Sopenharmony_ci env 301cb0ef41Sopenharmony_ci }); 311cb0ef41Sopenharmony_ci const stderr = output.stderr.toString().trim(); 321cb0ef41Sopenharmony_ci if (output.status !== 9) { 331cb0ef41Sopenharmony_ci console.log(stderr); 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci assert.strictEqual(output.status, 9); 361cb0ef41Sopenharmony_ci assert.strictEqual( 371cb0ef41Sopenharmony_ci stderr, 381cb0ef41Sopenharmony_ci `${process.execPath}: --heap-prof-name must be used with --heap-prof`); 391cb0ef41Sopenharmony_ci} 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci// Tests --heap-prof-dir without --heap-prof. 421cb0ef41Sopenharmony_ci{ 431cb0ef41Sopenharmony_ci tmpdir.refresh(); 441cb0ef41Sopenharmony_ci const output = spawnSync(process.execPath, [ 451cb0ef41Sopenharmony_ci '--heap-prof-dir', 461cb0ef41Sopenharmony_ci 'prof', 471cb0ef41Sopenharmony_ci fixtures.path('workload', 'allocation.js'), 481cb0ef41Sopenharmony_ci ], { 491cb0ef41Sopenharmony_ci cwd: tmpdir.path, 501cb0ef41Sopenharmony_ci env 511cb0ef41Sopenharmony_ci }); 521cb0ef41Sopenharmony_ci const stderr = output.stderr.toString().trim(); 531cb0ef41Sopenharmony_ci if (output.status !== 9) { 541cb0ef41Sopenharmony_ci console.log(stderr); 551cb0ef41Sopenharmony_ci } 561cb0ef41Sopenharmony_ci assert.strictEqual(output.status, 9); 571cb0ef41Sopenharmony_ci assert.strictEqual( 581cb0ef41Sopenharmony_ci stderr, 591cb0ef41Sopenharmony_ci `${process.execPath}: --heap-prof-dir must be used with --heap-prof`); 601cb0ef41Sopenharmony_ci} 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci// Tests --heap-prof-interval without --heap-prof. 631cb0ef41Sopenharmony_ci{ 641cb0ef41Sopenharmony_ci tmpdir.refresh(); 651cb0ef41Sopenharmony_ci const output = spawnSync(process.execPath, [ 661cb0ef41Sopenharmony_ci '--heap-prof-interval', 671cb0ef41Sopenharmony_ci kHeapProfInterval, 681cb0ef41Sopenharmony_ci fixtures.path('workload', 'allocation.js'), 691cb0ef41Sopenharmony_ci ], { 701cb0ef41Sopenharmony_ci cwd: tmpdir.path, 711cb0ef41Sopenharmony_ci env 721cb0ef41Sopenharmony_ci }); 731cb0ef41Sopenharmony_ci const stderr = output.stderr.toString().trim(); 741cb0ef41Sopenharmony_ci if (output.status !== 9) { 751cb0ef41Sopenharmony_ci console.log(stderr); 761cb0ef41Sopenharmony_ci } 771cb0ef41Sopenharmony_ci assert.strictEqual(output.status, 9); 781cb0ef41Sopenharmony_ci assert.strictEqual( 791cb0ef41Sopenharmony_ci stderr, 801cb0ef41Sopenharmony_ci `${process.execPath}: ` + 811cb0ef41Sopenharmony_ci '--heap-prof-interval must be used with --heap-prof'); 821cb0ef41Sopenharmony_ci} 83