Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(649)

Delta Between Two Patch Sets: x86asm/xed_test.go

Issue 95300044: code review 95300044: x86asm: basic 64-bit mode decoding (Closed)
Left Patch Set: Created 9 years, 10 months ago
Right Patch Set: diff -r 27604273fc7c https://code.google.com/p/rsc.x86/ Created 9 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « x86asm/testdata/Makefile ('k') | x86map/map.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4
5 // TODO: Download xed from
6 // https://software.intel.com/en-us/articles/pin-a-binary-instrumentation-tool-d ownloads
7 // and test against it too.
8 4
9 package x86asm 5 package x86asm
10 6
11 import ( 7 import (
12 "bytes" 8 "bytes"
13 "strings" 9 "strings"
14 "testing" 10 "testing"
15 ) 11 )
16 12
17 func TestXed32Manual(t *testing.T) { testXed32(t, hexCases(t, xedManualTests)) } 13 func TestXed32Manual(t *testing.T) { testXed32(t, hexCases(t, xedManualTests)) }
18 func TestXed32Testdata(t *testing.T) { testXed32(t, concat(basicPrefixes, testda taCases(t))) } 14 func TestXed32Testdata(t *testing.T) { testXed32(t, concat(basicPrefixes, testda taCases(t))) }
19 func TestXed32ModRM(t *testing.T) { testXed32(t, concat(basicPrefixes, enumMo dRM)) } 15 func TestXed32ModRM(t *testing.T) { testXed32(t, concat(basicPrefixes, enumMo dRM)) }
20 func TestXed32OneByte(t *testing.T) { testBasic(t, testXed32) } 16 func TestXed32OneByte(t *testing.T) { testBasic(t, testXed32) }
21 func TestXed320F(t *testing.T) { testBasic(t, testXed32, 0x0F) } 17 func TestXed320F(t *testing.T) { testBasic(t, testXed32, 0x0F) }
22 func TestXed320F38(t *testing.T) { testBasic(t, testXed32, 0x0F, 0x38) } 18 func TestXed320F38(t *testing.T) { testBasic(t, testXed32, 0x0F, 0x38) }
23 func TestXed320F3A(t *testing.T) { testBasic(t, testXed32, 0x0F, 0x3A) } 19 func TestXed320F3A(t *testing.T) { testBasic(t, testXed32, 0x0F, 0x3A) }
24 func TestXed32Prefix(t *testing.T) { testPrefix(t, testXed32) } 20 func TestXed32Prefix(t *testing.T) { testPrefix(t, testXed32) }
25 21
26 func TestXed64Manual(t *testing.T) { testXed64(t, hexCases(t, xedManualTests)) } 22 func TestXed64Manual(t *testing.T) { testXed64(t, hexCases(t, xedManualTests)) }
27 func TestXed64Testdata(t *testing.T) { testXed64(t, concat(basicPrefixes, testda taCases(t))) } 23 func TestXed64Testdata(t *testing.T) { testXed64(t, concat(basicPrefixes, testda taCases(t))) }
28 func TestXed64ModRM(t *testing.T) { testXed64(t, concat(basicPrefixes, enumMo dRM)) } 24 func TestXed64ModRM(t *testing.T) { testXed64(t, concat(basicPrefixes, enumMo dRM)) }
29 func TestXed64OneByte(t *testing.T) { testBasic(t, testXed64) } 25 func TestXed64OneByte(t *testing.T) { testBasic(t, testXed64) }
30 func TestXed640F(t *testing.T) { testBasic(t, testXed64, 0x0F) } 26 func TestXed640F(t *testing.T) { testBasic(t, testXed64, 0x0F) }
31 func TestXed640F38(t *testing.T) { testBasic(t, testXed64, 0x0F, 0x38) } 27 func TestXed640F38(t *testing.T) { testBasic(t, testXed64, 0x0F, 0x38) }
32 func TestXed640F3A(t *testing.T) { testBasic(t, testXed64, 0x0F, 0x3A) } 28 func TestXed640F3A(t *testing.T) { testBasic(t, testXed64, 0x0F, 0x3A) }
33 func TestXed64Prefix(t *testing.T) { testPrefix(t, testXed64) } 29 func TestXed64Prefix(t *testing.T) { testPrefix(t, testXed64) }
34 30
35 // xedManualTests holds test cases that will be run by TestObjdumpManual. 31 func TestXed64REXTestdata(t *testing.T) {
32 » testXed64(t, filter(concat3(basicPrefixes, rexPrefixes, testdataCases(t) ), isValidREX))
33 }
34 func TestXed64REXModRM(t *testing.T) { testXed64(t, concat3(basicPrefixes, rex Prefixes, enumModRM)) }
35 func TestXed64REXOneByte(t *testing.T) { testBasicREX(t, testXed64) }
36 func TestXed64REX0F(t *testing.T) { testBasicREX(t, testXed64, 0x0F) }
37 func TestXed64REX0F38(t *testing.T) { testBasicREX(t, testXed64, 0x0F, 0x38) }
38 func TestXed64REX0F3A(t *testing.T) { testBasicREX(t, testXed64, 0x0F, 0x3A) }
39 func TestXed64REXPrefix(t *testing.T) { testPrefixREX(t, testXed64) }
40
41 // xedManualTests holds test cases that will be run by TestXedManual32 and TestX edManual64.
36 // If you are debugging a few cases that turned up in a longer run, it can be us eful 42 // If you are debugging a few cases that turned up in a longer run, it can be us eful
37 // to list them here and then use -run=ObjdumpManual, particularly with tracing enabled. 43 // to list them here and then use -run=XedManual, particularly with tracing enab led.
38 var xedManualTests = ` 44 var xedManualTests = `
39 90
40 6690
41 ` 45 `
42 46
43 // allowedMismatchXed reports whether the mismatch between text and dec 47 // allowedMismatchXed reports whether the mismatch between text and dec
44 // should be allowed by the test. 48 // should be allowed by the test.
45 func allowedMismatchXed(text string, size int, inst *Inst, dec ExtInst) bool { 49 func allowedMismatchXed(text string, size int, inst *Inst, dec ExtInst) bool {
46 » if contains(text, "error: unrecognized instruction") && contains(dec.tex t, "GENERAL_ERROR") { 50 » if (contains(text, "error:") || isPrefix(text) && size == 1) && contains (dec.text, "GENERAL_ERROR", "INSTR_TOO_LONG", "BAD_LOCK_PREFIX") {
47 » » return true
48 » }
49
50 » if isPrefix(text) && size == 1 && contains(dec.text, "GENERAL_ERROR", "I NSTR_TOO_LONG", "BAD_LOCK_PREFIX") {
51 return true 51 return true
52 } 52 }
53 53
54 if contains(dec.text, "BAD_LOCK_PREFIX") && countExactPrefix(inst, Prefi xLOCK|PrefixInvalid) > 0 { 54 if contains(dec.text, "BAD_LOCK_PREFIX") && countExactPrefix(inst, Prefi xLOCK|PrefixInvalid) > 0 {
55 return true 55 return true
56 } 56 }
57 57
58 if contains(dec.text, "BAD_LOCK_PREFIX", "GENERAL_ERROR") && countExactP refix(inst, PrefixLOCK|PrefixImplicit) > 0 { 58 if contains(dec.text, "BAD_LOCK_PREFIX", "GENERAL_ERROR") && countExactP refix(inst, PrefixLOCK|PrefixImplicit) > 0 {
59 return true 59 return true
60 } 60 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 rsqrtps 199 rsqrtps
200 rcpps 200 rcpps
201 emms 201 emms
202 ldmxcsr 202 ldmxcsr
203 stmxcsr 203 stmxcsr
204 movhpd 204 movhpd
205 movnti 205 movnti
206 rdrand 206 rdrand
207 movbe 207 movbe
208 movlpd 208 movlpd
209 sysret
209 `) 210 `)
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b