Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Differential D114403 Diff 389059 lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py
Changeset View
Changeset View
Standalone View
Standalone View
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py
- This file was moved from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py.
""" | |||||
Test lldb data formatter subsystem. | |||||
""" | |||||
import lldb | import lldb | ||||
from lldbsuite.test.decorators import * | from lldbsuite.test.decorators import * | ||||
from lldbsuite.test.lldbtest import * | from lldbsuite.test.lldbtest import * | ||||
from lldbsuite.test import lldbutil | from lldbsuite.test import lldbutil | ||||
USE_LIBSTDCPP = "USE_LIBSTDCPP" | |||||
USE_LIBCPP = "USE_LIBCPP" | |||||
class LibcxxOptionalDataFormatterTestCase(TestBase): | class GenericOptionalDataFormatterTestCase(TestBase): | ||||
mydir = TestBase.compute_mydir(__file__) | mydir = TestBase.compute_mydir(__file__) | ||||
@add_test_categories(["libc++"]) | def do_test_with_run_command(self, stdlib_type): | ||||
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions | |||||
## with -std=c++17. | |||||
@skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '7.0']) | |||||
## We are skipping gcc version less that 5.1 since this test requires -std=c++17 | |||||
@skipIf(compiler="gcc", compiler_version=['<', '5.1']) | |||||
def test_with_run_command(self): | |||||
"""Test that that file and class static variables display correctly.""" | """Test that that file and class static variables display correctly.""" | ||||
self.build() | self.build(dictionary={stdlib_type: "1"}) | ||||
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) | self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) | ||||
bkpt = self.target().FindBreakpointByID( | bkpt = self.target().FindBreakpointByID( | ||||
lldbutil.run_break_set_by_source_regexp( | lldbutil.run_break_set_by_source_regexp( | ||||
self, "break here")) | self, "break here")) | ||||
self.runCmd("run", RUN_SUCCEEDED) | self.runCmd("run", RUN_SUCCEEDED) | ||||
# The stop reason of the thread should be breakpoint. | # The stop reason of the thread should be breakpoint. | ||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, | ||||
substrs=['stopped', | substrs=['stopped', | ||||
'stop reason = breakpoint']) | 'stop reason = breakpoint']) | ||||
self.runCmd( "frame variable has_optional" ) | self.runCmd( "frame variable has_optional" ) | ||||
output = self.res.GetOutput() | output = self.res.GetOutput() | ||||
## The variable has_optional tells us if the test program | ## The variable has_optional tells us if the test program | ||||
## detected we have a sufficient libc++ version to support optional | ## detected we have a sufficient libc++ version to support optional | ||||
## false means we do not and therefore should skip the test | ## false means we do not and therefore should skip the test | ||||
if output.find("(bool) has_optional = false") != -1 : | if output.find("(bool) has_optional = false") != -1 : | ||||
self.skipTest( "Optional not supported" ) | self.skipTest( "Optional not supported" ) | ||||
lldbutil.continue_to_breakpoint(self.process(), bkpt) | lldbutil.continue_to_breakpoint(self.process(), bkpt) | ||||
self.expect("frame variable number_not_engaged", | self.expect("frame variable number_not_engaged", | ||||
substrs=['Has Value=false']) | substrs=['Has Value=false']) | ||||
self.expect("frame variable number_engaged", | self.expect("frame variable number_engaged", | ||||
substrs=['Has Value=true', | substrs=['Has Value=true', | ||||
Show All 9 Lines | def do_test_with_run_command(self, stdlib_type): | ||||
'[3] = 4', | '[3] = 4', | ||||
'}', | '}', | ||||
'}']) | '}']) | ||||
self.expect("frame var ostring", | self.expect("frame var ostring", | ||||
substrs=['(optional_string) ostring = Has Value=true {', | substrs=['(optional_string) ostring = Has Value=true {', | ||||
'Value = "hello"', | 'Value = "hello"', | ||||
'}']) | '}']) | ||||
@add_test_categories(["libc++"]) | |||||
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions | |||||
## with -std=c++17. | |||||
@skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '7.0']) | |||||
## We are skipping gcc version less that 5.1 since this test requires -std=c++17 | |||||
@skipIf(compiler="gcc", compiler_version=['<', '5.1']) | |||||
def test_with_run_command_libcpp(self): | |||||
self.do_test_with_run_command(USE_LIBCPP) | |||||
@add_test_categories(["libstdcxx"]) | |||||
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions | |||||
## with -std=c++17. | |||||
@skipIf(compiler="clang", compiler_version=['<', '7.0']) | |||||
## We are skipping gcc version less that 5.1 since this test requires -std=c++17 | |||||
@skipIf(compiler="gcc", compiler_version=['<', '5.1']) | |||||
def test_with_run_command_libstdcpp(self): | |||||
self.do_test_with_run_command(USE_LIBSTDCPP) |