199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest that we respect the sysroot when building the std module. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 899451b44SJordan Rupprechtimport os 999451b44SJordan Rupprecht 10cabee89bSRaphael Isemann 1199451b44SJordan Rupprechtclass ImportStdModule(TestBase): 1299451b44SJordan Rupprecht # We only emulate a fake libc++ in this test and don't use the real libc++, 1399451b44SJordan Rupprecht # but we still add the libc++ category so that this test is only run in 1499451b44SJordan Rupprecht # test configurations where libc++ is actually supposed to be tested. 1599451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1699451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 1799451b44SJordan Rupprecht @skipIfRemote # This test messes with the platform, can't be run remotely. 1899451b44SJordan Rupprecht def test(self): 1999451b44SJordan Rupprecht self.build() 2099451b44SJordan Rupprecht 2199451b44SJordan Rupprecht sysroot = os.path.join(os.getcwd(), "root") 2299451b44SJordan Rupprecht 2399451b44SJordan Rupprecht # Set the sysroot. 24*2238dcc3SJonas Devlieghere self.runCmd( 25*2238dcc3SJonas Devlieghere "platform select --sysroot '" + sysroot + "' host", CURRENT_EXECUTABLE_SET 26*2238dcc3SJonas Devlieghere ) 2799451b44SJordan Rupprecht 28*2238dcc3SJonas Devlieghere lldbutil.run_to_source_breakpoint( 29*2238dcc3SJonas Devlieghere self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") 30*2238dcc3SJonas Devlieghere ) 3199451b44SJordan Rupprecht 3299451b44SJordan Rupprecht self.runCmd("settings set target.import-std-module true") 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht # Call our custom function in our sysroot std module. 3599451b44SJordan Rupprecht # If this gives us the correct result, then we used the sysroot. 3699451b44SJordan Rupprecht # We rely on the default argument of -123 to make sure we actually have the C++ module. 3799451b44SJordan Rupprecht # (We don't have default arguments in the debug information). 38*2238dcc3SJonas Devlieghere self.expect("expr std::myabs()", substrs=["(int) $0 = 123"]) 39