mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
fix big file test
This commit is contained in:
parent
62401463df
commit
aa745f4ff5
24
test/big.js
24
test/big.js
@ -54,11 +54,11 @@ tape('read', function (t) {
|
||||
}
|
||||
|
||||
const fuse = new Fuse(mnt, ops, { debug: !true, autoCache: true })
|
||||
fuse.mount(function (err) {
|
||||
t.error(err, 'no error')
|
||||
let fd = 0
|
||||
|
||||
fs.open(path.join(mnt, 'test'), 'w+', function (_, fd) {
|
||||
run(
|
||||
(_, cb) => fuse.mount(cb),
|
||||
open,
|
||||
(_, cb) => fs.fstat(fd, cb),
|
||||
checkSize(0),
|
||||
(_, cb) => fs.ftruncate(fd, 4 * 1024 * 1024 * 1024 + 1, cb),
|
||||
@ -72,6 +72,8 @@ tape('read', function (t) {
|
||||
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 6 * 1024 * 1024 * 1024, cb),
|
||||
(_, cb) => fs.fstat(fd, cb),
|
||||
checkSize(6 * 1024 * 1024 * 1024 + 4096),
|
||||
(_, cb) => fs.close(fd, cb),
|
||||
open,
|
||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 0, cb),
|
||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 4 * 1024 * 1024 * 1024, cb),
|
||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 6 * 1024 * 1024 * 1024, cb),
|
||||
@ -83,8 +85,13 @@ tape('read', function (t) {
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
|
||||
function open (_, cb) {
|
||||
fs.open(path.join(mnt, 'test'), 'a+', function (_, res) {
|
||||
fd = res
|
||||
cb()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function checkSize (n) {
|
||||
return ({ size}, cb) => {
|
||||
@ -92,13 +99,14 @@ tape('read', function (t) {
|
||||
cb()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function run (...fns) {
|
||||
function run (...fns) {
|
||||
const all = [...fns]
|
||||
tick()
|
||||
function tick (_, val) {
|
||||
function tick (err, val) {
|
||||
t.error(err, 'no error')
|
||||
const next = all.shift()
|
||||
if (next) next(val, tick)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user