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 1E6636465D; Thu, 21 Jan 2021 19:23:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1E6636465D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611246207; bh=V+R0AMY1VPfdzhggVA5Ry4X6z0O5yDUMwIH39oM/en8=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lhKW1GpJdNrCOp77kJUpFJqC6Hl+DtX52ZN0rGbcSHiBBkAk6m3cqOphInesW1ghc YOeymUmW6F/vOi6Ro2qNuhE2JLx56uXY78EknDBqdHsyLDUOd8zVfa3vDraZIztTlv M+sj+d5NeNealNokJGQmUMwJFS7Uf2YiG+i1FR4I= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 38F5F6465D for ; Thu, 21 Jan 2021 19:23:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 38F5F6465D Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1l2ck1-0005Ud-3E; Thu, 21 Jan 2021 19:23:25 +0300 To: Artem Starshov , Alexander Turenko References: Message-ID: <5ac4ae75-ce23-3f84-e91d-f0c4f4a50763@tarantool.org> Date: Thu, 21 Jan 2021 19:23:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9FAB20BF8F07590368A3B0CD810054B7D9DADA0D25F7A2C51182A05F5380850404BE2E4CA2BD8DF7C161E488DB3BA9770473851DF4DB3FAA4891C58007E6289D8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7544B1CCE26E01C74EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375AC38C7EC4509C8B8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCED83AE98076C068AB32CA3B5533DD11DFBF56C89D470B69B389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92A417C69337E82CC2CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC39F82E19B0A6E84575ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4931B544F03EFBC4D57BEFCD6C56BCFE9CEC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5CA480B41DC778EC0B76BB9810F83DE7069490AE7271DD25AD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA754DBC578B17CB11D78E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346BEB6F73FB9D1E4A729173C2A3239243A0CE613FD19A93B269A132D42775777E2EB92BD4E578BAB31D7E09C32AA3244CC037790A07ADF022978B74B7EDBC580BF522A1CF68F4BE05927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojYT//mZRaUegq1uB9LVZMkQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822CB4998FB4BFFD0A92C9CD0BEC1654DEEDD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCHv4 3/3] test: change -e assert(false) test using process_timeout module 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! LGTM I see no reasons to chaneg for latest two patches. At least review would be much more easier with a single patch. On 18.01.2021 15:45, Artem Starshov wrote: > Removed definitions of functions with timeout. Now they are used > from separated module process_timeout.lua > > Follows up #4983 > --- > .../gh-4983-tnt-e-assert-false-hangs.test.lua | 62 +++---------------- > 1 file changed, 9 insertions(+), 53 deletions(-) > > diff --git a/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua b/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua > index c8313770e..20046d7a5 100755 > --- a/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua > +++ b/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua > @@ -1,61 +1,17 @@ > #!/usr/bin/env tarantool > > -local fiber = require('fiber') > -local clock = require('clock') > -local ffi = require('ffi') > -local fio = require('fio') > -local errno = require('errno') > +-- Using io.popen and self written module process_timeout > +-- in presence of the 'popen' built-in module because the > +-- last one isn't available in 1.10 > +local process_timeout = require('process_timeout') > local tap = require('tap') > +local fio = require('fio') > +local ffi = require('ffi') > > -- > -- gh-4983: tarantool -e 'assert(false)' hangs > -- > > --- For process_is_alive. > -ffi.cdef([[ > - int kill(pid_t pid, int sig); > -]]) > - > ---- Verify whether a process is alive. > -local function process_is_alive(pid) > - local rc = ffi.C.kill(pid, 0) > - return rc == 0 or errno() ~= errno.ESRCH > -end > - > ---- Returns true if process completed before timeout, false otherwise. > -local function wait_process_completion(pid, timeout) > - local start_time = clock.monotonic() > - local process_completed = false > - while clock.monotonic() - start_time < timeout do > - if not process_is_alive(pid) then > - process_completed = true > - break > - end > - end > - return process_completed > -end > - > ---- Open file on reading with timeout. > -local function open_with_timeout(filename, timeout) > - local fh > - local start_time = clock.monotonic() > - while not fh and clock.monotonic() - start_time < timeout do > - fh = fio.open(filename, {'O_RDONLY'}) > - end > - return fh > -end > - > ---- Try to read from file with timeout with interval. > -local function read_with_timeout(fh, timeout, interval) > - local data = '' > - local start_time = clock.monotonic() > - while #data == 0 and clock.monotonic() - start_time < timeout do > - data = fh:read() > - if #data == 0 then fiber.sleep(interval) end > - end > - return data > -end > - > local TARANTOOL_PATH = arg[-1] > local output_file = fio.abspath('out.txt') > local line = ('%s -e "assert(false)" > %s 2>&1 & echo $!'): > @@ -73,7 +29,7 @@ local res = tap.test('gh-4983-tnt-e-assert-false-hangs', function(test) > local pid = tonumber(io.popen(line):read('*line')) > assert(pid, 'pid of proccess can\'t be recieved') > > - local process_completed = wait_process_completion(pid, > + local process_completed = process_timeout.wait_process_completion(pid, > process_waiting_timeout) > > test:ok(process_completed, > @@ -82,10 +38,10 @@ local res = tap.test('gh-4983-tnt-e-assert-false-hangs', function(test) > -- Kill process if hangs. > if not process_completed then ffi.C.kill(pid, 9) end > > - local fh = open_with_timeout(output_file, file_open_timeout) > + local fh = process_timeout.open_with_timeout(output_file, file_open_timeout) > assert(fh, 'error while opening ' .. output_file) > > - local data = read_with_timeout(fh, file_read_timeout, file_read_interval) > + local data = process_timeout.read_with_timeout(fh, file_read_timeout, file_read_interval) > test:like(data, 'assertion failed', 'assertion failure is displayed') > > fh:close()