[lldb][NFC] Make TestStats.py not an inline test
authorRaphael Isemann <teemperor@gmail.com>
Sat, 7 Mar 2020 02:42:20 +0000 (18:42 -0800)
committerRaphael Isemann <teemperor@gmail.com>
Sat, 7 Mar 2020 02:47:59 +0000 (18:47 -0800)
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.

lldb/test/API/commands/statistics/basic/Makefile [new file with mode: 0644]
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/commands/statistics/basic/main.c

diff --git a/lldb/test/API/commands/statistics/basic/Makefile b/lldb/test/API/commands/statistics/basic/Makefile
new file mode 100644 (file)
index 0000000..c9319d6
--- /dev/null
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
index 9f5c717..4809adf 100644 (file)
@@ -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'])
index 9adb3a0..2c5b4f5 100644 (file)
@@ -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
 }