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

Side by Side Diff: src/pkg/debug/plan9obj/file_test.go

Issue 49970044: code review 49970044: debug/plan9obj: implement parsing of Plan 9 a.out execu... (Closed)
Patch Set: diff -r f9e8a970798c https://code.google.com/p/go Created 11 years, 1 month 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/debug/plan9obj/file.go ('k') | src/pkg/debug/plan9obj/plan9obj.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package plan9obj
6
7 import (
8 "reflect"
9 "testing"
10 )
11
12 type fileTest struct {
13 file string
14 hdr FileHeader
15 sections []*SectionHeader
16 }
17
18 var fileTests = []fileTest{
19 {
20 "testdata/386-plan9-exec",
21 FileHeader{4},
22 []*SectionHeader{
23 {"text", 0x4c5f, 0x20},
24 {"data", 0x94c, 0x4c7f},
25 {"syms", 0x2c2b, 0x55cb},
26 {"spsz", 0x0, 0x81f6},
27 {"pcsz", 0xf7a, 0x81f6},
28 },
29 },
30 {
31 "testdata/amd64-plan9-exec",
32 FileHeader{8},
33 []*SectionHeader{
34 {"text", 0x4213, 0x28},
35 {"data", 0xa80, 0x423b},
36 {"syms", 0x2c8c, 0x4cbb},
37 {"spsz", 0x0, 0x7947},
38 {"pcsz", 0xca0, 0x7947},
39 },
40 },
41 }
42
43 func TestOpen(t *testing.T) {
44 for i := range fileTests {
45 tt := &fileTests[i]
46
47 f, err := Open(tt.file)
48 if err != nil {
49 t.Error(err)
50 continue
51 }
52 if !reflect.DeepEqual(f.FileHeader, tt.hdr) {
53 t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr)
54 continue
55 }
56
57 for i, sh := range f.Sections {
58 if i >= len(tt.sections) {
59 break
60 }
61 have := &sh.SectionHeader
62 want := tt.sections[i]
63 if !reflect.DeepEqual(have, want) {
64 t.Errorf("open %s, section %d:\n\thave %#v\n\twa nt %#v\n", tt.file, i, have, want)
65 }
66 }
67 tn := len(tt.sections)
68 fn := len(f.Sections)
69 if tn != fn {
70 t.Errorf("open %s: len(Sections) = %d, want %d", tt.file , fn, tn)
71 }
72 }
73 }
74
75 func TestOpenFailure(t *testing.T) {
76 filename := "file.go" // not a Plan 9 a.out file
77 _, err := Open(filename) // don't crash
78 if err == nil {
79 t.Errorf("open %s: succeeded unexpectedly", filename)
80 }
81 }
OLDNEW
« no previous file with comments | « src/pkg/debug/plan9obj/file.go ('k') | src/pkg/debug/plan9obj/plan9obj.go » ('j') | no next file with comments »

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