コード例 #1
0
ファイル: file_test.go プロジェクト: Harvey-OS/go
func TestDWARFRelocations(t *testing.T) {
	for i, test := range relocationTests {
		f, err := Open(test.file)
		if err != nil {
			t.Error(err)
			continue
		}
		dwarf, err := f.DWARF()
		if err != nil {
			t.Error(err)
			continue
		}
		for _, testEntry := range test.entries {
			reader := dwarf.Reader()
			for j := 0; j < testEntry.entryNumber; j++ {
				entry, err := reader.Next()
				if entry == nil || err != nil {
					t.Errorf("Failed to skip to entry %d: %v", testEntry.entryNumber, err)
					continue
				}
			}
			entry, err := reader.Next()
			if err != nil {
				t.Error(err)
				continue
			}
			if !reflect.DeepEqual(testEntry.entry, entry) {
				t.Errorf("#%d/%d: mismatch: got:%#v want:%#v", i, testEntry.entryNumber, entry, testEntry.entry)
				continue
			}
		}
	}
}
コード例 #2
0
ファイル: file_test.go プロジェクト: Harvey-OS/go
func TestCompressedDWARF(t *testing.T) {
	// Test file built with GCC 4.8.4 and as 2.24 using:
	// gcc -Wa,--compress-debug-sections -g -c -o zdebug-test-gcc484-x86-64.obj hello.c
	f, err := Open("testdata/zdebug-test-gcc484-x86-64.obj")
	if err != nil {
		t.Fatal(err)
	}
	dwarf, err := f.DWARF()
	if err != nil {
		t.Fatal(err)
	}
	reader := dwarf.Reader()
	n := 0
	for {
		entry, err := reader.Next()
		if err != nil {
			t.Fatal(err)
		}
		if entry == nil {
			break
		}
		n++
	}
	if n != 18 {
		t.Fatalf("want %d DWARF entries, got %d", 18, n)
	}
}
コード例 #3
0
ファイル: file_test.go プロジェクト: HackLinux/openrisc
func TestDWARFRelocations(t *testing.T) {
	for i, test := range relocationTests {
		f, err := Open(test.file)
		if err != nil {
			t.Error(err)
			continue
		}
		dwarf, err := f.DWARF()
		if err != nil {
			t.Error(err)
			continue
		}
		reader := dwarf.Reader()
		// Checking only the first entry is sufficient since it has
		// many different strings. If the relocation had failed, all
		// the string offsets would be zero and all the strings would
		// end up being the same.
		firstEntry, err := reader.Next()
		if err != nil {
			t.Error(err)
			continue
		}

		if !reflect.DeepEqual(test.firstEntry, firstEntry) {
			t.Errorf("#%d: mismatch: got:%#v want:%#v", i, firstEntry, test.firstEntry)
			continue
		}
	}
}