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