From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org,
Sergey Kaplun <skaplun@tarantool.org>,
Maxim Kokryashkin <m.kokryashkin@tarantool.org>
Subject: [Tarantool-patches] [PATCH luajit 2/4][v2] test: introduce a helper read_file
Date: Thu, 11 Apr 2024 16:22:04 +0300 [thread overview]
Message-ID: <9234535074cc11e0682353c0e5e865bb22cd88f0.1712841312.git.sergeyb@tarantool.org> (raw)
In-Reply-To: <cover.1712841312.git.sergeyb@tarantool.org>
From: Sergey Bronnikov <sergeyb@tarantool.org>
The test `lj-366-strtab-correct-size.test.lua` has a test helper
`read_file` that reads a file's content and returns it.
This helper will be useful for a test upcoming in the next commit,
so it is moved to test tools.
Needed for tarantool/tarantool#9595
---
.../lj-366-strtab-correct-size.test.lua | 13 +++----------
test/tarantool-tests/utils/tools.lua | 8 ++++++++
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/test/tarantool-tests/lj-366-strtab-correct-size.test.lua b/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
index 8a97a441..580fce09 100644
--- a/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
+++ b/test/tarantool-tests/lj-366-strtab-correct-size.test.lua
@@ -9,6 +9,7 @@ local test = tap.test('lj-366-strtab-correct-size'):skipcond({
})
local ffi = require 'ffi'
+local utils = require('utils')
-- Command below exports bytecode as an object file in ELF format:
-- $ luajit -b -n 'lango_team' -e 'print()' xxx.obj
@@ -130,7 +131,7 @@ local is64 = is64_arch[jit.arch]
local function create_obj_file(name)
local elf_filename = os.tmpname() .. '.obj'
local lua_path = os.getenv('LUA_PATH')
- local lua_bin = require('utils').exec.luacmd(arg):match('%S+')
+ local lua_bin = utils.exec.luacmd(arg):match('%S+')
local cmd_fmt = 'LUA_PATH="%s" %s -b -n "%s" -e "print()" %s'
local cmd = (cmd_fmt):format(lua_path, lua_bin, name, elf_filename)
local ret = os.execute(cmd)
@@ -138,14 +139,6 @@ local function create_obj_file(name)
return elf_filename
end
--- Reads a file located in a specified path and returns its content.
-local function read_file(path)
- local file = assert(io.open(path), 'cannot open an object file')
- local content = file:read('*a')
- file:close()
- return content
-end
-
-- Parses a buffer in an ELF format and returns an offset and a size of strtab
-- and symtab sections.
local function read_elf(elf_content)
@@ -172,7 +165,7 @@ end
test:plan(3)
local elf_filename = create_obj_file(MODULE_NAME)
-local elf_content = read_file(elf_filename)
+local elf_content = require('utils').tools.read_file(elf_filename)
assert(#elf_content ~= 0, 'cannot read an object file')
local strtab, symtab = read_elf(elf_content)
diff --git a/test/tarantool-tests/utils/tools.lua b/test/tarantool-tests/utils/tools.lua
index f35c6922..a2556e32 100644
--- a/test/tarantool-tests/utils/tools.lua
+++ b/test/tarantool-tests/utils/tools.lua
@@ -12,4 +12,12 @@ function M.profilename(name)
return (arg[0]:gsub('^(.+)/([^/]+)%.test%.lua$', replacepattern))
end
+-- Reads a file located at a specified path and returns its content.
+function M.read_file(path)
+ local file = assert(io.open(path), 'cannot open an object file')
+ local content = file:read('*a')
+ file:close()
+ return content
+end
+
return M
--
2.34.1
next prev parent reply other threads:[~2024-04-11 15:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 13:22 [Tarantool-patches] [PATCH luajit 0/4][v2] Mach-O generation fixes Sergey Bronnikov via Tarantool-patches
2024-04-11 13:22 ` [Tarantool-patches] [PATCH luajit 1/4][v2] ci: add a workflow for testing with AVX512 Sergey Bronnikov via Tarantool-patches
2024-04-12 10:27 ` Sergey Kaplun via Tarantool-patches
2024-04-16 11:53 ` Sergey Bronnikov via Tarantool-patches
2024-04-18 8:24 ` Sergey Kaplun via Tarantool-patches
2024-05-05 12:29 ` Maxim Kokryashkin via Tarantool-patches
2024-06-14 13:55 ` Sergey Bronnikov via Tarantool-patches
2024-06-14 15:24 ` Sergey Bronnikov via Tarantool-patches
2024-04-11 13:22 ` Sergey Bronnikov via Tarantool-patches [this message]
2024-04-12 10:47 ` [Tarantool-patches] [PATCH luajit 2/4][v2] test: introduce a helper read_file Sergey Kaplun via Tarantool-patches
2024-04-16 12:02 ` Sergey Bronnikov via Tarantool-patches
2024-06-20 12:14 ` Sergey Bronnikov via Tarantool-patches
2024-04-11 13:22 ` [Tarantool-patches] [PATCH luajit 3/4][v2] OSX/iOS/ARM64: Fix generation of Mach-O object files Sergey Bronnikov via Tarantool-patches
2024-04-12 11:19 ` Sergey Kaplun via Tarantool-patches
2024-04-16 15:29 ` Sergey Bronnikov via Tarantool-patches
2024-06-13 15:50 ` Sergey Bronnikov via Tarantool-patches
2024-04-11 13:22 ` [Tarantool-patches] [PATCH luajit 4/4][v2] OSX/iOS/ARM64: Fix bytecode embedding in Mach-O object file Sergey Bronnikov via Tarantool-patches
2024-04-12 11:27 ` Sergey Kaplun via Tarantool-patches
2024-06-13 15:40 ` Sergey Bronnikov via Tarantool-patches
2024-06-13 15:47 ` Sergey Bronnikov via Tarantool-patches
2024-06-20 10:15 ` [Tarantool-patches] [PATCH luajit 0/4][v2] Mach-O generation fixes Sergey Kaplun via Tarantool-patches
2024-07-09 8:07 ` Sergey Kaplun 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=9234535074cc11e0682353c0e5e865bb22cd88f0.1712841312.git.sergeyb@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=estetus@gmail.com \
--cc=m.kokryashkin@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit 2/4][v2] test: introduce a helper read_file' \
/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