From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 806C2AFE34D; Thu, 11 Apr 2024 18:25:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 806C2AFE34D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1712849158; bh=VDq2RRlGrRMKirerKmOItqYMyyBxH5OQh1yCLOrlwTI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=UmAdsu4i59dZJHRFNhaKAmy1cNlE/ADRIDcpa+V8Ib1rsveHdpCu2F7G5d+NrisTV izJ36YVK/kHEpFLvukUEtZXu8VEvFtAfmUeNmVTiDVcDsqefSRoFqrKerUjkNV1TlD GyQWqwjN8Qvf9vmgxsDFaRC8url3I2zqKpAxeiyg= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id BE4C0AFE34C for ; Thu, 11 Apr 2024 18:25:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BE4C0AFE34C Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5171a529224so5520887e87.0 for ; Thu, 11 Apr 2024 08:25:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712849136; x=1713453936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kZ1FDKf4C+grJ8cclM6oHw9v5dZrzv5jL/q4D23+fF8=; b=dekopfBN5RRPK+OqjCUZrqA+Ds6Z3MDqUvcUAPP6M9DIuxLmpcxsRerXnPbaXjoOL5 DR9PIr6oGLPAILkJdw/JB/fEx+1RvK8W8ZqXFTwiRRQBAmPEdcQhmt7BWos66prvlmud GO1ACmnqUaEgP8eaHyzkv7ZR6YiJAdf1zhW5Sk7B0InvsoBibE/HXl4bPWd9quZkUsEK MwXpsxurp1Th84ir42VnMXWIuh/hsF8NLX/cbsgScx4hXTxSboVgIO9KjbfQGQPi7JYd uQbHVOatVTpgoDx2Q3fpYhrupvEiklatfeh+En8WXHw8gFp02DVxjB0xWBD5QIziRhTj tk4g== X-Gm-Message-State: AOJu0YzrsK+fT452x7kKPbh7o3bVoRs5FbS+zSFi4kYp04CfwfogIHjp FRdgh73fj5pg1I2DN1wWjzN4xMZo9GWC41jUF3HTd0zdjImfSxiGpFrI6Q== X-Google-Smtp-Source: AGHT+IENok6ekUauJVzNNdMHKKJ0sAP32xAm823WfDiaKFu/ZW6F6B0UnH4N4bhrxhzlhyfHguhbuw== X-Received: by 2002:a19:385b:0:b0:513:172d:5b46 with SMTP id d27-20020a19385b000000b00513172d5b46mr32304lfj.39.1712849135661; Thu, 11 Apr 2024 08:25:35 -0700 (PDT) Received: from pony.. ([5.181.62.126]) by smtp.gmail.com with ESMTPSA id b5-20020ac25e85000000b00516d6419a70sm235623lfq.85.2024.04.11.08.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:25:35 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , Maxim Kokryashkin Date: Thu, 11 Apr 2024 16:22:04 +0300 Message-Id: <9234535074cc11e0682353c0e5e865bb22cd88f0.1712841312.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 2/4][v2] test: introduce a helper read_file X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Sergey Bronnikov 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