diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-12-17 16:55:42 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-12-17 19:09:03 +0100 |
| commit | b38da77e00c6c2fb3424224657e9f665e519ea2d (patch) | |
| tree | e4287fc16c85a0c8e499121303a8f9dd00cfc7b2 /pkg | |
| parent | 61adbb167eba0cc237dde8c0d9edee68ddb78623 (diff) | |
pkg/bisect: check existence of input files
It's better to fail early then to wait for kernel build.
Update #501
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/bisect/bisect.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index c78508368..df5dfcd90 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -64,6 +64,9 @@ type buildEnv struct { } func Run(cfg *Config) (*vcs.Commit, error) { + if err := checkConfig(cfg); err != nil { + return nil, err + } repo, err := vcs.NewRepo(cfg.Manager.TargetOS, cfg.Manager.Type, cfg.Manager.KernelSrc) if err != nil { return nil, err @@ -337,9 +340,26 @@ func (env *env) saveDebugFile(hash string, idx int, data []byte) { if env.cfg.DebugDir == "" || len(data) == 0 { return } + osutil.MkdirAll(env.cfg.DebugDir) osutil.WriteFile(filepath.Join(env.cfg.DebugDir, fmt.Sprintf("%v.%v", hash, idx)), data) } +func checkConfig(cfg *Config) error { + if !osutil.IsExist(cfg.BinDir) { + return fmt.Errorf("bin dir %v does not exist", cfg.BinDir) + } + if cfg.Kernel.Userspace != "" && !osutil.IsExist(cfg.Kernel.Userspace) { + return fmt.Errorf("userspace dir %v does not exist", cfg.Kernel.Userspace) + } + if cfg.Kernel.Sysctl != "" && !osutil.IsExist(cfg.Kernel.Sysctl) { + return fmt.Errorf("sysctl file %v does not exist", cfg.Kernel.Sysctl) + } + if cfg.Kernel.Cmdline != "" && !osutil.IsExist(cfg.Kernel.Cmdline) { + return fmt.Errorf("cmdline file %v does not exist", cfg.Kernel.Cmdline) + } + return nil +} + func (env *env) log(msg string, args ...interface{}) { fmt.Fprintf(env.cfg.Trace, msg+"\n", args...) } |
