forked from mandiant/GoReSym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
82 lines (66 loc) · 2.27 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*Copyright (C) 2022 Mandiant, Inc. All Rights Reserved.*/
package main
import (
"errors"
"fmt"
"os"
"testing"
)
var versions = []string{"117", "116", "115", "114", "113", "112", "111", "110", "19", "18", "17", "16", "15"}
var fileNames = []string{"testproject_lin", "testproject_lin_32", "testproject_lin_stripped", "testproject_lin_stripped_32", "testproject_mac", "testproject_mac_stripped", "testproject_win_32.exe", "testproject_win_stripped_32.exe", "testproject_win_stripped.exe", "testproject_win.exe"}
func TestAllVersions(t *testing.T) {
workingDirectory, err := os.Getwd()
if err != nil {
t.Errorf("Failed to get working directory")
}
fmt.Println(workingDirectory)
for _, v := range versions {
for _, file := range fileNames {
versionPath := fmt.Sprintf("%s/%s", v, file)
filePath := fmt.Sprintf("%s/test/build/%s", workingDirectory, versionPath)
if _, err := os.Stat(filePath); errors.Is(err, os.ErrNotExist) {
fmt.Printf("Test file %s doesn't exist\n", filePath)
continue
}
t.Run(versionPath, func(t *testing.T) {
data, err := main_impl(filePath, true, true, true, 0, "")
if err != nil {
t.Errorf("Go %s failed on %s: %s", v, file, err)
}
if data.TabMeta.VA == 0 {
t.Errorf("Go %s pclntab location failed on %s: %s", v, file, err)
}
if data.ModuleMeta.VA == 0 {
t.Errorf("Go %s moduledata location failed on %s: %s", v, file, err)
}
if len(data.Types) == 0 {
t.Errorf("Go %s type parsing failed on %s: %s", v, file, err)
}
// unsupported
if v != "15" && v != "16" {
if len(data.Interfaces) == 0 {
t.Errorf("Go %s interface parsing failed on %s: %s", v, file, err)
}
}
if len(data.StdFunctions) == 0 {
t.Errorf("Go %s std functions failed on %s: %s", v, file, err)
}
if len(data.UserFunctions) == 0 {
t.Errorf("Go %s user functions failed on %s: %s", v, file, err)
}
if len(data.Files) == 0 {
t.Errorf("Go %s files failed on %s: %s", v, file, err)
}
if data.Version == "" {
t.Errorf("Go %s version failed on %s: %s", v, file, err)
}
if data.OS == "" {
t.Errorf("Go %s OS failed on %s: %s", v, file, err)
}
if data.Arch == "" {
t.Errorf("Go %s Arch failed on %s: %s", v, file, err)
}
})
}
}
}