aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/runtest/run.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/runtest/run.go')
-rw-r--r--pkg/runtest/run.go62
1 files changed, 4 insertions, 58 deletions
diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go
index 1ea5c7a7e..213ce3f58 100644
--- a/pkg/runtest/run.go
+++ b/pkg/runtest/run.go
@@ -14,6 +14,7 @@ import (
"bufio"
"bytes"
"context"
+ "errors"
"fmt"
"os"
"path/filepath"
@@ -305,13 +306,10 @@ func parseProg(target *prog.Target, dir, filename string, requires map[string]bo
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to read %v: %w", filename, err)
}
- properties := parseRequires(data)
- // Need to check arch requirement early as some programs
- // may fail to deserialize on some arches due to missing syscalls.
- if !checkArch(properties, target.Arch) || !match(properties, requires) {
+ p, properties, err := manager.ParseSeedWithRequirements(target, data, requires)
+ if errors.Is(err, manager.ErrSkippedTest) {
return nil, nil, nil, nil
}
- p, err := manager.ParseSeedStrict(target, data)
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to deserialize %v: %w", filename, err)
}
@@ -366,42 +364,11 @@ func parseProg(target *prog.Target, dir, filename string, requires map[string]bo
return p, properties, info, nil
}
-func parseRequires(data []byte) map[string]bool {
- requires := make(map[string]bool)
- for s := bufio.NewScanner(bytes.NewReader(data)); s.Scan(); {
- const prefix = "# requires:"
- line := s.Text()
- if !strings.HasPrefix(line, prefix) {
- continue
- }
- for _, req := range strings.Fields(line[len(prefix):]) {
- positive := true
- if req[0] == '-' {
- positive = false
- req = req[1:]
- }
- requires[req] = positive
- }
- }
- return requires
-}
-
-func checkArch(requires map[string]bool, arch string) bool {
- for req, positive := range requires {
- const prefix = "arch="
- if strings.HasPrefix(req, prefix) &&
- arch != req[len(prefix):] == positive {
- return false
- }
- }
- return true
-}
-
func (ctx *Context) produceTest(req *runRequest, name string, properties,
requires map[string]bool, results *flatrpc.ProgInfo) {
req.name = name
req.results = results
- if !match(properties, requires) {
+ if !manager.MatchRequirements(properties, requires) {
req.skip = "excluded by constraints"
}
ctx.createTest(req)
@@ -445,27 +412,6 @@ func (ctx *Context) submit(req *runRequest) {
req.executor.Submit(req.Request)
}
-func match(props, requires map[string]bool) bool {
- for req, positive := range requires {
- if positive {
- if !props[req] {
- return false
- }
- continue
- }
- matched := true
- for _, req1 := range strings.Split(req, ",") {
- if !props[req1] {
- matched = false
- }
- }
- if matched {
- return false
- }
- }
- return true
-}
-
func (ctx *Context) createSyzTest(p *prog.Prog, sandbox string, threaded, cov bool) (*runRequest, error) {
var opts flatrpc.ExecOpts
sandboxFlags, err := flatrpc.SandboxToFlags(sandbox)