1""" 2Test that we respect the sysroot when building the std module. 3""" 4 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8import os 9 10 11class ImportStdModule(TestBase): 12 13 # We only emulate a fake libc++ in this test and don't use the real libc++, 14 # but we still add the libc++ category so that this test is only run in 15 # test configurations where libc++ is actually supposed to be tested. 16 @add_test_categories(["libc++"]) 17 @skipIf(compiler=no_match("clang")) 18 @skipIfRemote # This test messes with the platform, can't be run remotely. 19 def test(self): 20 self.build() 21 22 sysroot = os.path.join(os.getcwd(), "root") 23 24 # Set the sysroot. 25 self.runCmd("platform select --sysroot '" + sysroot + "' host", 26 CURRENT_EXECUTABLE_SET) 27 28 lldbutil.run_to_source_breakpoint(self, 29 "// Set break point at this line.", 30 lldb.SBFileSpec("main.cpp")) 31 32 self.runCmd("settings set target.import-std-module true") 33 34 # Call our custom function in our sysroot std module. 35 # If this gives us the correct result, then we used the sysroot. 36 # We rely on the default argument of -123 to make sure we actually have the C++ module. 37 # (We don't have default arguments in the debug information). 38 self.expect("expr std::myabs()", substrs=['(int) $0 = 123']) 39