This commit is contained in:
2018-05-16 10:10:23 +02:00
commit 79abc63edd
597 changed files with 93351 additions and 0 deletions

37
node_modules/epoll/test/brute-force-leak-check.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
'use strict';
/*
* Create 1e9 epoll instances and use each of them to detect a single event.
* The goal here is ensure that memory usage doesn't constantly increase over
* time.
*
* This test expects a newline as input on stdin. It polls for events on stdin
* but doesn't read stdin until it has been notified about the availability of
* input data 1e9 times.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
count = 0,
stdin = 0; // fd for stdin
function once() {
var epoll = new Epoll(function (err, fd, events) {
epoll.remove(fd).close();
count += 1;
if (count % 1e5 === 0) {
console.log(' ' + count + ' instances created and events detected ');
}
if (count < 1e9) {
once();
} else {
util.read(fd); // read stdin (the newline)
}
});
epoll.add(stdin, Epoll.EPOLLIN);
}
once();

25
node_modules/epoll/test/closed.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
'use strict';
/*
*
*/
var Epoll = require('../build/Release/epoll').Epoll,
assert = require('assert'),
poller = new Epoll(function () {}),
stdin = 0;
assert(poller.closed === false);
function closePoller() {
if (!poller.closed) {
poller.remove(stdin).close();
}
}
poller.add(stdin, Epoll.EPOLLIN);
closePoller();
closePoller();
assert(poller.closed === true);

15
node_modules/epoll/test/do-almost-nothing.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
'use strict';
/*
* Make sure the process terminates when epoll is used and 'almsost nothing'
* is actually done. The epoll addon calls uv_ref and uv_unref to keep nodes
* event loop alive. Here we make sure that the addon isn't keeping the event
* loop alive unnecessarily long. If the process terminates, everything is ok.
* If it hangs, there is a problem.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll = new Epoll(function () {}),
stdin = 0; // fd for stdin
epoll.add(stdin, Epoll.EPOLLIN).remove(stdin).close();

13
node_modules/epoll/test/do-nothing.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
'use strict';
/*
* Make sure the process terminates when epoll is used and 'nothing' is
* actually done. The epoll addon calls uv_ref and uv_unref to keep nodes
* event loop alive. Here we make sure that the addon isn't keeping the event
* loop alive unnecessarily long. If the process terminates, everything is ok.
* If it hangs, there is a problem.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll0 = new Epoll(function () {}),
epoll1 = new Epoll(function () {});

29
node_modules/epoll/test/no-gc-allowed.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
'use strict';
/*
* This test resulted in a segmentation fault in epoll v0.0.6. See issue #5.
*
* There were Ref/Unref issues in the epoll addon which resulted in epoll
* instances being garbage collected while still in use.
*
* This test expects a newline as input on stdin. It should be piped in for
* for best results:
* echo | node no-gc-allowed
*/
var Epoll = require('../build/Release/epoll').Epoll;
var time = process.hrtime();
var stdin = 0; // fd for stdin
var poller = new Epoll(function () {
var timeSoFar = process.hrtime(time);
if (timeSoFar[0] > 5) {
// BB faults in ~2.5s, Pi faults in ~?s, so wait about 5s.
// In order for the segfault to occur, V8 can't have anymore required
// references to poller. If process.exit(0) is replaced with
// poller.remove(0).close(), there will be a required reference, poller
// won't be garbage collected, and there will be no segfault.
process.exit(0);
}
});
poller.add(stdin, Epoll.EPOLLIN);

28
node_modules/epoll/test/one-shot.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
'use strict';
/*
* Make sure a single EPOLLONESHOT event can be handled.
*
* This test expects a newline as input on stdin.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
eventCount = 0,
epoll,
stdin = 0; // fd for stdin
epoll = new Epoll(function (err, fd, events) {
eventCount += 1;
if (eventCount === 1) {
setTimeout(function () {
util.read(fd); // read stdin (the newline)
epoll.remove(fd).close();
}, 100);
} else {
console.log('*** Error: unexpected event');
}
});
epoll.add(stdin, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);

39
node_modules/epoll/test/performance-check.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict';
/*
* Determine approximately how many EPOLLIN events can be handled per second.
*
* This test expects a newline as input on stdin. It polls for events on stdin
* but doesn't read stdin until the test has completed. This results in a
* continuous stream of events while the test is running.
*
* Note that the rate determined is misleading as epoll is notifying us about
* the same newline all the time.
*
* The newline should be piped in for reasonable results:
* echo | node performance-check
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
time,
count = 0,
stdin = 0; // fd for stdin
var epoll = new Epoll(function (err, fd, events) {
count += 1;
});
setTimeout(function () {
var rate;
time = process.hrtime(time);
rate = Math.floor(count / (time[0] + time[1] / 1E9));
console.log(' ' + rate + ' events per second');
epoll.remove(stdin).close();
util.read(stdin); // read stdin (the newline)
}, 100);
epoll.add(stdin, Epoll.EPOLLIN);
time = process.hrtime();

38
node_modules/epoll/test/run-tests generated vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
echo 'started - do-nothing'
node do-nothing
echo 'finished - do-nothing'
echo 'started - do-almost-nothing'
node do-almost-nothing
echo 'finished - do-almost-nothing'
echo 'started - verify-events'
node verify-events
echo 'finished - verify-events'
echo 'started - closed'
node closed
echo 'finished - closed'
echo 'started - one-shot'
echo | node one-shot
echo 'finished - one-shot'
echo 'started - two-shot'
echo | node two-shot
echo 'finished - two-shot'
# brute-force-leak-check takes a while to execute so its only run occasionally
#echo 'started - brute-force-leak-check'
#echo | node brute-force-leak-check
#echo 'finished - brute-force-leak-check'
echo 'started - performance-check'
echo | node performance-check
echo 'finished - performance-check'
echo 'started - no-gc-allowed'
echo | node no-gc-allowed
echo 'finished - no-gc-allowed'

32
node_modules/epoll/test/two-shot.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
'use strict';
/*
* Make sure two EPOLLONESHOT events can be handled.
*
* This test expects a newline as input on stdin.
*/
var Epoll = require('../build/Release/epoll').Epoll,
util = require('./util'),
eventCount = 0,
epoll,
stdin = 0; // fd for stdin
epoll = new Epoll(function (err, fd, events) {
eventCount += 1;
if (eventCount === 1) {
setTimeout(function () {
epoll.modify(fd, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);
}, 100);
} else if (eventCount === 2) {
setTimeout(function () {
util.read(fd); // read stdin (the newline)
epoll.remove(fd).close();
}, 100);
} else {
console.log('*** Error: unexpected event');
}
});
epoll.add(stdin, Epoll.EPOLLIN | Epoll.EPOLLONESHOT);

11
node_modules/epoll/test/util.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
'use strict';
var fs = require('fs');
module.exports = {
read: function (fd) {
var buf = new Buffer(1024);
fs.readSync(fd, buf, 0, buf.length, null);
}
};

33
node_modules/epoll/test/verify-events.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
'use strict';
/*
* Verify that add and modify accept all valid event types. See issue #2.
*/
var Epoll = require('../build/Release/epoll').Epoll,
epoll = new Epoll(function () {}),
stdin = 0; // fd for stdin
try {
epoll.add(stdin, Epoll.EPOLLIN).remove(stdin)
.add(stdin, Epoll.EPOLLOUT).remove(stdin)
.add(stdin, Epoll.EPOLLRDHUP).remove(stdin)
.add(stdin, Epoll.EPOLLPRI).remove(stdin)
.add(stdin, Epoll.EPOLLERR).remove(stdin)
.add(stdin, Epoll.EPOLLHUP).remove(stdin)
.add(stdin, Epoll.EPOLLET).remove(stdin)
.add(stdin, Epoll.EPOLLONESHOT)
.modify(stdin, Epoll.EPOLLIN)
.modify(stdin, Epoll.EPOLLOUT)
.modify(stdin, Epoll.EPOLLRDHUP)
.modify(stdin, Epoll.EPOLLPRI)
.modify(stdin, Epoll.EPOLLERR)
.modify(stdin, Epoll.EPOLLHUP)
.modify(stdin, Epoll.EPOLLET)
.modify(stdin, Epoll.EPOLLONESHOT)
.remove(stdin);
} catch (ex) {
console.log('*** Error: ' + ex.message);
} finally {
epoll.close();
}