Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/trusted/validator_ragel/gen_dfa_test.py

Issue 12090047: Validator_ragel: REX prefix support in gen_dfa.py. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 import unittest 7 import unittest
8 8
9 import gen_dfa 9 import gen_dfa
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 printer.GetContent().split(), 179 printer.GetContent().split(),
180 """ 180 """
181 0xeb 181 0xeb
182 @instruction_jmp 182 @instruction_jmp
183 @operands_count_is_1 183 @operands_count_is_1
184 @operand0_8bit 184 @operand0_8bit
185 rel8 185 rel8
186 @operand0_jmp_to 186 @operand0_jmp_to
187 """.split()) 187 """.split())
188 188
189 def test_no_modrm_with_rex(self):
190 printer = gen_dfa.InstructionPrinter(gen_dfa.DECODER, 64)
191 instr = gen_dfa.Instruction.Parse(
192 'movabs Od !ad, 0xa0, amd64 nacl-forbidden')
193
194 printer.PrintInstructionWithoutModRM(instr)
195
196 self.assertEquals(
197 printer.GetContent().split(),
198 """
199 REX_RXB?
200 0xa0
201 @instruction_movabs
202 @operands_count_is_2
203 @operand0_32bit
204 @operand1_32bit
205 @set_spurious_rex_b
206 @set_spurious_rex_x
207 @set_spurious_rex_r
208 @operand1_rax
209 @operand0_absolute_disp
210 disp64
211 """.split())
212
213 def test_nop_with_rex(self):
214 printer = gen_dfa.InstructionPrinter(gen_dfa.DECODER, 64)
215 instr = gen_dfa.Instruction.Parse(
216 'nop, 0x40 0x90, amd64 norex')
217
218 printer.PrintInstructionWithoutModRM(instr)
219
220 self.assertEquals(
221 printer.GetContent().split(),
222 """
223 0x40 0x90
224 @instruction_nop
225 @operands_count_is_0
226 @set_spurious_rex_b
227 @set_spurious_rex_x
228 @set_spurious_rex_r
229 """.split())
230
189 231
190 class TestParser(unittest.TestCase): 232 class TestParser(unittest.TestCase):
191 233
192 def test_instruction_definitions(self): 234 def test_instruction_definitions(self):
193 def_filenames = sys.argv[1:] 235 def_filenames = sys.argv[1:]
194 assert len(def_filenames) > 0 236 assert len(def_filenames) > 0
195 for filename in def_filenames: 237 for filename in def_filenames:
196 gen_dfa.ParseDefFile(filename) 238 gen_dfa.ParseDefFile(filename)
197 239
198 240
199 if __name__ == '__main__': 241 if __name__ == '__main__':
200 unittest.main(argv=[sys.argv[0], '--verbose']) 242 unittest.main(argv=[sys.argv[0], '--verbose'])
OLDNEW
« src/trusted/validator_ragel/gen_dfa.py ('K') | « src/trusted/validator_ragel/gen_dfa.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698