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 AA4696DDCD5; Fri, 10 Nov 2023 14:40:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AA4696DDCD5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1699616426; bh=na/j/wk6TJnfcJn3lPeIk98FQ0Y2sW2CSBgYAJ9+Pjs=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=e19uQHwxjG0Otu+UOVLnnhmk+4mcVhtSNXKaGRjFLN18IgoRfhz3jluHW1mWErZKq DVWtGsB1MKXrk1Y+xDpVLNgkAojbqPiSAkBqFtXqt9CELt3kjQMcyjVIZkaXX3IzBM FpAZAeza13c7PsRvpmqnzqw7UywNtbXeT1ytbSgI= Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [95.163.41.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 D94B46DDCD5 for ; Fri, 10 Nov 2023 14:40:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D94B46DDCD5 Received: by smtp33.i.mail.ru with esmtpa (envelope-from ) id 1r1Ps8-00FQnX-2e; Fri, 10 Nov 2023 14:40:25 +0300 Message-ID: Date: Fri, 10 Nov 2023 14:40:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun , Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org, max.kokryashkin@gmail.com References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C2A6B03AB739174C8B8ADBDCDAD54AB847BB7A66D7B1BE8200894C459B0CD1B998F58FBEF056C1BC67A5E0582502C377D6BA8C4D3EAF433A492007A4EDD3F072 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F1942E6D70B4A2F0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D81244D2CF6B2D5F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80CFF090D2E69CBF13E7D20068733088C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B19100238FE36DC7A2D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3632EDEA9CD5989A36136E347CC761E07C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CD2DCF9CF1F528DBC2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F0A35B161A8BF67C16D8C47C27EEC5E9FB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5CEC01685493128BE9CAE827606ED8659420AFC664287F976F87CCE6106E1FC07E67D4AC08A07B9B0A6C7FFFE744CA7FBCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D342B1F2AD168155B06B0FDB45E09C643268B19EBAC818254D54B1A4E47D43C7C5918F158FE424B66E81D7E09C32AA3244CB6A60EFB62A4E660A5C0F4CC8A73D77FA995755A1445935EBAD658CF5C8AB4025DA084F8E80FEBD3FFA33E6B6B2F82C47A83BD0C44CE203720ABEDE4BBDD9CDD X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj1d5ULkquG7x0jQHSJAND4A== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769F22D0F3B5BA7772677A2E18B5DB660531E1E156D000DABDBEBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] test: introduce asserts assert_str{_not}_equal 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" Hi, Sergey changes applied and force-pushed. On 11/1/23 10:40, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the patch! > Please, consider my comments below. > > On 31.10.23, Sergey Bronnikov wrote: >> From: Sergey Bronnikov >> >> The patch follows up commit a0483bd214f2 ("test: introduce module for C >> tests") and adds additional asserts suitable for comparing strings. >> --- >> test/tarantool-c-tests/README.md | 2 ++ >> test/tarantool-c-tests/test.h | 17 +++++++++++++++-- >> 2 files changed, 17 insertions(+), 2 deletions(-) >> >> diff --git a/test/tarantool-c-tests/README.md b/test/tarantool-c-tests/README.md > > >> diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h >> index 8b14c705..bbf573b2 100644 >> --- a/test/tarantool-c-tests/test.h >> +++ b/test/tarantool-c-tests/test.h > > >> @@ -214,4 +212,19 @@ static inline int todo(const char *reason) >> ); \ >> } while (0) >> >> +#define assert_str_equal(got, expected, n) do { \ >> + assert_general(strncmp(got, expected, n) == 0, \ >> + ASSERT_EQUAL_FMT(int, "%d"), \ > Typo: s/int/str/ Fixed, thanks. > >> + __FILE__, __LINE__, (got), (expected) \ >> + ); \ >> +} while (0) >> + >> +#define assert_str_not_equal(got, unexpected, n) do { \ >> + assert_general(strncmp(got, expected, n) != 0, \ >> + ASSERT_NOT_EQUAL_FMT(int, "%d"), \ > Typo: s/int/str/ Fixed, thanks. >> + __FILE__, __LINE__, (got), (unexpected) \ >> + ); \ >> +} while (0) > If some test fails we got the following output: > > | TAP version 13 > | 1..1 > | not ok 1 - lua_concat_testcase > | --- > | location: /home/burii/reviews/luajit/lj-881-lua-concat/test/tarantool-c-tests/lj-881-fix-lua-concat.test.c:81 > | failed_assertion: assert_str_equal > | got: 1652880104 > | expected: -1138225337 > | ... > | # Failed 1 tests out of 1 > > Failed assertion field is incorrect (see the comment above). > But the most important is "got" and "expected" fields, that returns the > addresses of strings, which isn't very meaningful. > > I suggest dumping the strings instead if they are not long enough (less > than 128 symbols, I suppose). The maxdump string length should be > a customizeable parameter. I suggest defining a macro `MAX_DUMP_STRLEN` > inside the header. So the user can redefine it before the > `assert_str_{not_}equal()` and use a custom value. I don't like your idea for the same reasons described by Igor. > If the string is too long, we should dump the offset of the mismatched > symbol. Or maybe it's better to always dump it. > > Thoughts? Now implementation of `assert_str_{not}_equal` is good enough for proposed test. Don't get why we should think about comparison of long strings. We could update assert implementation as soon it will be required by other tests, now it is not  required. > > Side note: > > Also, this comparing "by eye" isn't very convenient if values aren't > aligned, so maybe it is better to use spaces instead of tabs to align > values? This may be added within the separate patch series later. > >> + >> + > Nit: Excess empty line. Fixed, thanks. > >> #endif /* TARANTOOL_LUAJIT_TEST_H */ >> -- >> 2.34.1 >>