aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py')
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py226
1 files changed, 164 insertions, 62 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
index 12e8eef40cf3..18e45d9798ae 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
+++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
@@ -5,12 +5,14 @@ Test the printing of anonymous and named namespace variables.
from __future__ import print_function
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class NamespaceLookupTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -19,88 +21,131 @@ class NamespaceLookupTestCase(TestBase):
# Call super's setUp().
TestBase.setUp(self)
# Break inside different scopes and evaluate value
- self.line_break_global_scope = line_number('ns.cpp', '// BP_global_scope')
+ self.line_break_global_scope = line_number(
+ 'ns.cpp', '// BP_global_scope')
self.line_break_file_scope = line_number('ns2.cpp', '// BP_file_scope')
self.line_break_ns_scope = line_number('ns2.cpp', '// BP_ns_scope')
- self.line_break_nested_ns_scope = line_number('ns2.cpp', '// BP_nested_ns_scope')
- self.line_break_nested_ns_scope_after_using = line_number('ns2.cpp', '// BP_nested_ns_scope_after_using')
- self.line_break_before_using_directive = line_number('ns3.cpp', '// BP_before_using_directive')
- self.line_break_after_using_directive = line_number('ns3.cpp', '// BP_after_using_directive')
+ self.line_break_nested_ns_scope = line_number(
+ 'ns2.cpp', '// BP_nested_ns_scope')
+ self.line_break_nested_ns_scope_after_using = line_number(
+ 'ns2.cpp', '// BP_nested_ns_scope_after_using')
+ self.line_break_before_using_directive = line_number(
+ 'ns3.cpp', '// BP_before_using_directive')
+ self.line_break_after_using_directive = line_number(
+ 'ns3.cpp', '// BP_after_using_directive')
def runToBkpt(self, command):
self.runCmd(command, RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
- substrs = ['stopped',
- 'stop reason = breakpoint'])
-
- @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819")
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ @expectedFailureAll(
+ oslist=[
+ "windows",
+ "linux",
+ "freebsd"],
+ bugnumber="llvm.org/pr25819")
def test_scope_lookup_with_run_command(self):
"""Test scope lookup of functions in lldb."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns.cpp", self.line_break_global_scope, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_ns_scope, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_nested_ns_scope, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_nested_ns_scope_after_using, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns3.cpp", self.line_break_before_using_directive, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns3.cpp", self.line_break_after_using_directive, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns.cpp",
+ self.line_break_global_scope,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_ns_scope,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_nested_ns_scope,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_nested_ns_scope_after_using,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns3.cpp",
+ self.line_break_before_using_directive,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns3.cpp",
+ self.line_break_after_using_directive,
+ num_expected_locations=1,
+ loc_exact=False)
# Run to BP_global_scope at global scope
self.runToBkpt("run")
# Evaluate func() - should call ::func()
- self.expect("expr -- func()", startstr = "(int) $0 = 1")
+ self.expect("expr -- func()", startstr="(int) $0 = 1")
# Evaluate A::B::func() - should call A::B::func()
- self.expect("expr -- A::B::func()", startstr = "(int) $1 = 4")
+ self.expect("expr -- A::B::func()", startstr="(int) $1 = 4")
# Evaluate func(10) - should call ::func(int)
- self.expect("expr -- func(10)", startstr = "(int) $2 = 11")
+ self.expect("expr -- func(10)", startstr="(int) $2 = 11")
# Evaluate ::func() - should call A::func()
- self.expect("expr -- ::func()", startstr = "(int) $3 = 1")
+ self.expect("expr -- ::func()", startstr="(int) $3 = 1")
# Evaluate A::foo() - should call A::foo()
- self.expect("expr -- A::foo()", startstr = "(int) $4 = 42")
+ self.expect("expr -- A::foo()", startstr="(int) $4 = 42")
# Continue to BP_ns_scope at ns scope
self.runToBkpt("continue")
# Evaluate func(10) - should call A::func(int)
- self.expect("expr -- func(10)", startstr = "(int) $5 = 13")
+ self.expect("expr -- func(10)", startstr="(int) $5 = 13")
# Evaluate B::func() - should call B::func()
- self.expect("expr -- B::func()", startstr = "(int) $6 = 4")
+ self.expect("expr -- B::func()", startstr="(int) $6 = 4")
# Evaluate func() - should call A::func()
- self.expect("expr -- func()", startstr = "(int) $7 = 3")
+ self.expect("expr -- func()", startstr="(int) $7 = 3")
# Continue to BP_nested_ns_scope at nested ns scope
self.runToBkpt("continue")
# Evaluate func() - should call A::B::func()
- self.expect("expr -- func()", startstr = "(int) $8 = 4")
+ self.expect("expr -- func()", startstr="(int) $8 = 4")
# Evaluate A::func() - should call A::func()
- self.expect("expr -- A::func()", startstr = "(int) $9 = 3")
+ self.expect("expr -- A::func()", startstr="(int) $9 = 3")
# Evaluate func(10) - should call A::func(10)
# NOTE: Under the rules of C++, this test would normally get an error
# because A::B::func() hides A::func(), but lldb intentionally
# disobeys these rules so that the intended overload can be found
# by only removing duplicates if they have the same type.
- self.expect("expr -- func(10)", startstr = "(int) $10 = 13")
+ self.expect("expr -- func(10)", startstr="(int) $10 = 13")
- # Continue to BP_nested_ns_scope_after_using at nested ns scope after using declaration
+ # Continue to BP_nested_ns_scope_after_using at nested ns scope after
+ # using declaration
self.runToBkpt("continue")
# Evaluate A::func(10) - should call A::func(int)
- self.expect("expr -- A::func(10)", startstr = "(int) $11 = 13")
+ self.expect("expr -- A::func(10)", startstr="(int) $11 = 13")
- # Continue to BP_before_using_directive at global scope before using declaration
+ # Continue to BP_before_using_directive at global scope before using
+ # declaration
self.runToBkpt("continue")
# Evaluate ::func() - should call ::func()
- self.expect("expr -- ::func()", startstr = "(int) $12 = 1")
+ self.expect("expr -- ::func()", startstr="(int) $12 = 1")
# Evaluate B::func() - should call B::func()
- self.expect("expr -- B::func()", startstr = "(int) $13 = 4")
+ self.expect("expr -- B::func()", startstr="(int) $13 = 4")
- # Continue to BP_after_using_directive at global scope after using declaration
+ # Continue to BP_after_using_directive at global scope after using
+ # declaration
self.runToBkpt("continue")
# Evaluate ::func() - should call ::func()
- self.expect("expr -- ::func()", startstr = "(int) $14 = 1")
+ self.expect("expr -- ::func()", startstr="(int) $14 = 1")
# Evaluate B::func() - should call B::func()
- self.expect("expr -- B::func()", startstr = "(int) $15 = 4")
+ self.expect("expr -- B::func()", startstr="(int) $15 = 4")
@unittest2.expectedFailure("lldb scope lookup of functions bugs")
def test_function_scope_lookup_with_run_command(self):
@@ -108,26 +153,36 @@ class NamespaceLookupTestCase(TestBase):
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns.cpp", self.line_break_global_scope, num_expected_locations=1, loc_exact=False)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_ns_scope, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns.cpp",
+ self.line_break_global_scope,
+ num_expected_locations=1,
+ loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_ns_scope,
+ num_expected_locations=1,
+ loc_exact=False)
# Run to BP_global_scope at global scope
self.runToBkpt("run")
# Evaluate foo() - should call ::foo()
# FIXME: lldb finds Y::foo because lookup for variables is done
# before functions.
- self.expect("expr -- foo()", startstr = "(int) $0 = 42")
+ self.expect("expr -- foo()", startstr="(int) $0 = 42")
# Evaluate ::foo() - should call ::foo()
# FIXME: lldb finds Y::foo because lookup for variables is done
# before functions and :: is ignored.
- self.expect("expr -- ::foo()", startstr = "(int) $1 = 42")
+ self.expect("expr -- ::foo()", startstr="(int) $1 = 42")
# Continue to BP_ns_scope at ns scope
self.runToBkpt("continue")
# Evaluate foo() - should call A::foo()
# FIXME: lldb finds Y::foo because lookup for variables is done
# before functions.
- self.expect("expr -- foo()", startstr = "(int) $2 = 42")
+ self.expect("expr -- foo()", startstr="(int) $2 = 42")
@unittest2.expectedFailure("lldb file scope lookup bugs")
def test_file_scope_lookup_with_run_command(self):
@@ -135,14 +190,19 @@ class NamespaceLookupTestCase(TestBase):
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_file_scope, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_file_scope,
+ num_expected_locations=1,
+ loc_exact=False)
# Run to BP_file_scope at file scope
self.runToBkpt("run")
# Evaluate func() - should call static ns2.cpp:func()
# FIXME: This test fails because lldb doesn't know about file scopes so
# finds the global ::func().
- self.expect("expr -- func()", startstr = "(int) $0 = 2")
+ self.expect("expr -- func()", startstr="(int) $0 = 2")
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr25819")
def test_scope_lookup_before_using_with_run_command(self):
@@ -150,30 +210,51 @@ class NamespaceLookupTestCase(TestBase):
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns3.cpp", self.line_break_before_using_directive, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns3.cpp",
+ self.line_break_before_using_directive,
+ num_expected_locations=1,
+ loc_exact=False)
- # Run to BP_before_using_directive at global scope before using declaration
+ # Run to BP_before_using_directive at global scope before using
+ # declaration
self.runToBkpt("run")
# Evaluate func() - should call ::func()
- self.expect("expr -- func()", startstr = "(int) $0 = 1")
+ self.expect("expr -- func()", startstr="(int) $0 = 1")
# NOTE: this test may fail on older systems that don't emit import
# entries in DWARF - may need to add checks for compiler versions here.
- @skipIf(compiler="gcc", oslist=["linux"], debug_info=["dwo"]) # Skip to avoid crash
- @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819")
+ @skipIf(
+ compiler="gcc",
+ oslist=["linux"],
+ debug_info=["dwo"]) # Skip to avoid crash
+ @expectedFailureAll(
+ oslist=[
+ "windows",
+ "linux",
+ "freebsd"],
+ bugnumber="llvm.org/pr25819")
def test_scope_after_using_directive_lookup_with_run_command(self):
"""Test scope lookup after using directive in lldb."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns3.cpp", self.line_break_after_using_directive, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns3.cpp",
+ self.line_break_after_using_directive,
+ num_expected_locations=1,
+ loc_exact=False)
- # Run to BP_after_using_directive at global scope after using declaration
+ # Run to BP_after_using_directive at global scope after using
+ # declaration
self.runToBkpt("run")
# Evaluate func2() - should call A::func2()
- self.expect("expr -- func2()", startstr = "(int) $0 = 3")
+ self.expect("expr -- func2()", startstr="(int) $0 = 3")
- @unittest2.expectedFailure("lldb scope lookup after using declaration bugs")
+ @unittest2.expectedFailure(
+ "lldb scope lookup after using declaration bugs")
# NOTE: this test may fail on older systems that don't emit import
# emtries in DWARF - may need to add checks for compiler versions here.
def test_scope_after_using_declaration_lookup_with_run_command(self):
@@ -181,12 +262,18 @@ class NamespaceLookupTestCase(TestBase):
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_nested_ns_scope_after_using, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_nested_ns_scope_after_using,
+ num_expected_locations=1,
+ loc_exact=False)
- # Run to BP_nested_ns_scope_after_using at nested ns scope after using declaration
+ # Run to BP_nested_ns_scope_after_using at nested ns scope after using
+ # declaration
self.runToBkpt("run")
# Evaluate func() - should call A::func()
- self.expect("expr -- func()", startstr = "(int) $0 = 3")
+ self.expect("expr -- func()", startstr="(int) $0 = 3")
@unittest2.expectedFailure("lldb scope lookup ambiguity after using bugs")
def test_scope_ambiguity_after_using_lookup_with_run_command(self):
@@ -194,22 +281,38 @@ class NamespaceLookupTestCase(TestBase):
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns3.cpp", self.line_break_after_using_directive, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns3.cpp",
+ self.line_break_after_using_directive,
+ num_expected_locations=1,
+ loc_exact=False)
- # Run to BP_after_using_directive at global scope after using declaration
+ # Run to BP_after_using_directive at global scope after using
+ # declaration
self.runToBkpt("run")
# Evaluate func() - should get error: ambiguous
# FIXME: This test fails because lldb removes duplicates if they have
# the same type.
- self.expect("expr -- func()", startstr = "error")
-
- @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr25819")
+ self.expect("expr -- func()", startstr="error")
+
+ @expectedFailureAll(
+ oslist=[
+ "windows",
+ "linux",
+ "freebsd"],
+ bugnumber="llvm.org/pr25819")
def test_scope_lookup_shadowed_by_using_with_run_command(self):
"""Test scope lookup shadowed by using in lldb."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.run_break_set_by_file_and_line (self, "ns2.cpp", self.line_break_nested_ns_scope, num_expected_locations=1, loc_exact=False)
+ lldbutil.run_break_set_by_file_and_line(
+ self,
+ "ns2.cpp",
+ self.line_break_nested_ns_scope,
+ num_expected_locations=1,
+ loc_exact=False)
# Run to BP_nested_ns_scope at nested ns scope
self.runToBkpt("run")
@@ -218,5 +321,4 @@ class NamespaceLookupTestCase(TestBase):
# because A::B::func() shadows A::func(), but lldb intentionally
# disobeys these rules so that the intended overload can be found
# by only removing duplicates if they have the same type.
- self.expect("expr -- func(10)", startstr = "(int) $0 = 13")
-
+ self.expect("expr -- func(10)", startstr="(int) $0 = 13")