diff options
| author | Zubin Mithra <zsm@chromium.org> | 2019-10-08 15:57:52 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-10-22 10:09:57 +0200 |
| commit | a2bdbd8c37841cc507a2ad59f25d90d6467e5858 (patch) | |
| tree | bc4ad0e738a749c2321b7181e4ea04c5615738e7 /pkg/instance | |
| parent | 37dc03de04826cc0d5d1e3699832b0a3113d40af (diff) | |
pkg/bisect: add initial testing support for cause bisection
(note: incomplete change)
Refactor existing code as follows:
* Move reusable test utility functions from git_repo_test.go to
pkg/vcs/test_util.go and make them exported.
* Split Run() into Run()+runImpl().
* Change type of bisect.go:env.inst to `instance.BuilderTester`.
Change usage inside syz-testbuild/testbuild.go accordingly.
* Move most of linux.PreviousReleaseTags() into vcs/git.go as
git.previousReleaseTags().
* Allow build.CompilerIdentity to be mocked.
Introduce the following changes:
* instance.BuilderTester is an interface with methods
BuildSyzkaller()
BuildKernel()
Test()
NewEnv() now returns this interface.
* type testEnv implements instance.BuilderTester.
* type testBuilder implements builder interface. Add a entry into table
inside pkg/build/build.go:getBuilder() to return testBuilder object.
Diffstat (limited to 'pkg/instance')
| -rw-r--r-- | pkg/instance/instance.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index cc1b147f1..b3e24aace 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -27,11 +27,17 @@ import ( "github.com/google/syzkaller/vm" ) -type Env struct { +type BuilderTester interface { + BuildSyzkaller(string, string) error + BuildKernel(string, string, string, string, []byte) (string, error) + Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]error, error) +} + +type env struct { cfg *mgrconfig.Config } -func NewEnv(cfg *mgrconfig.Config) (*Env, error) { +func NewEnv(cfg *mgrconfig.Config) (BuilderTester, error) { if !vm.AllowsOvercommit(cfg.Type) { return nil, fmt.Errorf("test instances are not supported for %v VMs", cfg.Type) } @@ -47,13 +53,13 @@ func NewEnv(cfg *mgrconfig.Config) (*Env, error) { if err := osutil.MkdirAll(cfg.Workdir); err != nil { return nil, fmt.Errorf("failed to create tmp dir: %v", err) } - env := &Env{ + env := &env{ cfg: cfg, } return env, nil } -func (env *Env) BuildSyzkaller(repo, commit string) error { +func (env *env) BuildSyzkaller(repo, commit string) error { cfg := env.cfg srcIndex := strings.LastIndex(cfg.Syzkaller, "/src/") if srcIndex == -1 { @@ -82,7 +88,7 @@ func (env *Env) BuildSyzkaller(repo, commit string) error { return nil } -func (env *Env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, +func (env *env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile string, kernelConfig []byte) (string, error) { cfg := env.cfg imageDir := filepath.Join(cfg.Workdir, "image") @@ -170,7 +176,7 @@ func (err *CrashError) Error() string { // Test boots numVMs VMs, tests basic kernel operation, and optionally tests the provided reproducer. // TestError is returned if there is a problem with kernel/image (crash, reboot loop, etc). // CrashError is returned if the reproducer crashes kernel. -func (env *Env) Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]error, error) { +func (env *env) Test(numVMs int, reproSyz, reproOpts, reproC []byte) ([]error, error) { if err := mgrconfig.Complete(env.cfg); err != nil { return nil, err } |
