forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
/
qemu_s390x_test.go
67 lines (54 loc) · 1.44 KB
/
qemu_s390x_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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)
}