aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report/linux_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-07-11 13:26:59 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-07-12 15:59:14 +0200
commitdb33b3dda2268ab83d456651df956500b1caea5f (patch)
treeb4c347443bdb7b9f1a70eb2858c5bb4733c9c80e /pkg/report/linux_test.go
parentda3d6955d5ab2888e1d0a86d6401d2aaf48406f3 (diff)
pkg/report: don't decompile opcodes for hanged reports
It doesn't bring any extra value and only makes the reports bigger. Don't do such decompilation for hang-related reports. Refactor the opcode tests to rely more on the more generic NewReporter constructor.
Diffstat (limited to 'pkg/report/linux_test.go')
-rw-r--r--pkg/report/linux_test.go38
1 files changed, 23 insertions, 15 deletions
diff --git a/pkg/report/linux_test.go b/pkg/report/linux_test.go
index bba6326e0..5aba2f19e 100644
--- a/pkg/report/linux_test.go
+++ b/pkg/report/linux_test.go
@@ -238,15 +238,19 @@ func TestLinuxSymbolizeLine(t *testing.T) {
}
}
-func prepareLinuxReporter(t *testing.T, arch string) *linux {
- config := &config{
- target: targets.Get(targets.Linux, arch),
+func prepareLinuxReporter(t *testing.T, arch string) (*Reporter, *linux) {
+ cfg := &mgrconfig.Config{
+ Derived: mgrconfig.Derived{
+ TargetOS: targets.Linux,
+ TargetArch: arch,
+ SysTarget: targets.Get(targets.Linux, arch),
+ },
}
- reporter, _, err := ctorLinux(config)
+ reporter, err := NewReporter(cfg)
if err != nil {
- t.Errorf("Failed to create a reporter instance %#v", arch)
+ t.Errorf("Failed to create a reporter instance for %#v: %v", arch, err)
}
- return reporter.(*linux)
+ return reporter, reporter.impl.(*linux)
}
func TestParseLinuxOpcodes(t *testing.T) {
@@ -362,8 +366,8 @@ func TestParseLinuxOpcodes(t *testing.T) {
test := test // Capturing the value.
t.Run(fmt.Sprintf("%s/%v", test.arch, idx), func(t *testing.T) {
t.Parallel()
- reporter := prepareLinuxReporter(t, test.arch)
- ret, err := reporter.parseOpcodes(test.input)
+ _, linuxReporter := prepareLinuxReporter(t, test.arch)
+ ret, err := linuxReporter.parseOpcodes(test.input)
if test.output == nil && err == nil {
t.Errorf("Expected an error on input %#v", test)
} else if test.output != nil && err != nil {
@@ -390,10 +394,9 @@ func TestDisassemblyInReports(t *testing.T) {
if !obj.IsDir() {
continue
}
- reporter := prepareLinuxReporter(t, obj.Name())
-
- if reporter.target.BrokenCompiler != "" {
- t.Skip("skipping the test due to broken cross-compiler:\n" + reporter.target.BrokenCompiler)
+ reporter, linuxReporter := prepareLinuxReporter(t, obj.Name())
+ if linuxReporter.target.BrokenCompiler != "" {
+ t.Skip("skipping the test due to broken cross-compiler:\n" + linuxReporter.target.BrokenCompiler)
}
testPath := filepath.Join(archPath, obj.Name())
@@ -408,13 +411,13 @@ func TestDisassemblyInReports(t *testing.T) {
}
filePath := filepath.Join(testPath, strings.TrimSuffix(file.Name(), ".in"))
t.Run(obj.Name()+"/"+file.Name(), func(t *testing.T) {
- testDisassembly(t, reporter, filePath)
+ testDisassembly(t, reporter, linuxReporter, filePath)
})
}
}
}
-func testDisassembly(t *testing.T, reporter *linux, testFilePrefix string) {
+func testDisassembly(t *testing.T, reporter *Reporter, linuxReporter *linux, testFilePrefix string) {
t.Parallel()
input, err := ioutil.ReadFile(testFilePrefix + ".in")
@@ -422,7 +425,12 @@ func testDisassembly(t *testing.T, reporter *linux, testFilePrefix string) {
t.Fatalf("failed to read input file: %v", err)
}
- result := reporter.decompileReportOpcodes(input)
+ report := reporter.Parse(input)
+ if report == nil {
+ t.Fatalf("no bug report was found")
+ }
+
+ result := linuxReporter.decompileOpcodes(input, report)
if *flagUpdate {
osutil.WriteFile(testFilePrefix+".out", result)
}