diff options
| author | Space Meyer <meyerpatrick@google.com> | 2022-08-25 14:10:27 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-09-01 10:42:40 +0200 |
| commit | 3f79a9101d6ae91acf7edde3727992988bb01ae1 (patch) | |
| tree | 02fffb61eeecc65328969e918d718cbaba5265e5 | |
| parent | 8ed3d47016fdf9afc7672bd6fddcf4a7250b6d12 (diff) | |
pkg/vcs: fetch linux upstream stable before bisections
| -rw-r--r-- | pkg/bisect/bisect.go | 5 | ||||
| -rw-r--r-- | pkg/vcs/linux.go | 19 | ||||
| -rw-r--r-- | pkg/vcs/testos.go | 4 | ||||
| -rw-r--r-- | pkg/vcs/vcs.go | 8 |
4 files changed, 32 insertions, 4 deletions
diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index bc442c16a..0948bc653 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -201,6 +201,11 @@ func runImpl(cfg *Config, repo vcs.Repo, inst instance.Env) (*Result, error) { } func (env *env) bisect() (*Result, error) { + err := env.bisecter.PrepareBisect() + if err != nil { + return nil, err + } + cfg := env.cfg if err := build.Clean(cfg.Manager.TargetOS, cfg.Manager.TargetVMArch, cfg.Manager.Type, cfg.Manager.KernelSrc); err != nil { diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index a44729233..d2371ca5c 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -23,6 +23,7 @@ import ( type linux struct { *git + vmType string } var ( @@ -30,12 +31,14 @@ var ( _ ConfigMinimizer = new(linux) ) -func newLinux(dir string, opts []RepoOpt) *linux { +func newLinux(dir string, opts []RepoOpt, vmType string) *linux { ignoreCC := map[string]bool{ "stable@vger.kernel.org": true, } + return &linux{ - git: newGit(dir, ignoreCC, opts), + git: newGit(dir, ignoreCC, opts), + vmType: vmType, } } @@ -248,6 +251,18 @@ func linuxAlterConfigs(cf *kconfig.ConfigFile, tags map[string]bool) { } } +func (ctx *linux) PrepareBisect() error { + if ctx.vmType != "gvisor" { + // Some linux repos we fuzz don't import the upstream release git tags. We need tags + // to decide which compiler versions to use. Let's fetch upstream for its tags. + err := ctx.git.fetchRemote("https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git") + if err != nil { + return fmt.Errorf("fetching upstream linux failed: %w", err) + } + } + return nil +} + func (ctx *linux) Bisect(bad, good string, dt debugtracer.DebugTracer, pred func() (BisectResult, error)) ([]*Commit, error) { commits, err := ctx.git.Bisect(bad, good, dt, pred) diff --git a/pkg/vcs/testos.go b/pkg/vcs/testos.go index c9acf1781..baadb1a2a 100644 --- a/pkg/vcs/testos.go +++ b/pkg/vcs/testos.go @@ -48,3 +48,7 @@ func (ctx *testos) Minimize(target *targets.Target, original, baseline []byte, return original, nil } } + +func (ctx *testos) PrepareBisect() error { + return nil +} diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index 2355cac69..ae7bc8508 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -64,6 +64,10 @@ type Repo interface { // Bisecter may be optionally implemented by Repo. type Bisecter interface { + // Can be used for last minute preparations like pulling release tags into the bisected repo, which + // is required to determin the compiler version to use on linux. Can be an empty function. + PrepareBisect() error + // Bisect bisects good..bad commit range against the provided predicate (wrapper around git bisect). // The predicate should return an error only if there is no way to proceed // (it will abort the process), if possible it should prefer to return BisectSkip. @@ -172,10 +176,10 @@ const ( OptDontSandbox ) -func NewRepo(os, vm, dir string, opts ...RepoOpt) (Repo, error) { +func NewRepo(os, vmType, dir string, opts ...RepoOpt) (Repo, error) { switch os { case targets.Linux: - return newLinux(dir, opts), nil + return newLinux(dir, opts, vmType), nil case targets.Akaros: return newAkaros(dir, opts), nil case targets.Fuchsia: |
