Files
kata-containers/virtcontainers/qemu_s390x_test.go
Alice Frosi 8ba27e14a1 s390x: remove pmu from test
Remove pmu option because it is not used and the test TestQemuS390xCPUModel
fails because the option is present

Fixes: #1329

Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2019-03-06 17:02:15 +01:00

68 lines
1.4 KiB
Go

// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package virtcontainers
import (
"fmt"
"testing"
govmmQemu "github.com/intel/govmm/qemu"
"github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/stretchr/testify/assert"
)
func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{
HypervisorMachineType: machineType,
}
return newQemuArch(config)
}
func TestQemuS390xCPUModel(t *testing.T) {
assert := assert.New(t)
s390x := newTestQemu(QemuCCWVirtio)
expectedOut := defaultCPUModel
model := s390x.cpuModel()
assert.Equal(expectedOut, model)
s390x.enableNestingChecks()
expectedOut = defaultCPUModel
model = s390x.cpuModel()
assert.Equal(expectedOut, model)
}
func TestQemuS390xMemoryTopology(t *testing.T) {
assert := assert.New(t)
s390x := newTestQemu(QemuCCWVirtio)
hostMem := uint64(1024)
mem := uint64(120)
slots := uint8(10)
expectedMemory := govmmQemu.Memory{
Size: fmt.Sprintf("%dM", mem),
Slots: slots,
MaxMem: fmt.Sprintf("%dM", hostMem),
}
m := s390x.memoryTopology(mem, hostMem, slots)
assert.Equal(expectedMemory, m)
}
func TestQemuS390xAppendVhostUserDevice(t *testing.T) {
macAddress := "00:11:22:33:44:55:66"
qemu := qemuS390x{}
assert := assert.New(t)
vhostUserDevice := config.VhostUserDeviceAttrs{
Type: config.VhostUserNet,
MacAddress: macAddress,
}
_, err := qemu.appendVhostUserDevice(nil, vhostUserDevice)
assert.Error(err)
}