diff options
author | Todd Fiala <todd.fiala@gmail.com> | 2016-08-19 04:21:48 +0000 |
---|---|---|
committer | Todd Fiala <todd.fiala@gmail.com> | 2016-08-19 04:21:48 +0000 |
commit | 759300192abe8e38e8a40ab95934ba602a78c252 (patch) | |
tree | d284c51cf10c23d3023ab8e1308e26ad1ee218a7 /lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source | |
parent | e2ca3b65fcba7c4c5dbd10c1e8925177b7718806 (diff) | |
download | bcm5719-llvm-759300192abe8e38e8a40ab95934ba602a78c252.tar.gz bcm5719-llvm-759300192abe8e38e8a40ab95934ba602a78c252.zip |
Add StructuredData plugin type; showcase with new DarwinLog feature
Take 2, with missing cmake line fixed. Build tested on
Ubuntu 14.04 with clang-3.6.
See docs/structured_data/StructuredDataPlugins.md for details.
differential review: https://reviews.llvm.org/D22976
reviewers: clayborg, jingham
llvm-svn: 279202
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source')
6 files changed, 239 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/Makefile new file mode 100644 index 00000000000..214cedd96f1 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py new file mode 100644 index 00000000000..d44437cd14b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py @@ -0,0 +1,79 @@ +""" +Test DarwinLog "source include debug-level" functionality provided by the +StructuredDataDarwinLog plugin. + +These tests are currently only supported when running against Darwin +targets. +""" + +from __future__ import print_function + +import lldb +import os +import re + +from lldbsuite.test import decorators +from lldbsuite.test import lldbtest +from lldbsuite.test import darwin_log + + +class TestDarwinLogSourceDebug(darwin_log.DarwinLogTestBase): + + mydir = lldbtest.TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + super(TestDarwinLogSourceDebug, self).setUp() + + # Source filename. + self.source = 'main.c' + + # Output filename. + self.exe_name = 'a.out' + self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} + + # Locate breakpoint. + self.line = lldbtest.line_number(self.source, '// break here') + + # Indicate we want strict-sources behavior. + self.strict_sources = True + + def tearDown(self): + # Shut down the process if it's still running. + if self.child: + self.runCmd('process kill') + self.expect_prompt() + self.runCmd('quit') + + # Let parent clean up + super(TestDarwinLogSourceDebug, self).tearDown() + + # ========================================================================== + # source include/exclude debug filter tests + # ========================================================================== + + @decorators.skipUnlessDarwin + def test_source_default_exclude_debug(self): + """Test that default excluding of debug-level log messages works.""" + self.do_test([]) + + # We should only see the second log message as the first is a + # debug-level message and we're not including debug-level messages. + self.assertIsNotNone(self.child.match) + self.assertTrue((len(self.child.match.groups()) > 1) and + (self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") + + @decorators.skipUnlessDarwin + def test_source_explicitly_include_debug(self): + """Test that explicitly including debug-level log messages works.""" + self.do_test(["--debug"]) + + # We should only see the second log message as the first is a + # debug-level message and we're not including debug-level messages. + self.assertIsNotNone(self.child.match) + self.assertTrue((len(self.child.match.groups()) > 1) and + (self.child.match.group(2) == "cat1"), + "first log line should be present since we're " + "including debug-level log messages") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c new file mode 100644 index 00000000000..1f5cd1aa6c7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c @@ -0,0 +1,34 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <os/log.h> +#include <stdio.h> + +#include "../../common/darwin_log_common.h" + +int main(int argc, char** argv) +{ + os_log_t logger_sub1 = os_log_create("org.llvm.lldb.test.sub1", "cat1"); + os_log_t logger_sub2 = os_log_create("org.llvm.lldb.test.sub2", "cat2"); + if (!logger_sub1 || !logger_sub2) + return 1; + + // Note we cannot use the os_log() line as the breakpoint because, as of + // the initial writing of this test, we get multiple breakpoints for that + // line, which confuses the pexpect test logic. + printf("About to log\n"); // break here + os_log_debug(logger_sub1, "source-log-sub1-cat1"); + os_log(logger_sub2, "source-log-sub2-cat2"); + + // Sleep, as the darwin log reporting doesn't always happen until a bit + // later. We need the message to come out before the process terminates. + sleep(FINAL_WAIT_SECONDS); + + return 0; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/Makefile new file mode 100644 index 00000000000..214cedd96f1 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py new file mode 100644 index 00000000000..d47d85a27fd --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py @@ -0,0 +1,82 @@ +""" +Test DarwinLog "source include info-level" functionality provided by the +StructuredDataDarwinLog plugin. + +These tests are currently only supported when running against Darwin +targets. +""" + +from __future__ import print_function + +import lldb +import os +import re + +from lldbsuite.test import decorators +from lldbsuite.test import lldbtest +from lldbsuite.test import darwin_log + + +class TestDarwinLogSourceInfo(darwin_log.DarwinLogTestBase): + + mydir = lldbtest.TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + super(TestDarwinLogSourceInfo, self).setUp() + + # Source filename. + self.source = 'main.c' + + # Output filename. + self.exe_name = 'a.out' + self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} + + # Locate breakpoint. + self.line = lldbtest.line_number(self.source, '// break here') + + # Indicate we want strict-sources behavior. + self.strict_sources = True + + def tearDown(self): + # Shut down the process if it's still running. + if self.child: + self.runCmd('process kill') + self.expect_prompt() + self.runCmd('quit') + + # Let parent clean up + super(TestDarwinLogSourceInfo, self).tearDown() + + # ========================================================================== + # source include/exclude debug filter tests + # ========================================================================== + + @decorators.skipUnlessDarwin + @decorators.expectedFailureAll(bugnumber="rdar://27316264") + def test_source_exclude_info_level(self): + """Test that default excluding of info-level log messages works.""" + self.do_test([]) + + # We should only see the second log message as the first is an + # info-level message and we're not including debug-level messages. + self.assertIsNotNone(self.child.match) + self.assertTrue((len(self.child.match.groups()) > 1) and + (self.child.match.group(2) == "cat2"), + "first log line should not be present, second log line " + "should be") + + @decorators.skipUnlessDarwin + def test_source_include_info_level(self): + """Test that explicitly including info-level log messages works.""" + self.do_test( + ["--info"] + ) + + # We should only see the second log message as the first is a + # debug-level message and we're not including debug-level messages. + self.assertIsNotNone(self.child.match) + self.assertTrue((len(self.child.match.groups()) > 1) and + (self.child.match.group(2) == "cat1"), + "first log line should be present since we're " + "including info-level log messages") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c new file mode 100644 index 00000000000..5ab6f39c007 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c @@ -0,0 +1,34 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <os/log.h> +#include <stdio.h> + +#include "../../common/darwin_log_common.h" + +int main(int argc, char** argv) +{ + os_log_t logger_sub1 = os_log_create("org.llvm.lldb.test.sub1", "cat1"); + os_log_t logger_sub2 = os_log_create("org.llvm.lldb.test.sub2", "cat2"); + if (!logger_sub1 || !logger_sub2) + return 1; + + // Note we cannot use the os_log() line as the breakpoint because, as of + // the initial writing of this test, we get multiple breakpoints for that + // line, which confuses the pexpect test logic. + printf("About to log\n"); // break here + os_log_info(logger_sub1, "source-log-sub1-cat1"); + os_log(logger_sub2, "source-log-sub2-cat2"); + + // Sleep, as the darwin log reporting doesn't always happen until a bit + // later. We need the message to come out before the process terminates. + sleep(FINAL_WAIT_SECONDS); + + return 0; +} |