|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +constcommon=require('../common'); |
| 4 | +constassert=require('assert'); |
| 5 | +constcrypto=require('crypto'); |
| 6 | +constdgram=require('dgram'); |
| 7 | +constdns=require('dns'); |
| 8 | +constfs=require('fs'); |
| 9 | +constnet=require('net'); |
| 10 | +consttls=require('tls'); |
| 11 | +constzlib=require('zlib'); |
| 12 | +constChildProcess=require('child_process').ChildProcess; |
| 13 | +constStreamWrap=require('_stream_wrap').StreamWrap; |
| 14 | +constasync_wrap=process.binding('async_wrap'); |
| 15 | +constpkeys=Object.keys(async_wrap.Providers); |
| 16 | + |
| 17 | +letkeyList=pkeys.slice(); |
| 18 | +// Drop NONE |
| 19 | +keyList.splice(0,1); |
| 20 | + |
| 21 | + |
| 22 | +functioninit(id){ |
| 23 | +keyList=keyList.filter(e=>e!=pkeys[id]); |
| 24 | +} |
| 25 | + |
| 26 | +functionnoop(){} |
| 27 | + |
| 28 | +async_wrap.setupHooks(init,noop,noop); |
| 29 | + |
| 30 | +async_wrap.enable(); |
| 31 | + |
| 32 | + |
| 33 | +setTimeout(function(){}); |
| 34 | + |
| 35 | +fs.stat(__filename,noop); |
| 36 | +fs.watchFile(__filename,noop); |
| 37 | +fs.unwatchFile(__filename); |
| 38 | +fs.watch(__filename).close(); |
| 39 | + |
| 40 | +dns.lookup('localhost',noop); |
| 41 | +dns.lookupService('::',0,noop); |
| 42 | +dns.resolve('localhost',noop); |
| 43 | + |
| 44 | +newStreamWrap(newnet.Socket()); |
| 45 | + |
| 46 | +new(process.binding('tty_wrap').TTY)(); |
| 47 | + |
| 48 | +crypto.randomBytes(1,noop); |
| 49 | + |
| 50 | +try{ |
| 51 | +fs.unlinkSync(common.PIPE); |
| 52 | +}catch(e){} |
| 53 | + |
| 54 | +net.createServer(function(c){ |
| 55 | +c.end(); |
| 56 | +this.close(); |
| 57 | +}).listen(common.PIPE,function(){ |
| 58 | +net.connect(common.PIPE,noop); |
| 59 | +}); |
| 60 | + |
| 61 | +net.createServer(function(c){ |
| 62 | +c.end(); |
| 63 | +this.close(checkTLS); |
| 64 | +}).listen(common.PORT,function(){ |
| 65 | +net.connect(common.PORT,noop); |
| 66 | +}); |
| 67 | + |
| 68 | +dgram.createSocket('udp4').bind(common.PORT,function(){ |
| 69 | +this.send(newBuffer(2),0,2,common.PORT,'::',()=>{ |
| 70 | +this.close(); |
| 71 | +}); |
| 72 | +}); |
| 73 | + |
| 74 | +process.on('SIGINT',()=>process.exit()); |
| 75 | + |
| 76 | +// Run from closed net server above. |
| 77 | +functioncheckTLS(){ |
| 78 | +letoptions={ |
| 79 | +key: fs.readFileSync(common.fixturesDir+'/keys/ec-key.pem'), |
| 80 | +cert: fs.readFileSync(common.fixturesDir+'/keys/ec-cert.pem') |
| 81 | +}; |
| 82 | +letserver=tls.createServer(options,noop).listen(common.PORT,function(){ |
| 83 | +tls.connect(common.PORT,{rejectUnauthorized: false},function(){ |
| 84 | +this.destroy(); |
| 85 | +server.close(); |
| 86 | +}); |
| 87 | +}); |
| 88 | +} |
| 89 | + |
| 90 | +zlib.createGzip(); |
| 91 | + |
| 92 | +newChildProcess(); |
| 93 | + |
| 94 | +process.on('exit',function(){ |
| 95 | +if(keyList.length!==0){ |
| 96 | +process._rawDebug('Not all keys have been used:'); |
| 97 | +process._rawDebug(keyList); |
| 98 | +assert.equal(keyList.length,0); |
| 99 | +} |
| 100 | +}); |
0 commit comments