Merge pull request #865 from nitkon/kata-env

ppc64le: kata-env fails due to missing vendor field
This commit is contained in:
James O. D. Hunt
2018-11-28 09:22:47 +00:00
committed by GitHub
8 changed files with 82 additions and 41 deletions

View File

@@ -7,6 +7,7 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path"
@@ -483,8 +484,36 @@ func TestKvmIsUsable(t *testing.T) {
assert.Error(err)
}
type TestDataa struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}
func TestGetCPUDetails(t *testing.T) {
genericTestGetCPUDetails(t)
const validVendorName = "a vendor"
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)
const validModelName = "some CPU model"
validModel := fmt.Sprintf(`%s : %s`, archCPUModelField, validModelName)
validContents := fmt.Sprintf(`
a : b
%s
foo : bar
%s
`, validVendor, validModel)
data := []TestDataa{
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
{validVendor, "", "", true},
{validModel, "", "", true},
{validContents, validVendorName, validModelName, false},
}
genericTestGetCPUDetails(t, validVendor, validModel, validContents, data)
}
func TestSetCPUtype(t *testing.T) {