Index: packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py =================================================================== --- packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py +++ packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py @@ -58,11 +58,11 @@ thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") - # First, capture the golden output from the program itself from the - # series of printf statements. - stdout = process.GetSTDOUT(1024) - - self.assertIsNotNone(stdout, "Encountered an error reading the process's output") + # First, capture the golden output from the program itself. + golden = thread.GetFrameAtIndex(0).FindVariable("golden") + self.assertTrue(golden.IsValid(), "Encountered an error reading the process's golden variable") + golden_str = str(golden) + self.assertTrue("c_as_C" in golden_str) # This golden list contains a list of "my_expr = 'value' pairs extracted # from the golden output. @@ -72,7 +72,7 @@ # # my_expr = 'value' # - for line in stdout.split(os.linesep): + for line in golden_str.split(os.linesep): match = self.pattern.search(line) if match: my_expr, val = match.group(1), match.group(2) Index: packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp =================================================================== --- packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp +++ packages/Python/lldbsuite/test/lang/cpp/virtual/main.cpp @@ -1,5 +1,4 @@ -#include -#include +#include class A { @@ -84,18 +83,19 @@ C *c_as_C = new C(); A *c_as_A = c_as_C; - printf ("a_as_A->a() = '%s'\n", a_as_A->a()); - printf ("a_as_A->b() = '%s'\n", a_as_A->b()); - printf ("a_as_A->c() = '%s'\n", a_as_A->c()); - printf ("b_as_A->a() = '%s'\n", b_as_A->a()); - printf ("b_as_A->b() = '%s'\n", b_as_A->b()); - printf ("b_as_A->c() = '%s'\n", b_as_A->c()); - printf ("b_as_B->aa() = '%s'\n", b_as_B->aa()); - printf ("c_as_A->a() = '%s'\n", c_as_A->a()); - printf ("c_as_A->b() = '%s'\n", c_as_A->b()); - printf ("c_as_A->c() = '%s'\n", c_as_A->c()); - printf ("c_as_C->aa() = '%s'\n", c_as_C->aa()); - puts("");// Set first breakpoint here. + std::string golden; + golden += std::string("a_as_A->a() = '") + a_as_A->a() + "'\n"; + golden += std::string("a_as_A->b() = '") + a_as_A->b() + "'\n"; + golden += std::string("a_as_A->c() = '") + a_as_A->c() + "'\n"; + golden += std::string("b_as_A->a() = '") + b_as_A->a() + "'\n"; + golden += std::string("b_as_A->b() = '") + b_as_A->b() + "'\n"; + golden += std::string("b_as_A->c() = '") + b_as_A->c() + "'\n"; + golden += std::string("b_as_B->aa() = '") + b_as_B->aa() + "'\n"; + golden += std::string("c_as_A->a() = '") + c_as_A->a() + "'\n"; + golden += std::string("c_as_A->b() = '") + c_as_A->b() + "'\n"; + golden += std::string("c_as_A->c() = '") + c_as_A->c() + "'\n"; + golden += std::string("c_as_C->aa() = '") + c_as_C->aa() + "'\n"; + return 0;// Set first breakpoint here. // then evaluate: // expression a_as_A->a() // expression a_as_A->b() @@ -108,6 +108,4 @@ // expression c_as_A->b() // expression c_as_A->c() // expression c_as_C->aa() - - return 0; }