xref: /llvm-project/lldb/test/API/arm/emulation/TestEmulations.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test some ARM instruction emulation.
3"""
4
5import os
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class ARMEmulationTestCase(TestBase):
13    @no_debug_info_test
14    def test_thumb_emulations(self):
15        test_dir = os.path.join(self.getSourceDir(), "new-test-files")
16        files = os.listdir(test_dir)
17        thumb_files = list()
18        for f in files:
19            if f.endswith("-thumb.dat"):
20                thumb_files.append(f)
21
22        for f in thumb_files:
23            test_file = os.path.join(test_dir, f)
24            self.run_a_single_test(test_file)
25
26    @no_debug_info_test
27    def test_arm_emulations(self):
28        test_dir = os.path.join(self.getSourceDir(), "new-test-files")
29        files = os.listdir(test_dir)
30        arm_files = list()
31        for f in files:
32            if f.endswith("-arm.dat"):
33                arm_files.append(f)
34
35        for f in arm_files:
36            test_file = os.path.join(test_dir, f)
37            self.run_a_single_test(test_file)
38
39    def run_a_single_test(self, filename):
40        insn = lldb.SBInstruction()
41        stream = lldb.SBStream()
42        success = insn.TestEmulation(stream, filename)
43        output = stream.GetData()
44        if self.TraceOn():
45            print("\nRunning test " + os.path.basename(filename))
46            print(output)
47
48        self.assertTrue(success, "Emulation test {} failed.".format(filename))
49