1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const tick = require('../common/tick');
6const initHooks = require('./init-hooks');
7const { checkInvocations } = require('./hook-checks');
8const fs = require('fs');
9
10const hooks = initHooks();
11
12hooks.enable();
13fs.access(__filename, common.mustCall(onaccess));
14
15function onaccess() {
16  const as = hooks.activitiesOfTypes('FSREQCALLBACK');
17  const a = as[0];
18  checkInvocations(a, { init: 1, before: 1 },
19                   'while in onaccess callback');
20  tick(2);
21}
22
23process.on('exit', onexit);
24
25function onexit() {
26  hooks.disable();
27  hooks.sanityCheck('FSREQCALLBACK');
28
29  const as = hooks.activitiesOfTypes('FSREQCALLBACK');
30  assert.strictEqual(as.length, 1);
31
32  const a = as[0];
33  assert.strictEqual(a.type, 'FSREQCALLBACK');
34  assert.strictEqual(typeof a.uid, 'number');
35  checkInvocations(a, { init: 1, before: 1, after: 1, destroy: 1 },
36                   'when process exits');
37}
38