mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-19 07:14:22 +01:00
We only test the Machine parameters for now. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
/*
|
|
// 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)
|
|
}
|