From 7288521c2ab2ce481a739e2f9d5dc0ec4642fc66 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 22 Aug 2020 17:18:02 +0200 Subject: pkg/ipc: run cross-arch executor tests We may run some cross-arch tests using qemu-user. --- pkg/ipc/ipc_test.go | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'pkg/ipc') diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index 3460657bc..f0e19ed33 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -18,6 +18,7 @@ import ( "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys" + "github.com/google/syzkaller/sys/targets" ) const timeout = 10 * time.Second @@ -57,17 +58,29 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, bool, bool) { // TestExecutor runs all internal executor unit tests. // We do it here because we already build executor binary here. func TestExecutor(t *testing.T) { - target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) - if err != nil { - t.Fatal(err) - } - bin := buildExecutor(t, target) - defer os.Remove(bin) - output, err := osutil.RunCmd(time.Minute, "", bin, "test") - if err != nil { - t.Fatal(err) + t.Parallel() + for _, sysTarget := range targets.List[runtime.GOOS] { + sysTarget := sysTarget + t.Run(sysTarget.Arch, func(t *testing.T) { + if sysTarget.BrokenCompiler != "" { + t.Skipf("skipping, broken cross-compiler: %v", sysTarget.BrokenCompiler) + } + t.Parallel() + target, err := prog.GetTarget(runtime.GOOS, sysTarget.Arch) + if err != nil { + t.Fatal(err) + } + bin := buildExecutor(t, target) + defer os.Remove(bin) + // qemu-user may allow us to run some cross-arch binaries. + if _, err := osutil.RunCmd(time.Minute, "", bin, "test"); err != nil { + if sysTarget.Arch == runtime.GOOS || sysTarget.VMArch == runtime.GOOS { + t.Fatal(err) + } + t.Skipf("skipping, cross-arch binary failed: %v", err) + } + }) } - t.Logf("executor output:\n%s", output) } func TestExecute(t *testing.T) { -- cgit mrf-deployment