diff options
author | Davide Italiano <davide@freebsd.org> | 2018-04-16 22:55:34 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-04-16 22:55:34 +0000 |
commit | 4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8 (patch) | |
tree | 8c2d82677652c1e77ba491e8300fbac934cc51c7 /lldb/packages/Python/lldbsuite/test | |
parent | 9c86a313076351134cd1e4f2a604466d7c0974b4 (diff) | |
download | bcm5719-llvm-4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8.tar.gz bcm5719-llvm-4a6a2b1ce313f0901c8c1e03a8c62fa0f7f526d8.zip |
[Commands] Expose statistics through the SBAPI.
The API is `SBStructuredData GetStatistics()`. This allows
the command to be used in scripts.
<rdar://problem/36555975>
llvm-svn: 330165
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
3 files changed, 34 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile new file mode 100644 index 00000000000..f5a47fcc46c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py new file mode 100644 index 00000000000..e3e1cba3aec --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py @@ -0,0 +1,28 @@ +# Test the SBAPI for GetStatistics() + +import json +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestStatsAPI(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + + def test_stats_api(self): + self.build() + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + stats = target.GetStatistics() + stream = lldb.SBStream() + res = stats.GetAsJSON(stream) + stats_json = sorted(json.loads(stream.GetData())) + self.assertEqual(len(stats_json), 4) + self.assertEqual(stats_json[0], "Number of expr evaluation failures") + self.assertEqual(stats_json[1], "Number of expr evaluation successes") + self.assertEqual(stats_json[2], "Number of frame var failures") + self.assertEqual(stats_json[3], "Number of frame var successes") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/main.c new file mode 100644 index 00000000000..03b2213bb9a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/stats_api/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} |