diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-10-26 10:51:06 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-10-26 15:44:28 +0100 |
| commit | e6e35dba937599d098fc034eff2686e5ddc409e9 (patch) | |
| tree | 802be708d0bc84dee01b9285639690a53f1f6f94 /vm/gce/gce.go | |
| parent | d46bc75207fea1d7671c1277dd660cf1a4d7847b (diff) | |
sys/targets: add OS/Arch name consts
We use strings to identify OS/Arch.
These strings are duplicated throughout the code base massively.
golangci-lint points to possiblity of typos and duplication.
We already had to define these names in pkg/csource
and disable checking for prog package. A future change triggers
such warnings in another package.
Add OS/Arch name consts to sys/targets so that they can be used
to refer to OS/Arch. Use the consts everywhere.
Diffstat (limited to 'vm/gce/gce.go')
| -rw-r--r-- | vm/gce/gce.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 7bc049cb2..e3f23ccee 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -28,6 +28,7 @@ import ( "github.com/google/syzkaller/pkg/kd" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/osutil" + "github.com/google/syzkaller/sys/targets" "github.com/google/syzkaller/vm/vmimpl" ) @@ -248,7 +249,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin } merger := vmimpl.NewOutputMerger(tee) var decoder func(data []byte) (int, int, []byte) - if inst.env.OS == "windows" { + if inst.env.OS == targets.Windows { decoder = kd.Decode } merger.AddDecoder("console", conRpipe, decoder) @@ -264,7 +265,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin sshRpipe.Close() return nil, nil, err } - if inst.env.OS == "linux" { + if inst.env.OS == targets.Linux { if inst.sshUser != "root" { command = fmt.Sprintf("sudo bash -c '%v'", command) } @@ -369,10 +370,10 @@ func waitForConsoleConnect(merger *vmimpl.OutputMerger) error { } func (inst *instance) Diagnose() ([]byte, bool) { - if inst.env.OS == "freebsd" { + if inst.env.OS == targets.FreeBSD { return vmimpl.DiagnoseFreeBSD(inst.consolew) } - if inst.env.OS == "openbsd" { + if inst.env.OS == targets.OpenBSD { return vmimpl.DiagnoseOpenBSD(inst.consolew) } return nil, false |
