Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mikhail Elhimov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
	Sergey Bronnikov <sergeyb@tarantool.org>,
	Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit v2 4/7] dbg: add tests of deferred extension loading
Date: Fri,  4 Dec 2026 23:03:05 +0300	[thread overview]
Message-ID: <57109696be66d147afa61212d6e85f2463c6fb95.1796410322.git.m.elhimov@vk.team> (raw)
In-Reply-To: <cover.1796410322.git.m.elhimov@vk.team>

---
 .../debug-extension-tests.py                  | 50 +++++++++++--------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/test/tarantool-debugger-tests/debug-extension-tests.py b/test/tarantool-debugger-tests/debug-extension-tests.py
index 75459378..c8eeabc0 100644
--- a/test/tarantool-debugger-tests/debug-extension-tests.py
+++ b/test/tarantool-debugger-tests/debug-extension-tests.py
@@ -40,6 +40,8 @@ if LLDB:
         'settings set target.disable-aslr false\n'
         'process launch'
     )
+    SET_EXEC = 'target create ' + LUAJIT_BINARY
+    SET_RUN_ARGS = 'settings set target.run-args'
     # Don't run any initialization scripts.
     RUN_CMD_FILE = [
         '--batch',
@@ -70,6 +72,8 @@ else:
     INFERIOR_ARGS = '--args'
     LOAD_EXTENSION = 'source ' + EXTENSION
     PROCESS_RUN = 'run'
+    SET_EXEC = 'file ' + LUAJIT_BINARY
+    SET_RUN_ARGS = 'set args'
     # Don't run any initialization scripts.
     RUN_CMD_FILE = ['--batch', '--nx', '--quiet', '--command']
 
@@ -169,42 +173,41 @@ elif machine == 'arm64' or machine == 'aarch64':
 
 class TestCaseBase(unittest.TestCase):
     @classmethod
-    def construct_cmds(cls):
-        return '\n'.join([
+    def construct_cmds(cls, deferred, *run_args):
+        cmds = [
+            SET_EXEC,
+            SET_RUN_ARGS + ' ' + ' '.join(run_args),
             'b {loc}'.format(loc=cls.location),
             PROCESS_RUN,
             'n',
-            LOAD_EXTENSION,
             cls.extension_cmds.strip(),
-            'q',
-        ])
-
-    @classmethod
-    def setUpClass(cls):
-        cmd_file = persist(cls.construct_cmds())
-        script_file = persist(cls.lua_script)
+        ]
+        # Load the extension either before or after LuaJIT symbols
+        # are loaded (which is done with SET_EXEC command), to be
+        # able to check that it works correctly in both cases.
+        cmds.insert(0 if deferred else 1, LOAD_EXTENSION)
+        return '\n'.join(cmds)
+
+    def check(self, deferred=False):
+        script_file = persist(self.lua_script)
+        cmd_file = persist(self.construct_cmds(deferred, script_file.name))
         process_cmd = [
             DEBUGGER,
             *RUN_CMD_FILE,
             cmd_file.name,
-            INFERIOR_ARGS,
-            LUAJIT_BINARY,
-            script_file.name,
         ]
         if TEST_VERBOSE:
-            print('# Test name: {}'.format(cls.__name__))
+            print('# Test name: {}'.format(self.__class__.__name__))
             print('# Test command: {}'.format(' '.join(process_cmd)))
-        cls.output = execute_process(process_cmd)
+        output = execute_process(process_cmd)
         if TEST_VERBOSE:
-            print('# Command output:\n{}'.format(cls.output))
+            print('# Command output:\n{}'.format(output))
         cmd_file.close()
         script_file.close()
-
-    def check(self):
         if LEGACY:
-            self.assertRegexpMatches(self.output, self.pattern.strip())
+            self.assertRegexpMatches(output, self.pattern.strip())
         else:
-            self.assertRegex(self.output, self.pattern.strip())
+            self.assertRegex(output, self.pattern.strip())
 
 
 # Test that the emitted debug information supports macro
@@ -1131,6 +1134,13 @@ def get_leaf_subclasses(cls):
 
 for test_cls in get_leaf_subclasses(TestCaseBase):
     test_cls.test = lambda self: self.check()
+    # Check each function functionality in deferred loading mode
+    # to be sure that all internal variables of the extension are
+    # initialized correctly.
+    test_cls.test_with_deferred_loading = \
+        unittest.skipIf(LLDB, "not supported for LLDB")(
+            lambda self: self.check(True)
+        )
 
 if __name__ == '__main__':
     unittest.main(verbosity=2)
-- 
2.55.0


  parent reply	other threads:[~2026-12-04 20:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 20:03 [Tarantool-patches] [PATCH luajit v2 0/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 1/7] dbg: simplify composing of all commands output Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 2/7] dbg: cleanup and unify `dbg.eval` Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 3/7] dbg: handle missing cmd arg in a dbg-agnostic way Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` Mikhail Elhimov via Tarantool-patches [this message]
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 5/7] dbg: avoid hardcoded enums Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 6/7] dbg: display fast function name along with ffid Mikhail Elhimov via Tarantool-patches
2026-12-04 20:03 ` [Tarantool-patches] [PATCH luajit v2 7/7] dbg: remove wrong GC state Mikhail Elhimov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57109696be66d147afa61212d6e85f2463c6fb95.1796410322.git.m.elhimov@vk.team \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=e.temirgaleev@tarantool.org \
    --cc=m.elhimov@vk.team \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2 4/7] dbg: add tests of deferred extension loading' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox