firmware: validation & tests

This commit is contained in:
Michael Kuzmin 2018-10-17 02:15:27 +03:00
parent 0b5e6d1046
commit 9358f4e91a
3 changed files with 17 additions and 4 deletions

View File

@ -81,11 +81,13 @@ func (d *Driver) CreateVM(config *CreateConfig) (*VirtualMachine, error) {
Name: config.Name,
Annotation: config.Annotation,
GuestId: config.GuestOS,
Firmware: config.Firmware,
}
if config.Version != 0 {
createSpec.Version = fmt.Sprintf("%s%d", "vmx-", config.Version)
}
if config.Firmware != "" {
createSpec.Firmware = config.Firmware
}
folder, err := d.FindFolder(config.Folder)
if err != nil {

View File

@ -45,7 +45,7 @@ func checkDefault(t *testing.T, name string, host string, datastore string) buil
d := commonT.TestConn(t)
vm := commonT.GetVM(t, d, artifacts)
vmInfo, err := vm.Info("name", "parent", "runtime.host", "resourcePool", "datastore", "layoutEx.disk")
vmInfo, err := vm.Info("name", "parent", "runtime.host", "resourcePool", "datastore", "layoutEx.disk", "config.firmware")
if err != nil {
t.Fatalf("Cannot read VM properties: %v", err)
}
@ -91,6 +91,11 @@ func checkDefault(t *testing.T, name string, host string, datastore string) buil
t.Errorf("Invalid datastore name: expected '%v', got '%v'", datastore, dsInfo.Name)
}
fw := vmInfo.Config.Firmware
if fw != "bios" {
t.Errorf("Invalid firmware: expected 'bios', got '%v'", fw)
}
return nil
}
}
@ -111,6 +116,7 @@ func hardwareConfig() string {
config["RAM"] = 2048
config["RAM_reservation"] = 1024
config["NestedHV"] = true
config["firmware"] = "efi"
return commonT.RenderConfig(config)
}
@ -155,6 +161,11 @@ func checkHardware(t *testing.T) builderT.TestCheckFunc {
t.Errorf("VM should have NestedHV enabled, got %v", nestedHV)
}
fw := vmInfo.Config.Firmware
if fw != "efi" {
t.Errorf("Invalid firmware: expected 'efi', got '%v'", fw)
}
return nil
}
}

View File

@ -34,8 +34,8 @@ func (c *CreateConfig) Prepare() []error {
c.GuestOSType = "otherGuest"
}
if (c.Firmware == "") {
c.Firmware = "bios"
if (c.Firmware != "" && c.Firmware != "bios" && c.Firmware != "efi") {
errs = append(errs, fmt.Errorf("'firmware' must be 'bios' or 'efi'"))
}
return errs