forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: really test the ttywrap bits of getasyncid
Follow-up from nodejs#18800 Code that tries to exercise tty fds must be placed in `/pseudo-tty/`. PR-URL: nodejs#18886 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
1 parent
d22a97e
commit edb0197
Showing
3 changed files
with
51 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
// see also test/sequential/test-async-wrap-getasyncid.js | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const tty_wrap = process.binding('tty_wrap'); | ||
const { TTYWRAP } = process.binding('async_wrap').Providers; | ||
const providers = { TTYWRAP }; | ||
|
||
// Make sure that the TTYWRAP Provider is tested. | ||
{ | ||
const hooks = require('async_hooks').createHook({ | ||
init(id, type) { | ||
if (type === 'NONE') | ||
throw new Error('received a provider type of NONE'); | ||
delete providers[type]; | ||
}, | ||
}).enable(); | ||
process.on('beforeExit', common.mustCall(() => { | ||
process.removeAllListeners('uncaughtException'); | ||
hooks.disable(); | ||
|
||
const objKeys = Object.keys(providers); | ||
if (objKeys.length > 0) | ||
process._rawDebug(objKeys); | ||
assert.strictEqual(objKeys.length, 0); | ||
})); | ||
} | ||
|
||
function testInitialized(req, ctor_name) { | ||
assert.strictEqual(typeof req.getAsyncId, 'function'); | ||
assert(Number.isSafeInteger(req.getAsyncId())); | ||
assert(req.getAsyncId() > 0); | ||
assert.strictEqual(req.constructor.name, ctor_name); | ||
} | ||
|
||
{ | ||
const ttyFd = common.getTTYfd(); | ||
|
||
const handle = new tty_wrap.TTY(ttyFd, false); | ||
testInitialized(handle, 'TTY'); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters