11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst cp = require('child_process'); 61cb0ef41Sopenharmony_ciconst fs = require('fs'); 71cb0ef41Sopenharmony_ciconst path = require('path'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_citmpdir.refresh(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst CODE = 121cb0ef41Sopenharmony_ci 'setTimeout(() => { for (let i = 0; i < 100000; i++) { "test" + i } }, 1)'; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst proc = cp.spawn(process.execPath, [ 151cb0ef41Sopenharmony_ci '--trace-events-enabled', 161cb0ef41Sopenharmony_ci '--trace-event-file-pattern', 171cb0ef41Sopenharmony_ci // eslint-disable-next-line no-template-curly-in-string 181cb0ef41Sopenharmony_ci '${pid}-${rotation}-${pid}-${rotation}.tracing.log', 191cb0ef41Sopenharmony_ci '-e', CODE, 201cb0ef41Sopenharmony_ci], { cwd: tmpdir.path }); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciproc.once('exit', common.mustCall(() => { 231cb0ef41Sopenharmony_ci const expectedFilename = path.join(tmpdir.path, 241cb0ef41Sopenharmony_ci `${proc.pid}-1-${proc.pid}-1.tracing.log`); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci assert(fs.existsSync(expectedFilename)); 271cb0ef41Sopenharmony_ci fs.readFile(expectedFilename, common.mustCall((err, data) => { 281cb0ef41Sopenharmony_ci const traces = JSON.parse(data.toString()).traceEvents; 291cb0ef41Sopenharmony_ci assert(traces.length > 0); 301cb0ef41Sopenharmony_ci })); 311cb0ef41Sopenharmony_ci})); 32