11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
41cb0ef41Sopenharmony_ciconst fs = require('fs');
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciif (!common.enoughTestMem)
91cb0ef41Sopenharmony_ci  common.skip('skipped due to memory requirements');
101cb0ef41Sopenharmony_ciif (common.isAIX)
111cb0ef41Sopenharmony_ci  common.skip('does not work on AIX');
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_citmpdir.refresh();
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// Generate log file.
161cb0ef41Sopenharmony_cispawnSync(process.execPath, [ '--prof', '-p', '42' ], { cwd: tmpdir.path });
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconst files = fs.readdirSync(tmpdir.path);
191cb0ef41Sopenharmony_ciconst logfile = files.filter((name) => /\.log$/.test(name))[0];
201cb0ef41Sopenharmony_ciassert(logfile);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci// Make sure that the --preprocess argument is passed through correctly,
231cb0ef41Sopenharmony_ci// as an example flag listed in deps/v8/tools/tickprocessor.js.
241cb0ef41Sopenharmony_ci// Any of the other flags there should work for this test too, if --preprocess
251cb0ef41Sopenharmony_ci// is ever removed.
261cb0ef41Sopenharmony_ciconst { stdout } = spawnSync(
271cb0ef41Sopenharmony_ci  process.execPath,
281cb0ef41Sopenharmony_ci  [ '--prof-process', '--preprocess', logfile ],
291cb0ef41Sopenharmony_ci  { cwd: tmpdir.path, encoding: 'utf8', maxBuffer: Infinity });
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci// Make sure that the result is valid JSON.
321cb0ef41Sopenharmony_ciJSON.parse(stdout);
33