11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst cp = require('child_process'); 51cb0ef41Sopenharmony_ciconst fs = require('fs'); 61cb0ef41Sopenharmony_ciconst path = require('path'); 71cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciif (!common.hasCrypto) 101cb0ef41Sopenharmony_ci common.skip('missing crypto'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst { hkdf } = require('crypto'); 131cb0ef41Sopenharmony_ciconst { deflate } = require('zlib'); 141cb0ef41Sopenharmony_ciconst { Blob } = require('buffer'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciif (process.env.isChild === '1') { 171cb0ef41Sopenharmony_ci hkdf('sha512', 'key', 'salt', 'info', 64, () => {}); 181cb0ef41Sopenharmony_ci deflate('hello', () => {}); 191cb0ef41Sopenharmony_ci // Make async call 201cb0ef41Sopenharmony_ci const blob = new Blob(['h'.repeat(4096 * 2)]); 211cb0ef41Sopenharmony_ci blob.arrayBuffer(); 221cb0ef41Sopenharmony_ci return; 231cb0ef41Sopenharmony_ci} 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_citmpdir.refresh(); 261cb0ef41Sopenharmony_ciconst FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_cicp.spawnSync(process.execPath, 291cb0ef41Sopenharmony_ci [ 301cb0ef41Sopenharmony_ci '--trace-events-enabled', 311cb0ef41Sopenharmony_ci '--trace-event-categories', 321cb0ef41Sopenharmony_ci 'node.threadpoolwork.sync,node.threadpoolwork.async', 331cb0ef41Sopenharmony_ci __filename, 341cb0ef41Sopenharmony_ci ], 351cb0ef41Sopenharmony_ci { 361cb0ef41Sopenharmony_ci cwd: tmpdir.path, 371cb0ef41Sopenharmony_ci env: { 381cb0ef41Sopenharmony_ci ...process.env, 391cb0ef41Sopenharmony_ci isChild: '1', 401cb0ef41Sopenharmony_ci }, 411cb0ef41Sopenharmony_ci }); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ciassert(fs.existsSync(FILE_NAME)); 441cb0ef41Sopenharmony_ciconst data = fs.readFileSync(FILE_NAME); 451cb0ef41Sopenharmony_ciconst traces = JSON.parse(data.toString()).traceEvents; 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ciassert(traces.length > 0); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_cilet blobCount = 0; 501cb0ef41Sopenharmony_cilet zlibCount = 0; 511cb0ef41Sopenharmony_cilet cryptoCount = 0; 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_citraces.forEach((item) => { 541cb0ef41Sopenharmony_ci if ([ 551cb0ef41Sopenharmony_ci 'node,node.threadpoolwork,node.threadpoolwork.sync', 561cb0ef41Sopenharmony_ci 'node,node.threadpoolwork,node.threadpoolwork.async', 571cb0ef41Sopenharmony_ci ].includes(item.cat)) { 581cb0ef41Sopenharmony_ci if (item.name === 'blob') { 591cb0ef41Sopenharmony_ci blobCount++; 601cb0ef41Sopenharmony_ci } else if (item.name === 'zlib') { 611cb0ef41Sopenharmony_ci zlibCount++; 621cb0ef41Sopenharmony_ci } else if (item.name === 'crypto') { 631cb0ef41Sopenharmony_ci cryptoCount++; 641cb0ef41Sopenharmony_ci } 651cb0ef41Sopenharmony_ci } 661cb0ef41Sopenharmony_ci}); 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci// There are three types, each type has two async events and sync events at least 691cb0ef41Sopenharmony_ciassert.ok(blobCount >= 4); 701cb0ef41Sopenharmony_ciassert.ok(zlibCount >= 4); 711cb0ef41Sopenharmony_ciassert.ok(cryptoCount >= 4); 72