mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-28 05:40:26 +00:00
6193630786
SKIP/BROKEN distract too much attention from FAIL tests and are not usually interesting. Add Verbose flag that controls printing of SKIP/BROKEN tests. Enable it in pkf/runtest/run_test.go by default and disable in tools/syz-runtest.
82 lines
2.0 KiB
Go
82 lines
2.0 KiB
Go
// Copyright 2018 syzkaller project authors. All rights reserved.
|
|
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
|
|
|
|
package runtest
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/google/syzkaller/pkg/csource"
|
|
"github.com/google/syzkaller/pkg/host"
|
|
"github.com/google/syzkaller/prog"
|
|
"github.com/google/syzkaller/sys/targets"
|
|
_ "github.com/google/syzkaller/sys/test/gen" // pull in the test target
|
|
)
|
|
|
|
func Test(t *testing.T) {
|
|
switch runtime.GOOS {
|
|
case "openbsd":
|
|
t.Skipf("broken on %v", runtime.GOOS)
|
|
}
|
|
for _, sysTarget := range targets.List["test"] {
|
|
sysTarget1 := targets.Get(sysTarget.OS, sysTarget.Arch)
|
|
t.Run(sysTarget1.Arch, func(t *testing.T) {
|
|
t.Parallel()
|
|
test(t, sysTarget1)
|
|
})
|
|
}
|
|
}
|
|
|
|
func test(t *testing.T, sysTarget *targets.Target) {
|
|
target, err := prog.GetTarget(sysTarget.OS, sysTarget.Arch)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if testing.Short() && target.PtrSize == 4 {
|
|
// Building 32-bit binaries fails on travis (see comments in Makefile).
|
|
t.Skip("skipping in short mode")
|
|
}
|
|
executor, err := csource.BuildFile(target, filepath.FromSlash("../../executor/executor.cc"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.Remove(executor)
|
|
features, err := host.Check(target)
|
|
if err != nil {
|
|
t.Fatalf("failed to detect host features: %v", err)
|
|
}
|
|
calls, _, err := host.DetectSupportedSyscalls(target, "none")
|
|
if err != nil {
|
|
t.Fatalf("failed to detect supported syscalls: %v", err)
|
|
}
|
|
enabledCalls := map[string]map[*prog.Syscall]bool{
|
|
"": calls,
|
|
"none": calls,
|
|
}
|
|
requests := make(chan *RunRequest, 2*runtime.GOMAXPROCS(0))
|
|
go func() {
|
|
for req := range requests {
|
|
RunTest(req, executor)
|
|
close(req.Done)
|
|
}
|
|
}()
|
|
ctx := &Context{
|
|
Dir: filepath.Join("..", "..", "sys", target.OS, "test"),
|
|
Target: target,
|
|
Features: features,
|
|
EnabledCalls: enabledCalls,
|
|
Requests: requests,
|
|
LogFunc: func(text string) {
|
|
t.Helper()
|
|
t.Logf(text)
|
|
},
|
|
Verbose: true,
|
|
}
|
|
if err := ctx.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|