Sha256: 6623c1f4d35096dd64b1cee4409752e7758f1739cdffeddbeebe4b300c6d1dc0

Contents?: true

Size: 1.49 KB

Versions: 86

Compression:

Stored size: 1.49 KB

Contents

var test = require('tap').test
var fs = require('../')

test('open lots of stuff', function (t) {
  // Get around EBADF from libuv by making sure that stderr is opened
  // Otherwise Darwin will refuse to give us a FD for stderr!
  process.stderr.write('')

  // How many parallel open()'s to do
  var n = 1024
  var opens = 0
  var fds = []
  var going = true
  var closing = false
  var doneCalled = 0

  for (var i = 0; i < n; i++) {
    go()
  }

  function go() {
    opens++
    fs.open(__filename, 'r', function (er, fd) {
      if (er) throw er
      fds.push(fd)
      if (going) go()
    })
  }

  // should hit ulimit pretty fast
  setTimeout(function () {
    going = false
    t.equal(opens - fds.length, n)
    done()
  }, 100)


  function done () {
    if (closing) return
    doneCalled++

    if (fds.length === 0) {
      //console.error('done called %d times', doneCalled)
      // First because of the timeout
      // Then to close the fd's opened afterwards
      // Then this time, to complete.
      // Might take multiple passes, depending on CPU speed
      // and ulimit, but at least 3 in every case.
      t.ok(doneCalled >= 3)
      return t.end()
    }

    closing = true
    setTimeout(function () {
      // console.error('do closing again')
      closing = false
      done()
    }, 100)

    // console.error('closing time')
    var closes = fds.slice(0)
    fds.length = 0
    closes.forEach(function (fd) {
      fs.close(fd, function (er) {
        if (er) throw er
      })
    })
  }
})

Version data entries

86 entries across 79 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/graceful-fs/test/max-open.js
smock-0.1.268 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.267 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.266 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.265 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.264 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.263 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.262 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.261 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.260 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js
smock-0.1.259 node_modules/webpack/node_modules/watchpack/node_modules/graceful-fs/test/max-open.js