11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks'); 61cb0ef41Sopenharmony_ciconst initHooks = require('./init-hooks'); 71cb0ef41Sopenharmony_ciconst { checkInvocations } = require('./hook-checks'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst hooks = initHooks(); 101cb0ef41Sopenharmony_cihooks.enable(); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst rootAsyncId = async_hooks.executionAsyncId(); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciqueueMicrotask(common.mustCall(() => { 151cb0ef41Sopenharmony_ci assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId); 161cb0ef41Sopenharmony_ci})); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciprocess.on('exit', () => { 191cb0ef41Sopenharmony_ci hooks.sanityCheck(); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci const as = hooks.activitiesOfTypes('Microtask'); 221cb0ef41Sopenharmony_ci checkInvocations(as[0], { 231cb0ef41Sopenharmony_ci init: 1, before: 1, after: 1, destroy: 1, 241cb0ef41Sopenharmony_ci }, 'when process exits'); 251cb0ef41Sopenharmony_ci}); 26