github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/vcs/testos.go (about) 1 // Copyright 2019 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package vcs 5 6 import ( 7 "fmt" 8 9 "github.com/google/syzkaller/pkg/debugtracer" 10 "github.com/google/syzkaller/pkg/report/crash" 11 "github.com/google/syzkaller/sys/targets" 12 ) 13 14 type testos struct { 15 *git 16 } 17 18 var _ ConfigMinimizer = new(testos) 19 20 func newTestos(dir string, opts []RepoOpt) *testos { 21 return &testos{ 22 git: newGit(dir, nil, opts), 23 } 24 } 25 26 func (ctx *testos) PreviousReleaseTags(commit, compilerType string) ([]string, error) { 27 return ctx.git.previousReleaseTags(commit, false, false, false) 28 } 29 30 func (ctx *testos) EnvForCommit( 31 defaultCompiler, compilerType, binDir, commit string, kernelConfig []byte, 32 backports []BackportCommit, 33 ) (*BisectEnv, error) { 34 return &BisectEnv{KernelConfig: kernelConfig}, nil 35 } 36 37 func (ctx *testos) Minimize(target *targets.Target, original, baseline []byte, types []crash.Type, 38 dt debugtracer.DebugTracer, pred func(test []byte) (BisectResult, error)) ([]byte, error) { 39 if len(baseline) == 0 { 40 return original, nil 41 } 42 if res, err := pred(baseline); err != nil { 43 return nil, err 44 } else if res == BisectBad { 45 return baseline, nil 46 } 47 switch string(baseline) { 48 case "minimize-fails": 49 return nil, fmt.Errorf("minimization failure") 50 case "minimize-succeeds": 51 config := []byte("new-minimized-config") 52 pred(config) 53 return config, nil 54 default: 55 return original, nil 56 } 57 } 58 59 func (ctx *testos) PrepareBisect() error { 60 return nil 61 }