[Tarantool-patches] [PATCH luajit v5 2/2] test: add tests for debugging extensions

Sergey Bronnikov sergeyb at tarantool.org
Tue Dec 19 11:16:22 MSK 2023


Hi, Max!

many thanks for the patch! LGTM with a a number of minor comments,

please see below.


Sergey


On 12/6/23 17:14, Maxim Kokryashkin wrote:
> From: Maksim Kokryashkin <max.kokryashkin at gmail.com>
>
> This patch adds tests for LuaJIT debugging
> extensions for lldb and gdb.
> ---
>   .flake8rc                                     |   4 +
>   src/luajit_dbg.py                             |  11 +-
>   test/CMakeLists.txt                           |   3 +
>   .../CMakeLists.txt                            | 102 +++++++
>   .../debug-extension-tests.py                  | 262 ++++++++++++++++++
>   5 files changed, 376 insertions(+), 6 deletions(-)
>   create mode 100644 test/LuaJIT-debug-extensions-tests/CMakeLists.txt
>   create mode 100644 test/LuaJIT-debug-extensions-tests/debug-extension-tests.py
<snipped>
>   
>   if(LUAJIT_USE_TEST)
> diff --git a/test/LuaJIT-debug-extensions-tests/CMakeLists.txt b/test/LuaJIT-debug-extensions-tests/CMakeLists.txt
> new file mode 100644
> index 00000000..78eafd02
> --- /dev/null
> +++ b/test/LuaJIT-debug-extensions-tests/CMakeLists.txt
> @@ -0,0 +1,102 @@
> +add_custom_target(LuaJIT-gdb-extension-tests
> +  DEPENDS ${LUAJIT_TEST_BINARY}
> +)
> +
> +add_custom_target(LuaJIT-lldb-extension-tests
> +  DEPENDS ${LUAJIT_TEST_BINARY}
> +)
> +
> +set(DUMMY_GDB_MSG "LuaJIT-gdb-extension-tests is a dummy target")
> +set(DUMMY_LLDB_MSG "LuaJIT-lldb-extension-tests is a dummy target")
> +
> +# Debug info is required for testing of extensions.
> +if(NOT (CMAKE_BUILD_TYPE MATCHES Debug))
> +  message(WARNING
> +    "not a DEBUG build, LuaJIT-lldb-extension-tests and "
> +    "LuaJIT-gdb-extension-tests are dummy"
> +  )
> +  add_custom_command(TARGET LuaJIT-gdb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_GDB_MSG}
> +  )
> +  add_custom_command(TARGET LuaJIT-lldb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_LLDB_MSG}
> +  )
> +  return()
> +endif()
> +
> +# MacOS asks for permission to debug a process even when the
> +# machine is set into development mode. To solve the issue,
> +# it is required to add relevant users to the `_developer` user
> +# group in MacOS. Disabled for now.
> +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED ENV{CI})
> +  message(WARNING
> +    "Interactive debugging is unavailable for macOS CI builds,"
> +    "LuaJIT-lldb-extension-tests is dummy"
> +  )
> +  add_custom_command(TARGET LuaJIT-lldb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_LLDB_MSG}
> +  )
> +  return()
> +endif()
> +
> +find_package(PythonInterp)

CMake Warning (dev) at 
test/LuaJIT-debug-extensions-tests/CMakeLists.txt:30 (find_package):
   Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs 
modules
   are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
   the cmake_policy command to set the policy and suppress this warning.

This warning is for project developers.  Use -Wno-dev to suppress it.

See https://cmake.org/cmake/help/latest/policy/CMP0148.html

Let's fix this warning.



> +if(NOT PYTHONINTERP_FOUND)
> +  message(WARNING
> +    "`python` is not found, LuaJIT-lldb-extension-tests and "
> +    "LuaJIT-gdb-extension-tests are dummy"
> +  )
> +  add_custom_command(TARGET LuaJIT-gdb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_GDB_MSG}
> +  )
> +  add_custom_command(TARGET LuaJIT-lldb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_LLDB_MSG}
> +  )
> +  return()
> +endif()
> +
> +set(DEBUGGER_TEST_ENV
> +  "LUAJIT_TEST_BINARY=${LUAJIT_TEST_BINARY}"
> +  # Suppresses __pycache__ generation.
> +  "PYTHONDONTWRITEBYTECODE=1"
> +  "DEBUGGER_EXTENSION_PATH=${PROJECT_SOURCE_DIR}/src/luajit_dbg.py"
> +)
> +
> +set(TEST_SCRIPT_PATH
> +  ${PROJECT_SOURCE_DIR}/test/LuaJIT-debug-extensions-tests/debug-extension-tests.py
> +)
> +
> +find_program(GDB gdb)
> +if(GDB)
> +  set(GDB_TEST_ENV ${DEBUGGER_TEST_ENV}
> +    "DEBUGGER_COMMAND=${GDB}"
> +  )
> +  add_custom_command(TARGET LuaJIT-gdb-extension-tests
> +    COMMENT "Running luajit_dbg.py tests with gdb"
Nit: I would omit a filename in a comment
> +    COMMAND
> +    ${GDB_TEST_ENV} ${PYTHON_EXECUTABLE} ${TEST_SCRIPT_PATH}
> +    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> +  )
> +else()
> +  message(WARNING "`gdb' is not found, so LuaJIT-gdb-extension-tests is dummy")
> +  add_custom_command(TARGET LuaJIT-gdb-extension-tests
> +    COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red ${DUMMY_GDB_MSG}
> +  )
> +endif()
> +
> +find_program(LLDB lldb)
> +if(LLDB)
> +  set(LLDB_TEST_ENV ${DEBUGGER_TEST_ENV}
> +    "DEBUGGER_COMMAND=${LLDB}"
> +  )
> +  add_custom_command(TARGET LuaJIT-lldb-extension-tests
> +    COMMENT "Running luajit_dbg.py tests with lldb"

Nit: I would omit a filename in a comment


> +
<snipped>
> +
> +for test_cls in TestCaseBase.__subclasses__():
> +    test_cls.test = lambda self: self.check()
> +
> +if __name__ == '__main__':
> +    unittest.main(verbosity=2)

there are three verbosity levels: quiet (0), default (1) and verbose (3).

I would left a comment that "2" is a verbose level.

Feel free to ignore.



More information about the Tarantool-patches mailing list