Merge #6422 from ZyX-I/fix-6420

eval,fileio: Omit additional fsync() call
This commit is contained in:
Justin M. Keyes
2017-04-01 22:38:21 +02:00
committed by GitHub
3 changed files with 49 additions and 15 deletions

View File

@@ -80,6 +80,10 @@ local function file_read(fp, size)
return ret1, ret2
end
local function file_flush(fp)
return m.file_flush(fp)
end
local function file_fsync(fp)
return m.file_fsync(fp)
end
@@ -244,6 +248,21 @@ describe('file_fsync', function()
end)
end)
describe('file_flush', function()
itp('can flush writes to disk', function()
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
eq(0, file_flush(fp))
eq(0, err)
eq(0, lfs.attributes(filec).size)
local wsize = file_write(fp, 'test')
eq(4, wsize)
eq(0, lfs.attributes(filec).size)
eq(0, file_flush(fp))
eq(wsize, lfs.attributes(filec).size)
eq(0, m.file_close(fp))
end)
end)
describe('file_read', function()
itp('can read small chunks of input until eof', function()
local err, fp = file_open(file1, 0, 384)