]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/arm_emulation/TestEmulations.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / arm_emulation / TestEmulations.py
1 """
2 Test some ARM instruction emulation.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class ARMEmulationTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     @no_debug_info_test
21     def test_thumb_emulations(self):
22         current_dir = os.getcwd()
23         test_dir = os.path.join(current_dir, "new-test-files")
24         files = os.listdir(test_dir)
25         thumb_files = list()
26         for f in files:
27             if '-thumb.dat' in f:
28                 thumb_files.append(f)
29
30         for f in thumb_files:
31             test_file = os.path.join(test_dir, f)
32             self.run_a_single_test(test_file)
33
34     @no_debug_info_test
35     def test_arm_emulations(self):
36         current_dir = os.getcwd()
37         test_dir = os.path.join(current_dir, "new-test-files")
38         files = os.listdir(test_dir)
39         arm_files = list()
40         for f in files:
41             if '-arm.dat' in f:
42                 arm_files.append(f)
43
44         for f in arm_files:
45             test_file = os.path.join(test_dir, f)
46             self.run_a_single_test(test_file)
47
48     def run_a_single_test(self, filename):
49         insn = lldb.SBInstruction()
50         stream = lldb.SBStream()
51         success = insn.TestEmulation(stream, filename)
52         output = stream.GetData()
53         if self.TraceOn():
54             print('\nRunning test ' + os.path.basename(filename))
55             print(output)
56
57         self.assertTrue(success, 'Emulation test succeeded.')