diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2017-04-10 15:52:12 +0530 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2017-04-10 15:52:12 +0530 |
commit | 84b3a1c939dc2baf22f9f5e30029b263c1512ade (patch) | |
tree | 131f2c17ad61078f95425eab1e349b96d0245d36 /vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js | |
parent | ef9cd2561e325c82d4d1fcb03fef4582a53d7839 (diff) |
Integration of VNFMarket to Main GUI
IssueId : CLIENT-189
Change-Id: I37f49f6447ba2d5fb57779754117549eb315f0b5
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js')
-rw-r--r-- | vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js new file mode 100644 index 00000000..a6b9ba43 --- /dev/null +++ b/vnfmarket/src/main/webapp/vnfmarket/node_modules/graceful-fs/test/max-open.js @@ -0,0 +1,69 @@ +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 >= 2) + 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 + }) + }) + } +}) |