* tree-vect-loop-manip.c (vect_do_peeling): Do not use
[official-gcc.git] / libgo / go / debug / plan9obj / file_test.go
blob7e107bca2f52d85a340d7e5b908a95c99fab1ed3
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.
5 package plan9obj
7 import (
8 "reflect"
9 "testing"
12 type fileTest struct {
13 file string
14 hdr FileHeader
15 sections []*SectionHeader
18 var fileTests = []fileTest{
20 "testdata/386-plan9-exec",
21 FileHeader{Magic386, 0x324, 0x14, 4, 0x1000, 32},
22 []*SectionHeader{
23 {"text", 0x4c5f, 0x20},
24 {"data", 0x94c, 0x4c7f},
25 {"syms", 0x2c2b, 0x55cb},
26 {"spsz", 0x0, 0x81f6},
27 {"pcsz", 0xf7a, 0x81f6},
31 "testdata/amd64-plan9-exec",
32 FileHeader{MagicAMD64, 0x618, 0x13, 8, 0x200000, 40},
33 []*SectionHeader{
34 {"text", 0x4213, 0x28},
35 {"data", 0xa80, 0x423b},
36 {"syms", 0x2c8c, 0x4cbb},
37 {"spsz", 0x0, 0x7947},
38 {"pcsz", 0xca0, 0x7947},
43 func TestOpen(t *testing.T) {
44 for i := range fileTests {
45 tt := &fileTests[i]
47 f, err := Open(tt.file)
48 if err != nil {
49 t.Error(err)
50 continue
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
57 for i, sh := range f.Sections {
58 if i >= len(tt.sections) {
59 break
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\twant %#v\n", tt.file, i, have, want)
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)
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)