xref: /llvm-project/lldb/test/API/commands/target/create-no-such-arch/TestNoSuchArch.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test that using a non-existent architecture name does not crash LLDB.
3"""
4
5
6import lldb
7from lldbsuite.test.lldbtest import *
8import lldbsuite.test.lldbutil as lldbutil
9
10
11class NoSuchArchTestCase(TestBase):
12    NO_DEBUG_INFO_TESTCASE = True
13
14    def test(self):
15        self.build()
16        exe = self.getBuildArtifact("a.out")
17
18        # Check that passing an invalid arch via the command-line fails but
19        # doesn't crash
20        self.expect(
21            "target create --arch nothingtoseehere %s" % (exe),
22            error=True,
23            substrs=["error: invalid triple 'nothingtoseehere'"],
24        )
25
26        # Check that passing an invalid arch via the SB API fails but doesn't
27        # crash
28        target = self.dbg.CreateTargetWithFileAndArch(exe, "nothingtoseehere")
29        self.assertFalse(target.IsValid(), "This target should not be valid")
30
31        # Now just create the target with the default arch and check it's fine
32        target = self.dbg.CreateTarget(exe)
33        self.assertTrue(target.IsValid(), "This target should now be valid")
34