diff options
Diffstat (limited to 'test/unit/os/fileio_spec.lua')
-rw-r--r-- | test/unit/os/fileio_spec.lua | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/test/unit/os/fileio_spec.lua b/test/unit/os/fileio_spec.lua index 5358022422..7a738ce85c 100644 --- a/test/unit/os/fileio_spec.lua +++ b/test/unit/os/fileio_spec.lua @@ -1,6 +1,7 @@ local lfs = require('lfs') -local helpers = require('test.unit.helpers') +local helpers = require('test.unit.helpers')(after_each) +local itp = helpers.gen_itp(it) local eq = helpers.eq local ffi = helpers.ffi @@ -88,7 +89,7 @@ local function file_skip(fp, size) end describe('file_open', function() - it('can create a rwx------ file with kFileCreate', function() + itp('can create a rwx------ file with kFileCreate', function() local err, fp = file_open(filec, m.kFileCreate, 448) eq(0, err) local attrs = lfs.attributes(filec) @@ -96,7 +97,7 @@ describe('file_open', function() eq(0, m.file_close(fp)) end) - it('can create a rw------- file with kFileCreate', function() + itp('can create a rw------- file with kFileCreate', function() local err, fp = file_open(filec, m.kFileCreate, 384) eq(0, err) local attrs = lfs.attributes(filec) @@ -104,7 +105,7 @@ describe('file_open', function() eq(0, m.file_close(fp)) end) - it('can create a rwx------ file with kFileCreateOnly', function() + itp('can create a rwx------ file with kFileCreateOnly', function() local err, fp = file_open(filec, m.kFileCreateOnly, 448) eq(0, err) local attrs = lfs.attributes(filec) @@ -112,7 +113,7 @@ describe('file_open', function() eq(0, m.file_close(fp)) end) - it('can create a rw------- file with kFileCreateOnly', function() + itp('can create a rw------- file with kFileCreateOnly', function() local err, fp = file_open(filec, m.kFileCreateOnly, 384) eq(0, err) local attrs = lfs.attributes(filec) @@ -120,47 +121,47 @@ describe('file_open', function() eq(0, m.file_close(fp)) end) - it('fails to open an existing file with kFileCreateOnly', function() + itp('fails to open an existing file with kFileCreateOnly', function() local err, _ = file_open(file1, m.kFileCreateOnly, 384) eq(m.UV_EEXIST, err) end) - it('fails to open an symlink with kFileNoSymlink', function() + itp('fails to open an symlink with kFileNoSymlink', function() local err, _ = file_open(linkf, m.kFileNoSymlink, 384) -- err is UV_EMLINK in FreeBSD, but if I use `ok(err == m.UV_ELOOP or err == -- m.UV_EMLINK)`, then I loose the ability to see actual `err` value. if err ~= m.UV_ELOOP then eq(m.UV_EMLINK, err) end end) - it('can open an existing file write-only with kFileCreate', function() + itp('can open an existing file write-only with kFileCreate', function() local err, fp = file_open(file1, m.kFileCreate, 384) eq(0, err) eq(true, fp.wr) eq(0, m.file_close(fp)) end) - it('can open an existing file read-only with zero', function() + itp('can open an existing file read-only with zero', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) eq(0, m.file_close(fp)) end) - it('can open an existing file read-only with kFileReadOnly', function() + itp('can open an existing file read-only with kFileReadOnly', function() local err, fp = file_open(file1, m.kFileReadOnly, 384) eq(0, err) eq(false, fp.wr) eq(0, m.file_close(fp)) end) - it('can open an existing file read-only with kFileNoSymlink', function() + itp('can open an existing file read-only with kFileNoSymlink', function() local err, fp = file_open(file1, m.kFileNoSymlink, 384) eq(0, err) eq(false, fp.wr) eq(0, m.file_close(fp)) end) - it('can truncate an existing file with kFileTruncate', function() + itp('can truncate an existing file with kFileTruncate', function() local err, fp = file_open(file1, m.kFileTruncate, 384) eq(0, err) eq(true, fp.wr) @@ -169,7 +170,7 @@ describe('file_open', function() eq(0, attrs.size) end) - it('can open an existing file write-only with kFileWriteOnly', function() + itp('can open an existing file write-only with kFileWriteOnly', function() local err, fp = file_open(file1, m.kFileWriteOnly, 384) eq(0, err) eq(true, fp.wr) @@ -178,14 +179,14 @@ describe('file_open', function() eq(4096, attrs.size) end) - it('fails to create a file with just kFileWriteOnly', function() + itp('fails to create a file with just kFileWriteOnly', function() local err, _ = file_open(filec, m.kFileWriteOnly, 384) eq(m.UV_ENOENT, err) local attrs = lfs.attributes(filec) eq(nil, attrs) end) - it('can truncate an existing file with kFileTruncate when opening a symlink', + itp('can truncate an existing file with kFileTruncate when opening a symlink', function() local err, fp = file_open(linkf, m.kFileTruncate, 384) eq(0, err) @@ -195,31 +196,31 @@ describe('file_open', function() eq(0, attrs.size) end) - it('fails to open a directory write-only', function() + itp('fails to open a directory write-only', function() local err, _ = file_open(dir, m.kFileWriteOnly, 384) eq(m.UV_EISDIR, err) end) - it('fails to open a broken symbolic link write-only', function() + itp('fails to open a broken symbolic link write-only', function() local err, _ = file_open(linkb, m.kFileWriteOnly, 384) eq(m.UV_ENOENT, err) end) - it('fails to open a broken symbolic link read-only', function() + itp('fails to open a broken symbolic link read-only', function() local err, _ = file_open(linkb, m.kFileReadOnly, 384) eq(m.UV_ENOENT, err) end) end) describe('file_open_new', function() - it('can open a file read-only', function() + itp('can open a file read-only', function() local err, fp = file_open_new(file1, 0, 384) eq(0, err) eq(false, fp.wr) eq(0, m.file_free(fp)) end) - it('fails to open an existing file with kFileCreateOnly', function() + itp('fails to open an existing file with kFileCreateOnly', function() local err, fp = file_open_new(file1, m.kFileCreateOnly, 384) eq(m.UV_EEXIST, err) eq(nil, fp) @@ -229,7 +230,7 @@ end) -- file_close is called above, so it is not tested directly describe('file_fsync', function() - it('can flush writes to disk', function() + itp('can flush writes to disk', function() local err, fp = file_open(filec, m.kFileCreateOnly, 384) eq(0, file_fsync(fp)) eq(0, err) @@ -244,7 +245,7 @@ describe('file_fsync', function() end) describe('file_read', function() - it('can read small chunks of input until eof', function() + itp('can read small chunks of input until eof', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) @@ -264,7 +265,7 @@ describe('file_read', function() eq(0, m.file_close(fp)) end) - it('can read the whole file at once', function() + itp('can read the whole file at once', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) @@ -273,7 +274,7 @@ describe('file_read', function() eq(0, m.file_close(fp)) end) - it('can read more then 1024 bytes after reading a small chunk', function() + itp('can read more then 1024 bytes after reading a small chunk', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) @@ -283,7 +284,7 @@ describe('file_read', function() eq(0, m.file_close(fp)) end) - it('can read file by 768-byte-chunks', function() + itp('can read file by 768-byte-chunks', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) @@ -305,7 +306,7 @@ describe('file_read', function() end) describe('file_write', function() - it('can write the whole file at once', function() + itp('can write the whole file at once', function() local err, fp = file_open(filec, m.kFileCreateOnly, 384) eq(0, err) eq(true, fp.wr) @@ -316,7 +317,7 @@ describe('file_write', function() eq(fcontents, io.open(filec):read('*a')) end) - it('can write the whole file by small chunks', function() + itp('can write the whole file by small chunks', function() local err, fp = file_open(filec, m.kFileCreateOnly, 384) eq(0, err) eq(true, fp.wr) @@ -333,7 +334,7 @@ describe('file_write', function() eq(fcontents, io.open(filec):read('*a')) end) - it('can write the whole file by 768-byte-chunks', function() + itp('can write the whole file by 768-byte-chunks', function() local err, fp = file_open(filec, m.kFileCreateOnly, 384) eq(0, err) eq(true, fp.wr) @@ -352,7 +353,7 @@ describe('file_write', function() end) describe('file_skip', function() - it('can skip 3 bytes', function() + itp('can skip 3 bytes', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) |