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

Unified Diff: src/trusted/validator_ragel/validator_test.py

Issue 9348082: Move unreviewed files to unreviewed subdirectory (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/validator_ragel/validator-x86_64.rl ('k') | src/trusted/validator_ragel/x87-instructions.def » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator_ragel/validator_test.py
===================================================================
--- src/trusted/validator_ragel/validator_test.py (revision 7794)
+++ src/trusted/validator_ragel/validator_test.py (working copy)
@@ -1,256 +0,0 @@
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# This validator test was taken from branch "x86-64" in the repo:
-# https://github.com/mseaborn/x86-decoder
-# The test was modified to address intentional validator differences.
-
-import subprocess
-
-
-def WriteFile(filename, data):
- fh = open(filename, "w")
- try:
- fh.write(data)
- finally:
- fh.close()
-
-
-bits = 64
-
-test_cases = []
-
-def TestCase(asm, accept):
- def Func():
- print '* test %r' % asm
- full_asm = asm + '\n.p2align 5, 0x90\n'
- WriteFile('tmp.S', full_asm)
- subprocess.check_call(['gcc', '-m%i' % bits, '-c', 'tmp.S', '-o', 'tmp.o'])
- rc = subprocess.call(['./dfa_ncval', 'tmp.o'])
- if accept:
- assert rc == 0, rc
- else:
- assert rc == 1, rc
- test_cases.append(Func)
-
-
-# Check some simple allowed instructions.
-TestCase(accept=True, asm="""
-nop
-hlt
-mov $0x12345678, %rax
-mov $0x1234567812345678, %rax
-""")
-
-# Check a disallowed instruction.
-TestCase(accept=False, asm="""
-nop
-int $0x80
-""")
-
-TestCase(accept=False, asm='ret')
-
-TestCase(accept=False, asm='syscall')
-
-# Instruction bundle overflow.
-TestCase(accept=False, asm="""
-mov $0x1234567812345678, %rax
-mov $0x1234567812345678, %rax
-mov $0x1234567812345678, %rax
-mov $0x1234567812345678, %rax
-""")
-
-# Forwards and backwards jumps.
-TestCase(accept=True, asm="""
-nop
-jmp label2
-label1:
-jmp label1
-jmp label1
-label2:
-jmp label1
-""")
-
-# Out-of-range unaligned jump.
-TestCase(accept=False, asm="""
-label:
-jmp label - 1
-""")
-
-# Out-of-range unaligned jump.
-TestCase(accept=False, asm="""
-jmp label + 1
-.p2align 5
-label:
-""")
-
-# Jump into instruction.
-TestCase(accept=False, asm="""
-label:
-mov $0x1234567812345678, %rax
-jmp label + 1
-""")
-
-
-# Unmasked indirect jumps are disallowed.
-TestCase(accept=False, asm='jmp *%rax')
-TestCase(accept=False, asm='jmp *(%rax)')
-TestCase(accept=False, asm='call *%rax')
-TestCase(accept=False, asm='call *(%rax)')
-
-# Masking instructions on their own are allowed.
-TestCase(accept=True, asm='and $~31, %eax')
-TestCase(accept=True, asm='and $~31, %ebx')
-TestCase(accept=True, asm='and $~31, %rax')
-TestCase(accept=True, asm='and $~31, %rbx')
-TestCase(accept=True, asm='and $~31, %eax; add %r15, %rax')
-TestCase(accept=True, asm='and $~31, %ebx; add %r15, %rbx')
-
-# Masked indirect jumps are allowed.
-TestCase(accept=True, asm='and $~31, %eax; add %r15, %rax; jmp *%rax')
-TestCase(accept=True, asm='and $~31, %ebx; add %r15, %rbx; call *%rbx')
-
-# The registers must match up for the mask and the jump.
-TestCase(accept=False, asm='and $~31, %ebx; add %r15, %rax; jmp *%rax')
-TestCase(accept=False, asm='and $~31, %eax; add %r15, %rbx; jmp *%rax')
-TestCase(accept=False, asm='and $~31, %eax; add %r15, %rax; jmp *%rbx')
-TestCase(accept=False, asm='and $~31, %eax; add %r15, %rbx; jmp *%rbx')
-TestCase(accept=False, asm='and $~31, %ebx; add %r15, %rbx; jmp *%rax')
-
-# The mask and the jump must be adjacent.
-TestCase(accept=False, asm='and $~31, %eax; nop; add %r15, %rax; jmp *%rax')
-TestCase(accept=False, asm='and $~31, %eax; add %r15, %rax; nop; jmp *%rax')
-
-# Jumping into the middle of the superinstruction must be rejected.
-TestCase(accept=False, asm="""
-and $~31, %eax
-add %r15, %rax
-label:
-jmp *%rax
-jmp label
-""")
-TestCase(accept=False, asm="""
-and $~31, %eax
-label:
-add %r15, %rax
-jmp *%rax
-jmp label
-""")
-
-# Read-only access to special registers is allowed.
-TestCase(accept=True, asm='push %rax')
-TestCase(accept=True, asm='push %rbp')
-TestCase(accept=True, asm='push %rsp')
-TestCase(accept=True, asm='push %r15')
-TestCase(accept=True, asm='mov %rsp, %rax')
-# But write access is not.
-TestCase(accept=True, asm='pop %rax')
-TestCase(accept=False, asm='pop %rbp')
-TestCase(accept=False, asm='pop %rsp')
-TestCase(accept=False, asm='pop %r15')
-
-# Memory accesses.
-TestCase(accept=True, asm="""
-mov %eax, %eax
-mov (%r15, %rax), %ebx
-""")
-# Test for a top-bit-set register.
-TestCase(accept=True, asm="""
-mov %r12d, %r12d
-mov (%r15, %r12), %ebx
-""")
-# Check %edi and %esi because the first 'mov' also begins superinstructions.
-TestCase(accept=True, asm="""
-mov %edi, %edi
-mov (%r15, %rdi), %ebx
-""")
-TestCase(accept=True, asm="""
-mov %esi, %esi
-mov (%r15, %rsi), %ebx
-""")
-# Check mask on its own.
-TestCase(accept=True, asm="""
-mov %eax, %eax
-""")
-TestCase(accept=False, asm="""
-mov (%r15, %rax), %ebx
-""")
-TestCase(accept=False, asm="""
-mov %eax, %eax
-label:
-mov (%r15, %rax), %ebx
-jmp label
-""")
-
-# Check that post-conditions do not leak from a superinstruction. To
-# share DFT states, the first instruction of the nacljmp, "and $~31,
-# %eax", records a post-condition, just as when it is used on its own.
-# Although the code below is safe, we don't really want the
-# post-condition to leak through.
-TestCase(accept=False, asm="""
-and $~31, %eax
-add %r15, %rax
-jmp *%rax
-// %rax should not be regarded as zero-extended here.
-mov (%r15, %rax), %ebx
-""")
-TestCase(accept=False, asm="""
-mov %edi, %edi
-lea (%r15, %rdi), %rdi
-rep stos %al, %es:(%rdi)
-// %rdi should not be regarded as zero-extended here.
-mov (%r15, %rdi), %ebx
-""")
-TestCase(accept=False, asm="""
-mov %esi, %esi
-lea (%r15, %rsi), %rsi
-mov %edi, %edi
-lea (%r15, %rdi), %rdi
-rep movsb %ds:(%rsi), %es:(%rdi)
-// %rsi should not be regarded as zero-extended here.
-mov (%r15, %rsi), %ebx
-""")
-
-# Non-%r15-based memory accesses.
-TestCase(accept=True, asm='mov 0x1234(%rip), %eax')
-TestCase(accept=True, asm='mov 0x1234(%rsp), %eax')
-TestCase(accept=True, asm='mov 0x1234(%rbp), %eax')
-TestCase(accept=False, asm='mov 0x1234(%rsp, %rbx), %eax')
-TestCase(accept=False, asm='mov 0x1234(%rbp, %rbx), %eax')
-TestCase(accept=True, asm='mov %ebx, %ebx; mov 0x1234(%rsp, %rbx), %eax')
-TestCase(accept=True, asm='mov %ebx, %ebx; mov 0x1234(%rbp, %rbx), %eax')
-
-# 'lea' is not a memory access.
-TestCase(accept=True, asm='lea (%rbx, %rcx, 4), %rax')
-
-# Stack operations.
-TestCase(accept=True, asm='mov %rsp, %rbp')
-TestCase(accept=True, asm='mov %rbp, %rsp')
-TestCase(accept=True, asm="""
-add $8, %ebp
-add %r15, %rbp
-""")
-TestCase(accept=False, asm="""
-add $8, %ebp
-label:
-add %r15, %rbp
-jmp label
-""")
-# A stack fixup on its own is not allowed.
-TestCase(accept=False, asm='add %r15, %rbp')
-TestCase(accept=False, asm='add %r15, %rsp')
-TestCase(accept=False, asm='add %r15, %r15')
-
-# Sandboxing is not required on prefetch instructions.
-TestCase(accept=True, asm='prefetchnta (%rax)')
-
-
-def Main():
- for test_case in test_cases:
- test_case()
- print 'PASS'
-
-
-if __name__ == '__main__':
- Main()
« no previous file with comments | « src/trusted/validator_ragel/validator-x86_64.rl ('k') | src/trusted/validator_ragel/x87-instructions.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698