mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 07:22:20 +00:00
qemu: Add parameters adding unit tests
We only test the Machine parameters for now. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
ebfa382d2e
commit
54d32c2414
58
qemu_test.go
Normal file
58
qemu_test.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
// Copyright (c) 2016 Intel Corporation
|
||||||
|
//
|
||||||
|
// 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 qemu
|
||||||
|
|
||||||
|
import (
|
||||||
|
// "fmt"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func testAppend(structure interface{}, expected string, t *testing.T) {
|
||||||
|
var params []string
|
||||||
|
|
||||||
|
switch s := structure.(type) {
|
||||||
|
case Machine:
|
||||||
|
config := Config{
|
||||||
|
Machine: s,
|
||||||
|
}
|
||||||
|
|
||||||
|
params = appendMachine([]string{}, config)
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.Join(params, " ")
|
||||||
|
if result != expected {
|
||||||
|
t.Fatalf("Failed to append Machine [%s] != [%s]", result, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var machineString = "-machine pc-lite,accel=kvm,kernel_irqchip,nvdimm"
|
||||||
|
|
||||||
|
func TestAppendMachine(t *testing.T) {
|
||||||
|
machine := Machine{
|
||||||
|
Type: "pc-lite",
|
||||||
|
Acceleration: "kvm,kernel_irqchip,nvdimm",
|
||||||
|
}
|
||||||
|
|
||||||
|
testAppend(machine, machineString, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAppendEmptyMachine(t *testing.T) {
|
||||||
|
machine := Machine{}
|
||||||
|
|
||||||
|
testAppend(machine, "", t)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user