119 lines · python
1"""2Test that argdumper is a viable launching strategy.3"""4import os5 6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12 13class LaunchWithShellExpandTestCase(TestBase):14 NO_DEBUG_INFO_TESTCASE = True15 16 @expectedFailureAll(17 oslist=["windows", "linux", "freebsd"],18 bugnumber="llvm.org/pr24778 llvm.org/pr22627 llvm.org/pr48349",19 )20 @skipIfDarwinEmbedded # iOS etc don't launch the binary via a shell, so arg expansion won't happen21 @expectedFailureNetBSD22 def test(self):23 self.build()24 target = self.createTestTarget()25 26 # Create any breakpoints we need27 breakpoint = target.BreakpointCreateBySourceRegex(28 "break here", lldb.SBFileSpec("main.cpp", False)29 )30 self.assertTrue(breakpoint, VALID_BREAKPOINT)31 32 # Ensure we do the expansion with /bin/sh on POSIX.33 os.environ["SHELL"] = "/bin/sh"34 35 self.runCmd(36 "process launch -X true -w %s -- fi*.tx? () > <" % (self.getSourceDir())37 )38 39 process = self.process()40 41 self.assertState(42 process.GetState(), lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT43 )44 45 thread = process.GetThreadAtIndex(0)46 47 self.assertTrue(48 thread.IsValid(), "Process stopped at 'main' should have a valid thread"49 )50 51 stop_reason = thread.GetStopReason()52 53 self.assertEqual(54 stop_reason,55 lldb.eStopReasonBreakpoint,56 "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint",57 )58 59 self.expect_var_path("argv[1]", summary='"file1.txt"')60 self.expect_var_path("argv[2]", summary='"file2.txt"')61 self.expect_var_path("argv[3]", summary='"file3.txt"')62 self.expect_var_path("argv[4]", summary='"file4.txy"')63 self.expect_var_path("argv[5]", summary='"()"')64 self.expect_var_path("argv[6]", summary='">"')65 self.expect_var_path("argv[7]", summary='"<"')66 self.expect_var_path("argc", value="8")67 68 self.runCmd("process kill")69 70 self.runCmd('process launch -X true -w %s -- "foo bar"' % (self.getSourceDir()))71 72 process = self.process()73 74 self.assertState(75 process.GetState(), lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT76 )77 78 thread = process.GetThreadAtIndex(0)79 80 self.assertTrue(81 thread.IsValid(), "Process stopped at 'main' should have a valid thread"82 )83 84 stop_reason = thread.GetStopReason()85 86 self.assertEqual(87 stop_reason,88 lldb.eStopReasonBreakpoint,89 "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint",90 )91 92 self.expect("frame variable argv[1]", substrs=["foo bar"])93 94 self.runCmd("process kill")95 96 self.runCmd(r"process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))97 98 process = self.process()99 100 self.assertState(101 process.GetState(), lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT102 )103 104 thread = process.GetThreadAtIndex(0)105 106 self.assertTrue(107 thread.IsValid(), "Process stopped at 'main' should have a valid thread"108 )109 110 stop_reason = thread.GetStopReason()111 112 self.assertEqual(113 stop_reason,114 lldb.eStopReasonBreakpoint,115 "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint",116 )117 118 self.expect("frame variable argv[1]", substrs=["foo bar"])119