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 10*cabee89bSRaphael Isemann 1199451b44SJordan Rupprechtclass ImportStdModule(TestBase): 1299451b44SJordan Rupprecht 1399451b44SJordan Rupprecht # We only emulate a fake libc++ in this test and don't use the real libc++, 1499451b44SJordan Rupprecht # but we still add the libc++ category so that this test is only run in 1599451b44SJordan Rupprecht # test configurations where libc++ is actually supposed to be tested. 1699451b44SJordan Rupprecht @add_test_categories(["libc++"]) 1799451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 1899451b44SJordan Rupprecht @skipIfRemote # This test messes with the platform, can't be run remotely. 1999451b44SJordan Rupprecht def test(self): 2099451b44SJordan Rupprecht self.build() 2199451b44SJordan Rupprecht 2299451b44SJordan Rupprecht sysroot = os.path.join(os.getcwd(), "root") 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht # Set the sysroot. 25*cabee89bSRaphael Isemann self.runCmd("platform select --sysroot '" + sysroot + "' host", 26*cabee89bSRaphael Isemann CURRENT_EXECUTABLE_SET) 2799451b44SJordan Rupprecht 2899451b44SJordan Rupprecht lldbutil.run_to_source_breakpoint(self, 29*cabee89bSRaphael Isemann "// Set break point at this line.", 30*cabee89bSRaphael Isemann lldb.SBFileSpec("main.cpp")) 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). 3899451b44SJordan Rupprecht self.expect("expr std::myabs()", substrs=['(int) $0 = 123']) 39