[tarantool-patches] [PATCH] test: fix fio test when run by the root user

Alexander Turenko alexander.turenko at tarantool.org
Wed May 29 04:21:20 MSK 2019


We run testing in Travis-CI using docker, which by default enters into a
shell session as root.

This is follow up for e9c96a4c1afe28dac8beb9eed2d092e05b956366 ('fio:
fix mktree error reporting').
---

https://github.com/tarantool/tarantool/pull/4044
https://github.com/tarantool/tarantool/tree/Totktonada/gh-4044-fix-fio-test
https://travis-ci.org/tarantool/tarantool/builds/538518022

 test/app/fio.result   | 18 ++++++++++++------
 test/app/fio.test.lua | 12 ++++++++----
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/test/app/fio.result b/test/app/fio.result
index 7be76656a..8819e39fa 100644
--- a/test/app/fio.result
+++ b/test/app/fio.result
@@ -709,6 +709,12 @@ fio.mktree(tree2, tonumber('0777', 8))
 - true
 ...
 -- check mktree error reporting
+--
+-- The test is skipped for the super user, because it has ability
+-- to perform any file access despite file permissions.
+uid = ffi.C.getuid()
+---
+...
 tmp3 = fio.pathjoin(tmpdir, '5')
 ---
 ...
@@ -726,11 +732,11 @@ tree123 = fio.pathjoin(tmp3, '1/2/3')
 st, err = fio.mktree(tree123)
 ---
 ...
-st
+uid == 0 or st == false
 ---
-- false
+- true
 ...
-err:match('Permission denied') ~= nil
+uid == 0 or err:match('Permission denied') ~= nil
 ---
 - true
 ...
@@ -740,11 +746,11 @@ tree4 = fio.pathjoin(tmp3, '4')
 st, err = fio.mktree(tree4)
 ---
 ...
-st
+uid == 0 or st == false
 ---
-- false
+- true
 ...
-err:match('Permission denied') ~= nil
+uid == 0 or err:match('Permission denied') ~= nil
 ---
 - true
 ...
diff --git a/test/app/fio.test.lua b/test/app/fio.test.lua
index a1db9e2f4..6c0d2f478 100644
--- a/test/app/fio.test.lua
+++ b/test/app/fio.test.lua
@@ -227,17 +227,21 @@ fio.stat(tmp2) ~= nil
 fio.mktree(tree2, tonumber('0777', 8))
 
 -- check mktree error reporting
+--
+-- The test is skipped for the super user, because it has ability
+-- to perform any file access despite file permissions.
+uid = ffi.C.getuid()
 tmp3 = fio.pathjoin(tmpdir, '5')
 fio.mkdir(tmp3)
 fio.chmod(tmp3, tonumber('500', 8))
 tree123 = fio.pathjoin(tmp3, '1/2/3')
 st, err = fio.mktree(tree123)
-st
-err:match('Permission denied') ~= nil
+uid == 0 or st == false
+uid == 0 or err:match('Permission denied') ~= nil
 tree4 = fio.pathjoin(tmp3, '4')
 st, err = fio.mktree(tree4)
-st
-err:match('Permission denied') ~= nil
+uid == 0 or st == false
+uid == 0 or err:match('Permission denied') ~= nil
 
 -- copy and copytree
 file1 = fio.pathjoin(tmp1, 'file.1')
-- 
2.21.0





More information about the Tarantool-patches mailing list