1'use strict'; 2const common = require('../common'); 3const tmpdir = require('../common/tmpdir'); 4const fs = require('fs'); 5const assert = require('assert'); 6const { spawnSync } = require('child_process'); 7 8if (!common.enoughTestMem) 9 common.skip('skipped due to memory requirements'); 10if (common.isAIX) 11 common.skip('does not work on AIX'); 12 13tmpdir.refresh(); 14 15// Generate log file. 16spawnSync(process.execPath, [ '--prof', '-p', '42' ], { cwd: tmpdir.path }); 17 18const files = fs.readdirSync(tmpdir.path); 19const logfile = files.filter((name) => /\.log$/.test(name))[0]; 20assert(logfile); 21 22// Make sure that the --preprocess argument is passed through correctly, 23// as an example flag listed in deps/v8/tools/tickprocessor.js. 24// Any of the other flags there should work for this test too, if --preprocess 25// is ever removed. 26const { stdout } = spawnSync( 27 process.execPath, 28 [ '--prof-process', '--preprocess', logfile ], 29 { cwd: tmpdir.path, encoding: 'utf8', maxBuffer: Infinity }); 30 31// Make sure that the result is valid JSON. 32JSON.parse(stdout); 33