1 var test = require('tap').test
2 var fs = require('../')
4 test('open lots of stuff', function (t) {
5 // Get around EBADF from libuv by making sure that stderr is opened
6 // Otherwise Darwin will refuse to give us a FD for stderr!
7 process.stderr.write('')
9 // How many parallel open()'s to do
17 for (var i = 0; i < n; i++) {
23 fs.open(__filename, 'r', function (er, fd) {
30 // should hit ulimit pretty fast
31 setTimeout(function () {
33 t.equal(opens - fds.length, n)
42 if (fds.length === 0) {
43 console.error('done called %d times', doneCalled)
44 // First because of the timeout
45 // Then to close the fd's opened afterwards
46 // Then this time, to complete.
47 // Might take multiple passes, depending on CPU speed
48 // and ulimit, but at least 3 in every case.
54 setTimeout(function () {
55 // console.error('do closing again')
60 // console.error('closing time')
61 var closes = fds.slice(0)
63 closes.forEach(function (fd) {
64 fs.close(fd, function (er) {