summaryrefslogtreecommitdiff
path: root/test/async-hooks/test-fsreqwrap-access.js
blob: 2b31f2512d6b9c84df65251599b46ab044ece933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';

const common = require('../common');
const assert = require('assert');
const tick = require('./tick');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const fs = require('fs');

const hooks = initHooks();

hooks.enable();
fs.access(__filename, common.mustCall(onaccess));

function onaccess() {
  const as = hooks.activitiesOfTypes('FSREQWRAP');
  const a = as[0];
  checkInvocations(a, { init: 1, before: 1 },
                   'while in onaccess callback');
  tick(2);
}

process.on('exit', onexit);

function onexit() {
  hooks.disable();
  hooks.sanityCheck('FSREQWRAP');

  const as = hooks.activitiesOfTypes('FSREQWRAP');
  assert.strictEqual(as.length, 1);

  const a = as[0];
  assert.strictEqual(a.type, 'FSREQWRAP');
  assert.strictEqual(typeof a.uid, 'number');
  checkInvocations(a, { init: 1, before: 1, after: 1, destroy: 1 },
                   'when process exits');
}