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 06BDC69B6E7; Wed, 1 Nov 2023 10:45:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 06BDC69B6E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1698824708; bh=bEZZy54hxXYyd+r317c/lTkYQEqEcurvw6LZcEkPJ2U=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LehA4RmyWagqGsIWufJ//Hhw3YXefwdmgjC3Av7C05GSoDWyzUYNBfDiyY2S7lVTo o+mKxe0aiiKyxNQIObXZdRjxyB33yMlcx6WLFozwPUMbAwmH0ADFcXWqElM80bVGKz sd7s4TV5o0yP832iOm8zO0bzo1+YQrnnnylDJWas= Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [95.163.41.80]) (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 5AB6C690FEF for ; Wed, 1 Nov 2023 10:45:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5AB6C690FEF Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1qy5uS-003mOH-2B; Wed, 01 Nov 2023 10:45:05 +0300 Date: Wed, 1 Nov 2023 10:40:33 +0300 To: Sergey Bronnikov Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C931D0C4A91E713083557E3423ADEC5AE5E3E16383004B8A00894C459B0CD1B9CF09335EA81774E137EFD036BB3BF675F71419CE7D4ACE8147030CE06FC90E99 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D6964C9E324ABA58EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637629A2DB6D7098C1B8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D850554F2FE867A643BB8A4DAE051C9F90117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD1828451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE0AC5B80A05675ACD9935A1E27F592749D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3F8BD4E506CFA3D88C0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB861051D4BA689FC2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F616AD31D0D18CD5CC6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5AAE9220412C684CD3D927028A297115BE59739D49F5063FFF87CCE6106E1FC07E67D4AC08A07B9B06A1CB4668A9CA5FACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF959D14DFDB5D0FF021E2266DB922DD06A34B2B0F4B5137D5067DA651B1817FB1500AA17B1AA25A4FD8551B728A548A99D69F2D02236D74BFD4C4C0BE23186DB9A74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojixD2AZzOsmMeVoai5gPYSA== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769D5E229D50DCF1F40490E39AC99F1301584876E3DC5E244DFDEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: max.kokryashkin@gmail.com, tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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/ > + __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/ > + __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. 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? 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. > #endif /* TARANTOOL_LUAJIT_TEST_H */ > -- > 2.34.1 > -- Best regards, Sergey Kaplun