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 8DC6C4695FD; Wed, 24 May 2023 09:45:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8DC6C4695FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1684910740; bh=CbZLRqOFlC5fErpG1Vrsz0cJnt7IOK7iCy4pHDvUKjA=; 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=HbC3vg24VAC6TnslLPtxNddj5jpfVAkbwgHMaaA1A8KBqKqaEWCygvEisiY+3/Y/1 QtJ3FRfl3vcA+55X5sOeBuxEsc4GCTJCjmEg/VUHU0IZLr3Tv8UVUNzLVmcXB1wWSE SFy85hL5zuJyIFDMVE3rAl5HN/JP2UT8mbhrpngY= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [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 A69FE464E99 for ; Wed, 24 May 2023 09:45:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A69FE464E99 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1q1iFe-0006Vw-K8; Wed, 24 May 2023 09:45:39 +0300 Date: Wed, 24 May 2023 09:41:33 +0300 To: Sergey Bronnikov Message-ID: References: <4564f805b390388473afa982db5cf3235f1cbaad.1684442182.git.skaplun@tarantool.org> <467c6552-2cc8-7097-6d86-bb8c9628bb84@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <467c6552-2cc8-7097-6d86-bb8c9628bb84@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9318AAE2601AA39B8CDDE39D04FBBDEACD358682397C8999C00894C459B0CD1B94B7426201E0691D83F7CF0B736077A503F65E5CC60B9D595B2E6FBEB60789C2A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72AC9FB60380F23AEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B323FE155BC226618638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85C046AA42296959E5CED3FCA37FB2454117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF070A1BC70AFFF2BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735200AC5B80A05675ACD618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0D75EB778CE7D8A0C68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CFA80D66F452D417A43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5F23EDD27EB7327078B0E24D588854588C3B1C5A2907FCEFCF87CCE6106E1FC07E67D4AC08A07B9B06A1CB4668A9CA5FACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF3896A65362CF3DA37960A14C3AFA434E94FE263C0B2733746BC3EFE02CC1C931F09515A9A3E4BB8DD5191E2618EE498C08DCF8A9C7CE472A4D7F1D1B242F3D89F4E8A8FB6BF8EBF5 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj7RK+RruQK1dYdLyVyYdWLA== X-DA7885C5: 98F6EC7F906792DF7469A5B7D14CDF1904E71FEC6084D03342B51E158A10613D262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986B44A44E6E2A527DF8F34AE71BFF84A64D0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 2/6] test: introduce module for C tests 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: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review! Fixed some of your comments, branch is force-pushed. On 22.05.23, Sergey Bronnikov wrote: > Hi, Sergey! > > > Thanks for the patch! Please see my comments inline. > > > On 5/18/23 23:44, Sergey Kaplun wrote: > > We need an instrument to write tests in plain C for LuaJIT, to be able: > > * easily test LuaC API > > * test patches without usage of plain Lua > > * write unit tests > > * startup LuaJIT with custom memory allocator, to test some GC issues > > * maybe, in future, use custom hashing function to test a behavior > > of LuaJIT tables > > and so on. > > Unexpected newline, put this on a previous line. Fixed. > > > > > The module serves to achieve these goals without too fancy > > features. > > > > It's functionality inspired by cmoka API [1], but only TAP14 [2] > typo: cmocka Fixed, thanks! > > protocol is supported (Version of TAP set to 13 to be compatible with > > old TAP13 harnesses). > > Please add tests for TAP13/TAP14 conformance testing. > > It would be unpleasant if proposed library will produce TAP-incompatible > output and it will break parsing in 'prove'. > > At least single test for passed testcase "ok", single testcase for > failed "not ok" testcase, one testcase for every directive. I've added the tests for ok|skip|todo. "not ok" is skipped, because it rather tricky to test it behaviour via prove without test failure. The content of is the following: =================================================================== #include "test.h" #define UNUSED(x) ((void)(x)) static int test_ok(void *test_state) { UNUSED(test_state); return TEST_EXIT_SUCCESS; } static int test_skip(void *test_state) { UNUSED(test_state); return skip("test skip"); } static int test_todo(void *test_state) { UNUSED(test_state); return todo("test todo"); } int main(void) { const struct test_unit tgroup[] = { test_unit_new(test_ok), test_unit_new(test_skip), test_unit_new(test_todo) }; return test_run_group(tgroup, NULL); } =================================================================== > > > The group of unit tests is declared like the following: > > > > [1]: https://github.com/clibs/cmocka > > [2]: https://testanything.org/tap-version-14-specification.html > > > > Part of tarantool/tarantool#7900 > > --- > > test/CMakeLists.txt | 2 + > > test/tarantool-c-tests/CMakeLists.txt | 41 +++++ > > test/tarantool-c-tests/test.c | 251 ++++++++++++++++++++++++++ > > test/tarantool-c-tests/test.h | 217 ++++++++++++++++++++++ > > 4 files changed, 511 insertions(+) > > create mode 100644 test/tarantool-c-tests/CMakeLists.txt > > create mode 100644 test/tarantool-c-tests/test.c > > create mode 100644 test/tarantool-c-tests/test.h > > > > diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt > > index a8262b12..47296a22 100644 > > --- a/test/CMakeLists.txt > > +++ b/test/CMakeLists.txt > > @@ -48,12 +48,14 @@ separate_arguments(LUAJIT_TEST_COMMAND) > > add_subdirectory(LuaJIT-tests) > > add_subdirectory(PUC-Rio-Lua-5.1-tests) > > add_subdirectory(lua-Harness-tests) > > +add_subdirectory(tarantool-c-tests) > > add_subdirectory(tarantool-tests) > > > > add_custom_target(${PROJECT_NAME}-test DEPENDS > > LuaJIT-tests > > PUC-Rio-Lua-5.1-tests > > lua-Harness-tests > > + tarantool-c-tests > > tarantool-tests > Should we rename tarantool-tests to tarantool-lua-tests in a separate > commit? Maybe, but I don't really want to do it since inconsistencies with Tarantool's integration suite, so I suppose we can leave it as is, can't we? > > ) > > > > diff --git a/test/tarantool-c-tests/CMakeLists.txt b/test/tarantool-c-tests/CMakeLists.txt > > new file mode 100644 > > index 00000000..c6b7cd30 > > --- /dev/null > > +++ b/test/tarantool-c-tests/CMakeLists.txt > > @@ -0,0 +1,41 @@ > > +find_program(PROVE prove) > > +if(NOT PROVE) > > + message(WARNING "`prove' is not found, so tarantool-c-tests target is not generated") > > + return() > > +endif() > > copy-pasted from test/tarantool-tests/CMakeLists.txt, I would place it > to test/CMakeLists.txt. > > At least searching prove (find_program(PROVE prove)). As, discussed here [1], this refactoring should be the part of the separate pachset. > > > + > > +set(C_TEST_SUFFIX .c_test) > > Lua tests in test/tarantool-tests have prefix ".test.lua". > > Should we use here ".test.c" for consistency? "c_test" is the suffix for executable files. ".test.c" is used for test files themselves. > > > > +set(C_TEST_FLAGS --failures --shuffle) > > + > > diff --git a/test/tarantool-c-tests/test.c b/test/tarantool-c-tests/test.c > > new file mode 100644 > > index 00000000..74cba3a3 > > --- /dev/null > > +++ b/test/tarantool-c-tests/test.c > > diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h > > new file mode 100644 > > index 00000000..28df9daf > > --- /dev/null > > +++ b/test/tarantool-c-tests/test.h > > @@ -0,0 +1,217 @@ > > +#ifndef TEST_H > > +#define TEST_H > I would use prefix to avoid intersection with another headers. For > example "TARANTOOL_TEST_H" or something else. Replaced with TARANTOOL_LUAJIT_TEST_H. See the iterative patch below: =================================================================== diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h index 28df9daf..047f01a5 100644 --- a/test/tarantool-c-tests/test.h +++ b/test/tarantool-c-tests/test.h @@ -1,5 +1,5 @@ -#ifndef TEST_H -#define TEST_H +#ifndef TARANTOOL_LUAJIT_TEST_H +#define TARANTOOL_LUAJIT_TEST_H #include #include @@ -214,4 +214,4 @@ static inline int todo(const char *reason) ); \ } while (0) -#endif /* TEST_H */ +#endif /* TARANTOOL_LUAJIT_TEST_H */ =================================================================== Same for utils header: =================================================================== diff --git a/test/tarantool-c-tests/utils.h b/test/tarantool-c-tests/utils.h index cf668006..f651f7f6 100644 --- a/test/tarantool-c-tests/utils.h +++ b/test/tarantool-c-tests/utils.h @@ -1,3 +1,6 @@ +#ifndef TARANTOOL_LUAJIT_TEST_UTILS_H +#define TARANTOOL_LUAJIT_TEST_UTILS_H + #include #include @@ -61,3 +64,5 @@ static void utils_lua_close(lua_State *L) if (!lua_isfunction((L), -1)) \ bail_out("Can't get auxiliary test function"); \ } while (0) + +#endif /* TARANTOOL_LUAJIT_TEST_UTILS_H */ =================================================================== > > + > > +#endif /* TEST_H */ [1]: https://lists.tarantool.org/pipermail/tarantool-patches/2023-May/027577.html -- Best regards, Sergey Kaplun