[Lldb-commits] [lldb] 6bbdecc - [lldb][NFC] Make TestStats.py not an inline test

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 6 18:48:18 PST 2020


Author: Raphael Isemann
Date: 2020-03-06T18:47:59-08:00
New Revision: 6bbdecc5cf8096148df4726245f3bc60e464c76b

URL: https://github.com/llvm/llvm-project/commit/6bbdecc5cf8096148df4726245f3bc60e464c76b
DIFF: https://github.com/llvm/llvm-project/commit/6bbdecc5cf8096148df4726245f3bc60e464c76b.diff

LOG: [lldb][NFC] Make TestStats.py not an inline test

There is still the bug that empty lines seem to skip any following expressions
and it makes it harder to commend between all the comments. Let's make this
a normal test instead which is just slightly more verbose but can be properly
formatted.

Added: 
    lldb/test/API/commands/statistics/basic/Makefile

Modified: 
    lldb/test/API/commands/statistics/basic/TestStats.py
    lldb/test/API/commands/statistics/basic/main.c

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/statistics/basic/Makefile b/lldb/test/API/commands/statistics/basic/Makefile
new file mode 100644
index 000000000000..c9319d6e6888
--- /dev/null
+++ b/lldb/test/API/commands/statistics/basic/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules

diff  --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index 9f5c7172a65b..4809adf9060f 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -1,5 +1,32 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
 
-lldbinline.MakeInlineTest(
-    __file__, globals(), [decorators.no_debug_info_test])
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def test(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
+
+        self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
+
+        # 'expression' should change the statistics.
+        self.expect("statistics enable")
+        self.expect("statistics enable", substrs=['already enabled'], error=True)
+        self.expect("expr patatino", substrs=['27'])
+        self.expect("statistics disable")
+        self.expect("statistics dump", substrs=['expr evaluation successes : 1',
+                                                'expr evaluation failures : 0'])
+
+        # 'frame var' with disabled statistics shouldn't change stats.
+        self.expect("frame var", substrs=['27'])
+
+        self.expect("statistics enable")
+        # 'frame var' with enabled statistics will change stats.
+        self.expect("frame var", substrs=['27'])
+        self.expect("statistics disable")
+        self.expect("statistics dump", substrs=['frame var successes : 1',
+                                                'frame var failures : 0'])

diff  --git a/lldb/test/API/commands/statistics/basic/main.c b/lldb/test/API/commands/statistics/basic/main.c
index 9adb3a09a080..2c5b4f5f098e 100644
--- a/lldb/test/API/commands/statistics/basic/main.c
+++ b/lldb/test/API/commands/statistics/basic/main.c
@@ -2,17 +2,6 @@
 
 int main(void) {
   int patatino = 27;
-  //%self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True)
-  //%self.expect("statistics enable")
-  //%self.expect("statistics enable", substrs=['already enabled'], error=True)
-  //%self.expect("expr patatino", substrs=['27'])
-  //%self.expect("statistics disable")
-  //%self.expect("statistics dump", substrs=['expr evaluation successes : 1', 'expr evaluation failures : 0'])
-  //%self.expect("frame var", substrs=['27'])
-  //%self.expect("statistics enable")
-  //%self.expect("frame var", substrs=['27'])
-  //%self.expect("statistics disable")
-  //%self.expect("statistics dump", substrs=['frame var successes : 1', 'frame var failures : 0'])
 
-  return 0;
+  return 0; // break here
 }


        


More information about the lldb-commits mailing list