[PATCH v4 3/3] test: app/fio -- Add ERRINJ_COIO_SENDFILE_CHUNK
Cyrill Gorcunov
gorcunov at gmail.com
Wed Apr 17 00:40:34 MSK 2019
To test sendfile work in a cycle -- force transferring 1 byte at once.
---
v4: These files are quite small so test with 1 byte chunk to force
sendfile cycle.
test/app/fio.result | 23 +++++++++++++++++++++++
test/app/fio.test.lua | 8 ++++++++
2 files changed, 31 insertions(+)
diff --git a/test/app/fio.result b/test/app/fio.result
index 486cb8043..879e0a767 100644
--- a/test/app/fio.result
+++ b/test/app/fio.result
@@ -718,6 +718,9 @@ file2 = fio.pathjoin(tmp2, 'file.2')
file3 = fio.pathjoin(tree, 'file.3')
---
...
+file4 = fio.pathjoin(tree, 'file.4')
+---
+...
fh1 = fio.open(file1, { 'O_RDWR', 'O_TRUNC', 'O_CREAT' }, 0777)
---
...
@@ -752,6 +755,26 @@ fio.stat(fio.pathjoin(tmp2, "file.1")) ~= nil
---
- true
...
+--- test copyfile to operate with one byte transfer
+errinj = box.error.injection
+---
+...
+errinj.set('ERRINJ_COIO_SENDFILE_CHUNK', 1)
+---
+- ok
+...
+fio.copyfile(file1, file4)
+---
+- true
+...
+fio.stat(file1, file4) ~= nil
+---
+- true
+...
+errinj.set('ERRINJ_COIO_SENDFILE_CHUNK', -1)
+---
+- ok
+...
res, err = fio.copyfile(fio.pathjoin(tmp1, 'not_exists.txt'), tmp1)
---
...
diff --git a/test/app/fio.test.lua b/test/app/fio.test.lua
index 9af37044d..1255b2804 100644
--- a/test/app/fio.test.lua
+++ b/test/app/fio.test.lua
@@ -230,6 +230,7 @@ fio.mktree(tree2, 0777)
file1 = fio.pathjoin(tmp1, 'file.1')
file2 = fio.pathjoin(tmp2, 'file.2')
file3 = fio.pathjoin(tree, 'file.3')
+file4 = fio.pathjoin(tree, 'file.4')
fh1 = fio.open(file1, { 'O_RDWR', 'O_TRUNC', 'O_CREAT' }, 0777)
fh1:write("gogo")
@@ -241,6 +242,13 @@ fio.symlink(file1, file3)
fio.copyfile(file1, tmp2)
fio.stat(fio.pathjoin(tmp2, "file.1")) ~= nil
+--- test copyfile to operate with one byte transfer
+errinj = box.error.injection
+errinj.set('ERRINJ_COIO_SENDFILE_CHUNK', 1)
+fio.copyfile(file1, file4)
+fio.stat(file1, file4) ~= nil
+errinj.set('ERRINJ_COIO_SENDFILE_CHUNK', -1)
+
res, err = fio.copyfile(fio.pathjoin(tmp1, 'not_exists.txt'), tmp1)
res
err:match("failed to copy") ~= nil
--
2.20.1
More information about the Tarantool-patches
mailing list