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 D8A8B49A0C4; Thu, 25 May 2023 20:33:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D8A8B49A0C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1685036004; bh=rpU5KXTyQd3LTQuoAT4pj1uUREZMfyKjre4zf4JmpYE=; 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=rehSOghiA/ga66/E9jQxPOlus8cxN4HJN0tXLF2IBw/lofctftC41TmZ/eKbL0OhC H3RNJsjV+6I1cf2YSyiqhg2qRqKOW0927iEb4VjjmVTFkQQ/MKt2EHIK4utyGj5o6f /snh6CiJxvo0hRXFX7NwqI87awQ3bvGLxbBIBSdo= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [95.163.41.82]) (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 5A2ED4457FA for ; Thu, 25 May 2023 20:33:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5A2ED4457FA Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1q2Eq1-004THy-F6; Thu, 25 May 2023 20:33:21 +0300 Message-ID: <1be152d0-9c74-0751-2473-2211ed32d625@tarantool.org> Date: Thu, 25 May 2023 20:33:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: Sergey Kaplun References: <4564f805b390388473afa982db5cf3235f1cbaad.1684442182.git.skaplun@tarantool.org> <467c6552-2cc8-7097-6d86-bb8c9628bb84@tarantool.org> 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: 4F1203BC0FB41BD9FA9FE7958A526B77309F3D27DFA702EA70EC4E5C3BB5181100894C459B0CD1B9D0D925DB00B496FBD18198D894A0C8B1A2E723F5D8B9D13FD2B9C3C88B730D5B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7EB05B7739F1E6D56EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DAE863916B47044D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83A33A90FCCE1943B556CD4A9B23279A8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC9ECA4966ACB4B5DBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735204B6963042765DA4B618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEFAD5A440E159F97D4DB3626BA78294CCD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE34E7D9683544204AF6136E347CC761E07C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063757B1FBEA53BC6EDBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-87b9d050: 1 X-C1DE0DAB: 0D63561A33F958A58F2E1EF63DFF869D48D3D79363BB8CE385DB178DECCC6924F87CCE6106E1FC07E67D4AC08A07B9B0A6C7FFFE744CA7FBCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF815D20B7E33F3A2E35F26CAF5B739510DF42FA44CA34E0C971E839F55E1431EAAF1510F4A86D2C811D9AEFA979736CF11449EAD4953F6E7C572F9B860E39E918F4E8A8FB6BF8EBF5 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojuzmi18dYIZGMBi9a/Hoa1w== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458F6B256E313BF3CF5837942C86DD0A319E1AC4DDBCF91F5B7282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B 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 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" Hi, Sergey! Thanks for fixes, see comments below. On 5/24/23 09:41, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the review! > > Fixed some of your comments, branch is force-pushed. > > 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! Nit: probably it is better "CMocka", because it is a proper name ("имя собственное") and should be with capital letters. Feel free to ignore. > >>> 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); > } > =================================================================== This test checks that macroses/functions in test.h could be called and nothing more. We need checking TAP output that binary will emit for different test statuses, plan, testcase counters ("1..10"). > >>> 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? Sure, let's skip. >>> ) >>> >>> 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. OK > >>> + >>> +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. OK > >> >>> +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: Good, thanks! > > =================================================================== > 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 >