Fix the dependency issue (#231)
This commit is contained in:
3
vendor/github.com/vmware/vmw-guestinfo/README
generated
vendored
3
vendor/github.com/vmware/vmw-guestinfo/README
generated
vendored
@@ -1,3 +0,0 @@
|
||||
This package provides access to the guestinfo variables exposed to a VMware virtual machine.
|
||||
|
||||
see examples/main.go for an example
|
||||
43
vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_386_test.go
generated
vendored
43
vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_386_test.go
generated
vendored
@@ -1,43 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bdoor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
)
|
||||
|
||||
func TestBdoorArgAlignment(t *testing.T) {
|
||||
a := uint32(0xFFFFFFFF)
|
||||
b := uint32(33)
|
||||
c := uint32(44)
|
||||
d := uint32(55)
|
||||
si := uint32(0xBADDECAF)
|
||||
di := uint32(0xBAADA555)
|
||||
bp := uint32(0xDEADBEEF)
|
||||
|
||||
oa, ob, oc, od, osi, odi, obp := bdoor_inout_test(a, b, c, d, si, di, bp)
|
||||
|
||||
if !util.AssertEqual(t, a, oa) ||
|
||||
!util.AssertEqual(t, b, ob) ||
|
||||
!util.AssertEqual(t, c, oc) ||
|
||||
!util.AssertEqual(t, d, od) ||
|
||||
!util.AssertEqual(t, si, osi) ||
|
||||
!util.AssertEqual(t, di, odi) ||
|
||||
!util.AssertEqual(t, bp, obp) {
|
||||
return
|
||||
}
|
||||
}
|
||||
43
vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_amd64_test.go
generated
vendored
43
vendor/github.com/vmware/vmw-guestinfo/bdoor/bdoor_amd64_test.go
generated
vendored
@@ -1,43 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bdoor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
)
|
||||
|
||||
func TestBdoorArgAlignment(t *testing.T) {
|
||||
a := uint64(0xFFFFFFFF0000022)
|
||||
b := uint64(33)
|
||||
c := uint64(44)
|
||||
d := uint64(55)
|
||||
si := uint64(0xFFFFFFFF0000066)
|
||||
di := uint64(0xFFFAAFFF0000077)
|
||||
bp := uint64(0xFFFFFFFFAAAAAAA)
|
||||
|
||||
oa, ob, oc, od, osi, odi, obp := bdoor_inout_test(a, b, c, d, si, di, bp)
|
||||
|
||||
if !util.AssertEqual(t, a, oa) ||
|
||||
!util.AssertEqual(t, b, ob) ||
|
||||
!util.AssertEqual(t, c, oc) ||
|
||||
!util.AssertEqual(t, d, od) ||
|
||||
!util.AssertEqual(t, si, osi) ||
|
||||
!util.AssertEqual(t, di, odi) ||
|
||||
!util.AssertEqual(t, bp, obp) {
|
||||
return
|
||||
}
|
||||
}
|
||||
39
vendor/github.com/vmware/vmw-guestinfo/bdoor/word_386_test.go
generated
vendored
39
vendor/github.com/vmware/vmw-guestinfo/bdoor/word_386_test.go
generated
vendored
@@ -1,39 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bdoor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
)
|
||||
|
||||
func TestSetWord(t *testing.T) {
|
||||
inLow := uint16(0xEEFF)
|
||||
inHigh := uint16(0xBBBB)
|
||||
|
||||
out := &UInt32{}
|
||||
//out.SetWord(uint32(0xBBBBEEFF))
|
||||
out.Low = inLow
|
||||
out.High = inHigh
|
||||
|
||||
if !util.AssertEqual(t, inLow, out.Low) || !util.AssertEqual(t, inHigh, out.High) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, uint32(0xBBBBEEFF), out.Word()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
70
vendor/github.com/vmware/vmw-guestinfo/bdoor/word_amd64_test.go
generated
vendored
70
vendor/github.com/vmware/vmw-guestinfo/bdoor/word_amd64_test.go
generated
vendored
@@ -1,70 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package bdoor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
)
|
||||
|
||||
func TestSetWord(t *testing.T) {
|
||||
inLow := uint16(0xEEFF)
|
||||
inHigh := uint16(0xBBBB)
|
||||
|
||||
out := &UInt32{}
|
||||
//out.SetWord(uint32(0xBBBBEEFF))
|
||||
out.Low = inLow
|
||||
out.High = inHigh
|
||||
|
||||
if !util.AssertEqual(t, inLow, out.Low) || !util.AssertEqual(t, inHigh, out.High) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, uint32(0xBBBBEEFF), out.Word()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestQuadToHighLow(t *testing.T) {
|
||||
in := uint64(0xFFFFFFFF0000000A)
|
||||
|
||||
var u UInt64
|
||||
u.SetQuad(in)
|
||||
if !util.AssertEqual(t, uint32(in), u.Low.Word()) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, uint32(in>>32), u.High.Word()) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, in, u.Quad()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestHighLowToQuad(t *testing.T) {
|
||||
inHigh := uint16(0xff)
|
||||
inLow := uint16(0xaa)
|
||||
|
||||
u := UInt64{
|
||||
High: UInt32{High: inHigh},
|
||||
Low: UInt32{Low: inLow},
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, (uint64(inHigh)<<48)+uint64(inLow), u.Quad()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
75
vendor/github.com/vmware/vmw-guestinfo/examples/main.go
generated
vendored
75
vendor/github.com/vmware/vmw-guestinfo/examples/main.go
generated
vendored
@@ -1,75 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/rpcvmx"
|
||||
"github.com/vmware/vmw-guestinfo/vmcheck"
|
||||
)
|
||||
|
||||
var (
|
||||
set bool
|
||||
get bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
flag.BoolVar(&set, "set", false, "Sets the guestinfo.KEY with the string VALUE")
|
||||
flag.BoolVar(&get, "get", false, "Returns the config string in the guestinfo.* namespace")
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
isVM, err := vmcheck.IsVirtualWorld()
|
||||
if err != nil {
|
||||
log.Fatalf("Error: %s", err)
|
||||
}
|
||||
|
||||
if !isVM {
|
||||
log.Fatalf("ERROR: not in a virtual world.")
|
||||
}
|
||||
|
||||
if !set && !get {
|
||||
flag.Usage()
|
||||
}
|
||||
|
||||
config := rpcvmx.NewConfig()
|
||||
if set {
|
||||
if flag.NArg() != 2 {
|
||||
log.Fatalf("ERROR: Please provide guestinfo key / value pair (eg; -set foo bar")
|
||||
}
|
||||
if err := config.SetString(flag.Arg(0), flag.Arg(1)); err != nil {
|
||||
log.Fatalf("ERROR: SetString failed with %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if get {
|
||||
if flag.NArg() != 1 {
|
||||
log.Fatalf("ERROR: Please provide guestinfo key (eg; -get foo)")
|
||||
}
|
||||
if out, err := config.String(flag.Arg(0), ""); err != nil {
|
||||
log.Fatalf("ERROR: String failed with %s", err)
|
||||
} else {
|
||||
fmt.Printf("%s\n", out)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
130
vendor/github.com/vmware/vmw-guestinfo/message/message_test.go
generated
vendored
130
vendor/github.com/vmware/vmw-guestinfo/message/message_test.go
generated
vendored
@@ -1,130 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package message
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
"github.com/vmware/vmw-guestinfo/vmcheck"
|
||||
)
|
||||
|
||||
const rpciProtocolNum uint32 = 0x49435052
|
||||
const tcloProtocol uint32 = 0x4f4c4354
|
||||
|
||||
func TestOpenClose(t *testing.T) {
|
||||
l := DefaultLogger.(*logger)
|
||||
l.DebugLevel = true
|
||||
|
||||
isVm, err := vmcheck.IsVirtualWorld()
|
||||
if err != nil || !isVm {
|
||||
t.Skip("Not in a virtual world")
|
||||
return
|
||||
}
|
||||
|
||||
ch, err := NewChannel(rpciProtocolNum)
|
||||
if !util.AssertNotNil(t, ch) || !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
// check low bandwidth
|
||||
ch.forceLowBW = true
|
||||
err = ch.Send([]byte("info-get guestinfo.doesnotexistdoesnotexit"))
|
||||
if !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
b, err := ch.Receive()
|
||||
if !util.AssertNoError(t, err) || !util.AssertNotNil(t, b) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, "0 No value found", string(b)) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertNoError(t, ch.Close()) {
|
||||
return
|
||||
}
|
||||
|
||||
// check high bandwidth
|
||||
ch, err = NewChannel(rpciProtocolNum)
|
||||
if !util.AssertNotNil(t, ch) || !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = ch.Send([]byte("info-get guestinfo.doesnotexistdoesnotexit"))
|
||||
if !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
b, err = ch.Receive()
|
||||
if !util.AssertNoError(t, err) || !util.AssertNotNil(t, b) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertEqual(t, "0 No value found", string(b)) {
|
||||
return
|
||||
}
|
||||
|
||||
if !util.AssertNoError(t, ch.Close()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Test we can reply to the rpcin
|
||||
func TestReset(t *testing.T) {
|
||||
l := DefaultLogger.(*logger)
|
||||
l.DebugLevel = true
|
||||
|
||||
isVm, err := vmcheck.IsVirtualWorld()
|
||||
if err != nil || !isVm {
|
||||
t.Skip("Not in a virtual world")
|
||||
return
|
||||
}
|
||||
|
||||
if os.Getenv("TEST_TOOLBOX") == "" {
|
||||
t.Skip("Skipping toolbox test")
|
||||
return
|
||||
}
|
||||
|
||||
ch, err := NewChannel(tcloProtocol)
|
||||
if !util.AssertNotNil(t, ch) || !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer ch.Close()
|
||||
|
||||
var buf []byte
|
||||
|
||||
for {
|
||||
_ = ch.Send(buf)
|
||||
request, _ := ch.Receive()
|
||||
|
||||
if len(request) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if string(request) == "reset" {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
reply := "OK ATR toolbox"
|
||||
err = ch.Send([]byte(reply))
|
||||
if !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
58
vendor/github.com/vmware/vmw-guestinfo/util/util.go
generated
vendored
58
vendor/github.com/vmware/vmw-guestinfo/util/util.go
generated
vendored
@@ -1,58 +0,0 @@
|
||||
// Copyright 2016 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Test utilities.
|
||||
|
||||
func AssertEqual(t *testing.T, a interface{}, b interface{}) bool {
|
||||
if !reflect.DeepEqual(a, b) {
|
||||
Fail(t)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func AssertNoError(t *testing.T, err error) bool {
|
||||
if err != nil {
|
||||
t.Logf("error :%s", err.Error())
|
||||
Fail(t)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func AssertNotNil(t *testing.T, a interface{}) bool {
|
||||
val := reflect.ValueOf(a)
|
||||
if val.IsNil() {
|
||||
Fail(t)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func Fail(t *testing.T) {
|
||||
_, file, line, _ := runtime.Caller(2)
|
||||
t.Logf("FAIL on %s:%d", file, line)
|
||||
t.Fail()
|
||||
}
|
||||
37
vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_test.go
generated
vendored
37
vendor/github.com/vmware/vmw-guestinfo/vmcheck/vmcheck_test.go
generated
vendored
@@ -1,37 +0,0 @@
|
||||
// Copyright 2016-2017 VMware, Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package vmcheck
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/vmware/vmw-guestinfo/util"
|
||||
)
|
||||
|
||||
func TestIsVirtualWorld(t *testing.T) {
|
||||
isBackdoor, err := hypervisorPortCheck()
|
||||
if !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
t.Log("Backdoor available: ", isBackdoor)
|
||||
t.Log("CPU HV: ", IsVirtualCPU())
|
||||
|
||||
isVM, err := IsVirtualWorld()
|
||||
if !util.AssertNoError(t, err) {
|
||||
return
|
||||
}
|
||||
t.Log("Running in a VM: ", isVM)
|
||||
}
|
||||
Reference in New Issue
Block a user