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 C77F6485702; Thu, 18 May 2023 23:49:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C77F6485702 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1684442942; bh=7BZmCQ7jMZ9KhCTTJ+i9mekZLKiCELYf3qRf+vpa+oE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OLNIm6wKB/PrkAfOULxvVBmjUft1kwCDklpW/KbNYjaa/jZp2DhXjfF6C1OrMl3k1 k7z3F2uy4vpf1MdCePo5ch7Inbq0D4UeDsBtkLXlY8B0JRpI4d/TMaJFM3GkSwi2k8 NE9FHw9GAXn/4WgDii+z5WyYk++Pwz6gSIqzBxLg= 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 963BA45E87A for ; Thu, 18 May 2023 23:49:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 963BA45E87A Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1pzkYV-0005wh-7g; Thu, 18 May 2023 23:48:59 +0300 To: Igor Munkin , Maxim Kokryashkin , Sergey Bronnikov Date: Thu, 18 May 2023 23:44:47 +0300 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD921E8753A900160F1CF01BC910163A817574ED0228E619E23182A05F538085040F41B71BA7639DE38664BAEFE3A4B47B378110E7C5A0B95EBC2F4E2A851470F1C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7624C4D757C4F5837EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379CBE0668FF2CDAD68638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80116EBC7396DA6BD24FB720D901F3C49117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC93A51A5089774A2DA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520CCD848CCB6FE560CBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B67393CE827C55B5F775ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5BF91620D6739567FDDE4659982D14559D19DE1EF39016576F87CCE6106E1FC07E67D4AC08A07B9B0735DFC8FA7AC12079C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF8FACCDC113A9EA958E210ABD7B5709AF93EAD83B5D09F40E26BDE0234B201EDDF33D08354E2B7C920DBD3925112B781E7710B20FC0A773036D825A50C1CF613506EEC8038AF5C160 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXj50lcc1fbFd4IaFIsN4drb X-DA7885C5: 87DBC7F5B2C07115117DE7BC9A9FF824B4C76422CDC3EBBE1A196A34F2C80DE4262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73933AF1F914F131DBF537BCB95B719800D103B3CD37224060580FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 0/6] Revorking 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" The whole idea of the patch-set introduce module for LuaJIT C tests. It also, can be used for unit tests. * The first patch is the prerequisite for the patch-set. It fixes LD_LIBRARY_PATH definition. * The 2nd and 3d patches provides an API and helper for writing the tests. * The last 3 patches rewrite existing tests that should be written in C in the proper way. Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-noticket-tarantool-c-tests PR: https://github.com/tarantool/tarantool/pull/8444 Related Issue: * https://github.com/tarantool/tarantool/issues/7900 * https://github.com/tarantool/tarantool/issues/781 Thanks Maxim, for the review! I've fixed some Maxim comments and suggestions for the previous series. Some ignorable comments about wording are ignored:). Also, see answers for your questions below: > >+if(NOT PROVE) > >+ message(WARNING "`prove' is not found, so tarantool-c-tests target is not generated") > >+ return() > >+endif() > There is the same check in the test/tarantool-tests/CMakeLists.txt. Maybe > we should move it to the higher-level CMake so the lower-level CMakeLists > inherit it. I agree it maybe done, but not within this particular patchsett, so ignoring for now. > >+#define test_run_group(t_arr, t_state) \ > >+ _test_run_group(__func__, t_arr, lengthof(t_arr), t_state) > Is there any reason for it to be a macro and not a function wrapper? > I believe it is better to use the functions when possible, since they are > easier to support and debug. Just for the convenience in usage of __func__ macro as a test group name. > >+/* Need for `strchr()` in diagnostic parsing. */ > `strchr()` is not safe, despite the fact it searches till `\0`. > We should at least replace it with `memchr()`, which has > the explicit constraint for buffer length. > >+#include Yes, but: 1) We use it only for our test code, where we set this `\0` directly to mark EOL. 2) It's simplier than use several marks in buffer. So, ignoring for now. > >+# vim: ft=cmake expandtab shiftwidth=2: tabstop=2: > That change is not necessary. Yes, but more convenient to use in vim -- since our usual codestyle isn't 4 tabs as its default for CMake. :) Still we don't use it anywhere (unfortunately), so removed. > >+ bail_out("failed to translate Lua code snippet"); > Why `bail_out` and not an assertion? Here and below. Assertion is for some thing we wnat to test and may fail. Bail out usage is more specific: | As an emergency measure a test script can decide that further tests are | useless (e.g. missing dependencies) and testing should stop immediately. | In that case the test script prints the magic words See [1]. I think that loading Lua script helper (dependency) is something like that. > >+#include "lj_arch.h" > Side note: I don't like the approach with private headers, but > I couldn't find any better way to check that. Maybe it is a good > idea to implement a public C API function to get the information > about OS and ARCH, since it is a really common to check them? I think, that this is the best option, espessialy if we want to write some unit test for some specific module (I mean ). Changes in v2: 1) use | int _test_run_group(const char *group_name, const struct test_unit tests[], | size_t n_tests, void *test_state); instead of | int _test_run_group(const char *group_name, const struct test_unit *tests, | size_t n_tests, void *test_state); 2) `skip()` `skip_all()` and `todo()` helpers now return values to be return to runner. i.e. change usage from | if (cond) | skip("NIY"); to | if (cond) | return skip("NIY"); `bail_out()` helper still just exits with error code, which corresponding its standard specification. But now some parts of the code start to look "alya cringe": | return todo("Need to replace backtrace with libunwind first"); | lua_State *L = test_state; | utils_get_aux_lfunc(L); | (void)luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF); | (void)luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_FLUSH); | check_profile_func(L); | (void)luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_ON); | return TEST_EXIT_SUCCESS; (Yes, we want to use unconditional `todo()`). So I commented the similar code, helper `check_profile_func()`, etc. with `#if 0`. 3) In 4th patch use subtest group for snap-related tests to skip all at once with disabled JIT. 4) lj-49-bad-lightuserdata is moved in C tests, too. Sergey Kaplun (6): test: fix setting of {DY}LD_LIBRARY_PATH variables test: introduce module for C tests test: introduce utils.h helper for C tests test: rewrite misclib-getmetrics-capi test in C test: rewrite misclib-sysprof-capi test in C test: rewrite lj-49-bad-lightuserdata test in C .gitignore | 1 + src/CMakeLists.txt | 2 + test/CMakeLists.txt | 2 + test/tarantool-c-tests/CMakeLists.txt | 65 ++++ .../lj-49-bad-lightuserdata.test.c} | 47 +-- .../misclib-getmetrics-capi-script.lua} | 83 ++--- .../misclib-getmetrics-capi.test.c | 343 ++++++++++++++++++ .../misclib-sysprof-capi-script.lua | 35 ++ .../misclib-sysprof-capi.test.c | 325 +++++++++++++++++ test/tarantool-c-tests/test.c | 251 +++++++++++++ test/tarantool-c-tests/test.h | 217 +++++++++++ test/tarantool-c-tests/utils.h | 63 ++++ test/tarantool-tests/CMakeLists.txt | 12 +- .../lj-49-bad-lightuserdata.test.lua | 11 - .../lj-49-bad-lightuserdata/CMakeLists.txt | 1 - .../misclib-getmetrics-capi/CMakeLists.txt | 1 - .../misclib-getmetrics-capi/testgetmetrics.c | 270 -------------- .../misclib-sysprof-capi.test.lua | 54 --- .../misclib-sysprof-capi/CMakeLists.txt | 1 - .../misclib-sysprof-capi/testsysprof.c | 260 ------------- 20 files changed, 1374 insertions(+), 670 deletions(-) create mode 100644 test/tarantool-c-tests/CMakeLists.txt rename test/{tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c => tarantool-c-tests/lj-49-bad-lightuserdata.test.c} (55%) rename test/{tarantool-tests/misclib-getmetrics-capi.test.lua => tarantool-c-tests/misclib-getmetrics-capi-script.lua} (68%) create mode 100644 test/tarantool-c-tests/misclib-getmetrics-capi.test.c create mode 100644 test/tarantool-c-tests/misclib-sysprof-capi-script.lua create mode 100644 test/tarantool-c-tests/misclib-sysprof-capi.test.c create mode 100644 test/tarantool-c-tests/test.c create mode 100644 test/tarantool-c-tests/test.h create mode 100644 test/tarantool-c-tests/utils.h delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata.test.lua delete mode 100644 test/tarantool-tests/lj-49-bad-lightuserdata/CMakeLists.txt delete mode 100644 test/tarantool-tests/misclib-getmetrics-capi/CMakeLists.txt delete mode 100644 test/tarantool-tests/misclib-getmetrics-capi/testgetmetrics.c delete mode 100644 test/tarantool-tests/misclib-sysprof-capi.test.lua delete mode 100644 test/tarantool-tests/misclib-sysprof-capi/CMakeLists.txt delete mode 100644 test/tarantool-tests/misclib-sysprof-capi/testsysprof.c -- 2.34.1