From 551aee64cd4d0daebf60a0c0aed4a4e09a9d39b6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 26 Jun 2024 12:02:08 +0200 Subject: pkg/runtest: shorted parsing tests Parsing auto-generated seeds takes lots of time: --- PASS: TestParsing/linux/mips64le (56.86s) --- PASS: TestParsing/linux/amd64 (53.63s) --- PASS: TestParsing/linux/arm64 (53.32s) --- PASS: TestParsing/linux/arm (53.57s) --- PASS: TestParsing/linux/386 (53.59s) --- PASS: TestParsing/linux/s390x (43.09s) --- PASS: TestParsing/linux/riscv64 (43.17s) --- PASS: TestParsing/linux/ppc64le (43.12s) Don't even parse them. After: --- PASS: TestParsing/fuchsia/amd64 (0.48s) --- PASS: TestParsing/test/64_fork (0.59s) --- PASS: TestParsing/linux/386 (3.04s) --- PASS: TestParsing/linux/arm64 (3.08s) --- PASS: TestParsing/linux/riscv64 (3.10s) --- PASS: TestParsing/linux/s390x (3.13s) --- PASS: TestParsing/linux/amd64 (3.13s) --- PASS: TestParsing/linux/arm (3.14s) --- PASS: TestParsing/linux/mips64le (3.21s) --- PASS: TestParsing/test/32 (0.37s) --- PASS: TestParsing/fuchsia/arm64 (0.35s) --- PASS: TestParsing/test/32_fork (0.57s) --- PASS: TestParsing/test/64 (0.53s) --- PASS: TestParsing/test/64_fuzz (0.54s) --- PASS: TestParsing/linux/ppc64le (2.87s) --- pkg/runtest/run.go | 11 ++++++----- pkg/runtest/run_test.go | 10 ++++------ 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'pkg/runtest') diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index cef85f6e9..50af943e0 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -197,7 +197,7 @@ func progFileList(dir, filter string) ([]string, error) { } func (ctx *Context) generateFile(sandboxes []string, cover []bool, filename string) error { - p, requires, results, err := parseProg(ctx.Target, ctx.Dir, filename) + p, requires, results, err := parseProg(ctx.Target, ctx.Dir, filename, nil) if err != nil { return err } @@ -282,15 +282,16 @@ nextSandbox: return nil } -func parseProg(target *prog.Target, dir, filename string) (*prog.Prog, map[string]bool, *flatrpc.ProgInfo, error) { +func parseProg(target *prog.Target, dir, filename string, requires map[string]bool) ( + *prog.Prog, map[string]bool, *flatrpc.ProgInfo, error) { data, err := os.ReadFile(filepath.Join(dir, filename)) if err != nil { return nil, nil, nil, fmt.Errorf("failed to read %v: %w", filename, err) } - requires := parseRequires(data) + 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(requires, target.Arch) { + if !checkArch(properties, target.Arch) || !match(properties, requires) { return nil, nil, nil, nil } p, err := target.Deserialize(data, prog.Strict) @@ -345,7 +346,7 @@ func parseProg(target *prog.Target, dir, filename string) (*prog.Prog, map[strin } info.Calls = append(info.Calls, ci) } - return p, requires, info, nil + return p, properties, info, nil } func parseRequires(data []byte) map[string]bool { diff --git a/pkg/runtest/run_test.go b/pkg/runtest/run_test.go index 92b6c2d77..af613ed30 100644 --- a/pkg/runtest/run_test.go +++ b/pkg/runtest/run_test.go @@ -414,7 +414,10 @@ func TestParsing(t *testing.T) { t.Run(fmt.Sprintf("%v/%v", target.OS, target.Arch), func(t *testing.T) { t.Parallel() for _, file := range files { - p, requires, _, err := parseProg(target, dir, file) + // syz_mount_image tests are very large and this test takes too long. + // syz-imagegen that generates does some of this testing (Deserialize/SerializeForExec). + requires := map[string]bool{"manual": false} + p, _, _, err := parseProg(target, dir, file, requires) if err != nil { t.Errorf("failed to parse %v: %v", file, err) } @@ -424,11 +427,6 @@ func TestParsing(t *testing.T) { if runtime.GOOS != sysTarget.BuildOS { continue // we need at least preprocessor binary to generate sources } - // syz_mount_image tests are very large and this test takes too long. - // syz-imagegen that generates does some of this testing (Deserialize/SerializeForExec). - if requires["manual"] { - continue - } if _, err = csource.Write(p, csource.ExecutorOpts); err != nil { t.Errorf("failed to generate C source for %v: %v", file, err) } -- cgit mrf-deployment