Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Igor Munkin <imun@tarantool.org>,
	Sergey Ostanevich <sergos@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 3/3] test: adapt Lua 5.1 test suite for Tarantool
Date: Fri, 12 Mar 2021 08:36:24 +0300	[thread overview]
Message-ID: <054383ce45cad544e65b12df1af9320b5f999f73.1615472551.git.skaplun@tarantool.org> (raw)
In-Reply-To: <cover.1615472551.git.skaplun@tarantool.org>

In some insignificant details Tarantool's behaviour is not the same
as the behaviour of Lua 5.1.

`progname` is not edged by '"' to be able run other test suites.

Tests in the following files are disabled with corresponding comments:
* gc.lua
* main.lua
* pm.lua

See full list of disabled tests to adapt in
https://github.com/tarantool/tarantool/issues/5870.

Tests in the following files are adapted for testing with Tarantool's
out-of-source build:
* all.lua
* verybig.lua

Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Lua-5.1-tests/CMakeLists.txt |  3 +++
 test/PUC-Lua-5.1-tests/all.lua        | 16 ++++++++++++----
 test/PUC-Lua-5.1-tests/gc.lua         |  9 ++++++---
 test/PUC-Lua-5.1-tests/main.lua       | 24 +++++++++++++++++-------
 test/PUC-Lua-5.1-tests/pm.lua         |  6 +++++-
 test/PUC-Lua-5.1-tests/verybig.lua    |  4 +++-
 6 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/test/PUC-Lua-5.1-tests/CMakeLists.txt b/test/PUC-Lua-5.1-tests/CMakeLists.txt
index 08bee36..1249cab 100644
--- a/test/PUC-Lua-5.1-tests/CMakeLists.txt
+++ b/test/PUC-Lua-5.1-tests/CMakeLists.txt
@@ -82,6 +82,9 @@ add_custom_command(TARGET PUC-Lua-5.1-tests
     # LUA_INIT="package.path='?\;'..package.path"
     # So use less preferable way for tests.
     LUA_PATH="${LUA_PATH}\;\;"
+    # XXX: Adapt to run test on readonly file systems
+    # with loadfile(CUR_SOURCE_DIR..filename).
+    CUR_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
     ${LUAJIT_TEST_COMMAND} ${TEST_RUNNER}
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 )
diff --git a/test/PUC-Lua-5.1-tests/all.lua b/test/PUC-Lua-5.1-tests/all.lua
index 8c4afac..52a6235 100755
--- a/test/PUC-Lua-5.1-tests/all.lua
+++ b/test/PUC-Lua-5.1-tests/all.lua
@@ -58,9 +58,13 @@ end
 --
 -- redefine dofile to run files through dump/undump
 --
-dofile = function (n)
+-- Adapt test for testing with Tarantool's out-of-source build
+-- on read only file system. CUR_SOURCE_DIR is set via CMake.
+local path_to_sources = os.getenv('CUR_SOURCE_DIR')..'/'
+dofile = function (n, prefix)
+  local pr = prefix or path_to_sources
   showmem()
-  local f = assert(loadfile(n))
+  local f = assert(loadfile(pr..n))
   local b = string.dump(f)
   f = assert(loadstring(b))
   return f()
@@ -77,7 +81,9 @@ do
   end
 end
 
-local f = assert(loadfile('gc.lua'))
+-- Adapt test for testing with Tarantool's out-of-source build
+-- on read only file system.
+local f = assert(loadfile(path_to_sources..'gc.lua'))
 f()
 dofile('db.lua')
 assert(dofile('calls.lua') == deep and deep)
@@ -88,7 +94,9 @@ assert(dofile('locals.lua') == 5)
 dofile('constructs.lua')
 dofile('code.lua')
 do
-  local f = coroutine.wrap(assert(loadfile('big.lua')))
+  -- Adapt test for testing with Tarantool's out-of-source build
+  -- on read only file system.
+  local f = coroutine.wrap(assert(loadfile(path_to_sources..'big.lua')))
   assert(f() == 'b')
   assert(f() == 'a')
 end
diff --git a/test/PUC-Lua-5.1-tests/gc.lua b/test/PUC-Lua-5.1-tests/gc.lua
index b767104..6c4097a 100644
--- a/test/PUC-Lua-5.1-tests/gc.lua
+++ b/test/PUC-Lua-5.1-tests/gc.lua
@@ -128,9 +128,12 @@ do
     local a = {}
   until gcinfo() > 1000
   collectgarbage"restart"
-  repeat
-    local a = {}
-  until gcinfo() < 1000
+  -- Tarantool has too much objects at start.
+  -- gcinfo() is always greater than 1000.
+  -- Test is disabled for Tarantool binary.
+  -- repeat
+  --   local a = {}
+  -- until gcinfo() < 1000
 end
 
 lim = 15
diff --git a/test/PUC-Lua-5.1-tests/main.lua b/test/PUC-Lua-5.1-tests/main.lua
index 12f3981..69eb5db 100644
--- a/test/PUC-Lua-5.1-tests/main.lua
+++ b/test/PUC-Lua-5.1-tests/main.lua
@@ -11,7 +11,7 @@ out = os.tmpname()
 do
   local i = 0
   while arg[i] do i=i-1 end
-  progname = '"'..arg[i+1]..'"'
+  progname = arg[i+1]
 end
 print(progname)
 
@@ -50,8 +50,10 @@ end
 -- test 2 files
 prepfile("print(1); a=2")
 prepfile("print(a)", otherprog)
-RUN("lua -l %s -l%s -lstring -l io %s > %s", prog, otherprog, otherprog, out)
-checkout("1\n2\n2\n")
+-- Test is disabled for Tarantool binary.
+-- See https://github.com/tarantool/tarantool/issues/5747.
+-- RUN("lua -l %s -l%s -lstring -l io %s > %s", prog, otherprog, otherprog, out)
+-- checkout("1\n2\n2\n")
 
 local a = [[
   assert(table.getn(arg) == 3 and arg[1] == 'a' and
@@ -63,7 +65,10 @@ local a = [[
 ]]
 a = string.format(a, progname)
 prepfile(a)
-RUN('lua "-e " -- %s a b c', prog)
+-- Tarantool has different command line argument parsing.
+-- For example it always set itself as arg[-1].
+-- Test is disabled for Tarantool binary.
+-- RUN('lua "-e " -- %s a b c', prog)
 
 -- test 'arg' availability in libraries
 -- LuaJIT v2.1.0-beta3 has extension from Lua 5.3:
@@ -85,8 +90,10 @@ prepfile[[print(({...})[30])]]
 RUN("lua %s %s > %s", prog, string.rep(" a", 30), out)
 checkout("a\n")
 
-RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out)
-checkout("1\n3\n")
+-- Test is disabled for Tarantool binary.
+-- See https://github.com/tarantool/tarantool/issues/5747.
+-- RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out)
+-- checkout("1\n3\n")
 
 prepfile[[
   print(
@@ -177,7 +184,10 @@ assert(not os.remove(out))
 
 RUN("lua -v")
 
-NoRun("lua -h")
+-- Tarantool returns zero status at exit with -h option, unlike
+-- Lua does.
+-- Test is disabled for Tarantool binary.
+-- NoRun("lua -h")
 NoRun("lua -e")
 NoRun("lua -e a")
 NoRun("lua -f")
diff --git a/test/PUC-Lua-5.1-tests/pm.lua b/test/PUC-Lua-5.1-tests/pm.lua
index 366a31c..6e1b403 100644
--- a/test/PUC-Lua-5.1-tests/pm.lua
+++ b/test/PUC-Lua-5.1-tests/pm.lua
@@ -207,7 +207,11 @@ function rev (s)
 end
 
 local x = string.rep('012345', 10)
-assert(rev(rev(x)) == x)
+-- The first Tarantool's fiber has only 512Kb of stack.
+-- It is not enough for this recursive call.
+-- See also https://github.com/tarantool/tarantool/issues/5782.
+-- Test is disabled for Tarantool binary.
+-- assert(rev(rev(x)) == x)
 
 
 -- gsub with tables
diff --git a/test/PUC-Lua-5.1-tests/verybig.lua b/test/PUC-Lua-5.1-tests/verybig.lua
index 59e0142..bfb95df 100644
--- a/test/PUC-Lua-5.1-tests/verybig.lua
+++ b/test/PUC-Lua-5.1-tests/verybig.lua
@@ -93,7 +93,9 @@ for s in string.gmatch(prog, "$([^$]+)") do
   if not n then io.write(s) else F[n]() end
 end
 io.close()
-result = dofile(file)
+-- Adapt test for testing with Tarantool's out-of-source build
+-- on read only file system.
+result = dofile(file, "")
 assert(os.remove(file))
 print'OK'
 return result
-- 
2.28.0


  parent reply	other threads:[~2021-03-12  5:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12  5:36 [Tarantool-patches] [PATCH luajit 0/3] Adapt PUC-Rio Lua 5.1 test suite Sergey Kaplun via Tarantool-patches
2021-03-12  5:36 ` [Tarantool-patches] [PATCH luajit 1/3] test: add " Sergey Kaplun via Tarantool-patches
2021-03-16 13:35   ` Sergey Ostanevich via Tarantool-patches
2021-03-17 15:17     ` Igor Munkin via Tarantool-patches
2021-03-19 11:30       ` Sergey Kaplun via Tarantool-patches
2021-03-17 14:55   ` Igor Munkin via Tarantool-patches
2021-03-19 11:26     ` Sergey Kaplun via Tarantool-patches
2021-03-12  5:36 ` [Tarantool-patches] [PATCH luajit 2/3] test: adapt PUC-Rio Lua 5.1 test suite for LuaJIT Sergey Kaplun via Tarantool-patches
2021-03-13 19:04   ` Sergey Ostanevich via Tarantool-patches
2021-03-22 18:52   ` Igor Munkin via Tarantool-patches
2021-03-26  8:26     ` Sergey Kaplun via Tarantool-patches
2021-03-12  5:36 ` Sergey Kaplun via Tarantool-patches [this message]
2021-03-13 19:07   ` [Tarantool-patches] [PATCH luajit 3/3] test: adapt Lua 5.1 test suite for Tarantool Sergey Ostanevich via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=054383ce45cad544e65b12df1af9320b5f999f73.1615472551.git.skaplun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=sergos@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 3/3] test: adapt Lua 5.1 test suite for Tarantool' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox