Author: adrian Date: Tue Dec 18 14:17:38 2018 New Revision: 349550 URL: http://llvm.org/viewvc/llvm-project?rev=349550&view=rev Log: TestHelloWorld: Use a file on the target platform for synchronisation.
Thanks to Pavel Labath for the idea! Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=349550&r1=349549&r2=349550&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py Tue Dec 18 14:17:38 2018 @@ -10,8 +10,7 @@ import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - +import lldbsuite.test.lldbutil as lldbutil class HelloWorldTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -88,8 +87,12 @@ class HelloWorldTestCase(TestBase): target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(exe, ["abc", "xyz"]) + token = exe+'.token' + if os.path.exists(token): + os.remove(token) + popen = self.spawnSubprocess(exe, [token]) self.addTearDownHook(self.cleanupSubprocesses) + lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() @@ -98,11 +101,10 @@ class HelloWorldTestCase(TestBase): self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Let's check the stack traces of the attached process. - import lldbsuite.test.lldbutil as lldbutil stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, substrs=['main.c:%d' % self.line2, - '(int)argc=3']) + '(int)argc=2']) @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24600") @@ -115,9 +117,13 @@ class HelloWorldTestCase(TestBase): self.setTearDownCleanup(dictionary=d) target = self.dbg.CreateTarget(exe) - # Spawn a new process - popen = self.spawnSubprocess(exe, ["abc", "xyz"]) + # Spawn a new process. + token = exe+'.token' + if os.path.exists(token): + os.remove(token) + popen = self.spawnSubprocess(exe, [token]) self.addTearDownHook(self.cleanupSubprocesses) + lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() @@ -132,7 +138,6 @@ class HelloWorldTestCase(TestBase): target.ConnectRemote(listener, None, None, error) process = target.AttachToProcessWithName(listener, name, False, error) - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Verify that after attach, our selected target indeed matches name. @@ -142,8 +147,7 @@ class HelloWorldTestCase(TestBase): startstr=name) # Let's check the stack traces of the attached process. - import lldbsuite.test.lldbutil as lldbutil stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, substrs=['main.c:%d' % self.line2, - '(int)argc=3']) + '(int)argc=2']) Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c?rev=349550&r1=349549&r2=349550&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c (original) +++ lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/main.c Tue Dec 18 14:17:38 2018 @@ -8,16 +8,22 @@ int main(int argc, char const *argv[]) { - lldb_enable_attach(); + lldb_enable_attach(); - printf("Hello world.\n"); // Set break point at this line. - if (argc == 1) - return 0; + printf("Hello world.\n"); // Set break point at this line. + if (argc == 1) + return 1; - // Waiting to be attached by the debugger, otherwise. - char line[100]; - while (1) - sleep (1); // Waiting to be attached... + // Create the synchronization token. + FILE *f; + if (f = fopen(argv[1], "wx")) { + fputs("\n", f); + fflush(f); + fclose(f); + } else + return 1; - printf("Exiting now\n"); + // Waiting to be attached by the debugger, otherwise. + while (1) + sleep(1); // Waiting to be attached... } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits