From f6c43faab72cc4d24c97287064030de97ab74f4a Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 19 Aug 2021 13:09:46 +0000 Subject: pkg/report: return more information from opcode decompiler Let decompiler also parse the exact command name. Perform right trim on the full output line, as it may contain tabs and spaces at the end. Introduce an "-update" flag to facilitate mass updating of opcode decompilation tests after changes to this functionality. --- pkg/report/linux_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pkg/report/linux_test.go') diff --git a/pkg/report/linux_test.go b/pkg/report/linux_test.go index ec5eb3c71..bba6326e0 100644 --- a/pkg/report/linux_test.go +++ b/pkg/report/linux_test.go @@ -14,6 +14,7 @@ import ( "testing" "github.com/google/syzkaller/pkg/mgrconfig" + "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/symbolizer" "github.com/google/syzkaller/sys/targets" ) @@ -421,12 +422,16 @@ func testDisassembly(t *testing.T, reporter *linux, testFilePrefix string) { t.Fatalf("failed to read input file: %v", err) } + result := reporter.decompileReportOpcodes(input) + if *flagUpdate { + osutil.WriteFile(testFilePrefix+".out", result) + } + output, err := ioutil.ReadFile(testFilePrefix + ".out") if err != nil { t.Fatalf("failed to read output file: %v", err) } - result := reporter.decompileReportOpcodes(input) if !bytes.Equal(output, result) { t.Fatalf("Expected:\n%s\nGot:\n%s\n", output, result) } -- cgit mrf-deployment