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
82
test/big.js
82
test/big.js
@ -54,37 +54,44 @@ tape('read', function (t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fuse = new Fuse(mnt, ops, { debug: !true, autoCache: true })
|
const fuse = new Fuse(mnt, ops, { debug: !true, autoCache: true })
|
||||||
fuse.mount(function (err) {
|
let fd = 0
|
||||||
t.error(err, 'no error')
|
|
||||||
|
|
||||||
fs.open(path.join(mnt, 'test'), 'w+', function (_, fd) {
|
run(
|
||||||
run(
|
(_, cb) => fuse.mount(cb),
|
||||||
(_, cb) => fs.fstat(fd, cb),
|
open,
|
||||||
checkSize(0),
|
(_, cb) => fs.fstat(fd, cb),
|
||||||
(_, cb) => fs.ftruncate(fd, 4 * 1024 * 1024 * 1024 + 1, cb),
|
checkSize(0),
|
||||||
(_, cb) => fs.fstat(fd, cb),
|
(_, cb) => fs.ftruncate(fd, 4 * 1024 * 1024 * 1024 + 1, cb),
|
||||||
checkSize(4 * 1024 * 1024 * 1024 + 1),
|
(_, cb) => fs.fstat(fd, cb),
|
||||||
(_, cb) => fs.truncate(path.join(mnt, 'test'), 6 * 1024 * 1024 * 1024 + 2, cb),
|
checkSize(4 * 1024 * 1024 * 1024 + 1),
|
||||||
(_, cb) => fs.fstat(fd, cb),
|
(_, cb) => fs.truncate(path.join(mnt, 'test'), 6 * 1024 * 1024 * 1024 + 2, cb),
|
||||||
checkSize(6 * 1024 * 1024 * 1024 + 2),
|
(_, cb) => fs.fstat(fd, cb),
|
||||||
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 0, cb),
|
checkSize(6 * 1024 * 1024 * 1024 + 2),
|
||||||
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 4 * 1024 * 1024 * 1024, cb),
|
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 0, cb),
|
||||||
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 6 * 1024 * 1024 * 1024, cb),
|
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 4 * 1024 * 1024 * 1024, cb),
|
||||||
(_, cb) => fs.fstat(fd, cb),
|
(_, cb) => fs.write(fd, Buffer.alloc(4096), 0, 4096, 6 * 1024 * 1024 * 1024, cb),
|
||||||
checkSize(6 * 1024 * 1024 * 1024 + 4096),
|
(_, cb) => fs.fstat(fd, cb),
|
||||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 0, cb),
|
checkSize(6 * 1024 * 1024 * 1024 + 4096),
|
||||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 4 * 1024 * 1024 * 1024, cb),
|
(_, cb) => fs.close(fd, cb),
|
||||||
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 6 * 1024 * 1024 * 1024, cb),
|
open,
|
||||||
(_, cb) => fs.close(fd, cb),
|
(_, cb) => fs.read(fd, Buffer.alloc(4096), 0, 4096, 0, cb),
|
||||||
(_, cb) => unmount(fuse, 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),
|
||||||
t.same(writes.length, 0)
|
(_, cb) => fs.close(fd, cb),
|
||||||
t.same(reads.length, 0)
|
(_, cb) => unmount(fuse, cb),
|
||||||
t.end()
|
() => {
|
||||||
}
|
t.same(writes.length, 0)
|
||||||
)
|
t.same(reads.length, 0)
|
||||||
|
t.end()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function open (_, cb) {
|
||||||
|
fs.open(path.join(mnt, 'test'), 'a+', function (_, res) {
|
||||||
|
fd = res
|
||||||
|
cb()
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
function checkSize (n) {
|
function checkSize (n) {
|
||||||
return ({ size}, cb) => {
|
return ({ size}, cb) => {
|
||||||
@ -92,13 +99,14 @@ tape('read', function (t) {
|
|||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
function run (...fns) {
|
function run (...fns) {
|
||||||
const all = [...fns]
|
const all = [...fns]
|
||||||
tick()
|
tick()
|
||||||
function tick (_, val) {
|
function tick (err, val) {
|
||||||
const next = all.shift()
|
t.error(err, 'no error')
|
||||||
if (next) next(val, tick)
|
const next = all.shift()
|
||||||
|
if (next) next(val, tick)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user