mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 11:44:38 +00:00
govmm: Unite VirtioNet tests
no explicit PCI test, just switch path depending on architecture (CCW for s390x, PCI for others). Also fixes an unknown variable error. Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
parent
4a428fd1c5
commit
2f37165f46
@ -11,8 +11,8 @@ import "testing"
|
||||
|
||||
var (
|
||||
deviceFSString = "-device virtio-9p-pci,disable-modern=true,fsdev=workload9p,mount_tag=rootfs,romfile=efi-virtio.rom -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none,multidevs=remap"
|
||||
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
deviceSerialString = "-device virtio-serial-pci,disable-modern=true,id=serial0,romfile=efi-virtio.rom,max_ports=2"
|
||||
deviceVhostUserNetString = "-chardev socket,id=char1,path=/tmp/nonexistentsocket.socket -netdev type=vhost-user,id=net1,chardev=char1,vhostforce -device virtio-net-pci,netdev=net1,mac=00:11:22:33:44:55,romfile=efi-virtio.rom"
|
||||
deviceVSOCKString = "-device vhost-vsock-pci,disable-modern=true,id=vhost-vsock-pci0,guest-cid=4,romfile=efi-virtio.rom"
|
||||
|
@ -17,11 +17,6 @@ import (
|
||||
const agentUUID = "4cb19522-1e18-439a-883a-f9b2a3a95f5e"
|
||||
const volumeUUID = "67d86208-b46c-4465-9018-e14187d4010"
|
||||
|
||||
var (
|
||||
deviceNetworkPCIString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,romfile=efi-virtio.rom"
|
||||
deviceNetworkPCIStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-pci,netdev=tap0,mac=01:02:de:ad:be:ef,bus=/pci-bus/pcie.0,addr=ff,disable-modern=true,mq=on,vectors=6,romfile=efi-virtio.rom"
|
||||
)
|
||||
|
||||
const DevNo = "fe.1.1234"
|
||||
|
||||
func testAppend(structure interface{}, expected string, t *testing.T) {
|
||||
@ -177,10 +172,13 @@ func TestAppendDeviceNetwork(t *testing.T) {
|
||||
VHost: true,
|
||||
MACAddress: "01:02:de:ad:be:ef",
|
||||
DisableModern: true,
|
||||
ROMFile: "efi-virtio.rom",
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if netdev.Transport.isVirtioCCW(nil) {
|
||||
if netdev.Transport.isVirtioPCI(nil) {
|
||||
netdev.Bus = "/pci-bus/pcie.0"
|
||||
netdev.Addr = "255"
|
||||
} else if netdev.Transport.isVirtioCCW(nil) {
|
||||
netdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
@ -209,73 +207,19 @@ func TestAppendDeviceNetworkMq(t *testing.T) {
|
||||
VHost: true,
|
||||
MACAddress: "01:02:de:ad:be:ef",
|
||||
DisableModern: true,
|
||||
ROMFile: "efi-virtio.rom",
|
||||
ROMFile: romfile,
|
||||
}
|
||||
if netdev.Transport.isVirtioCCW(nil) {
|
||||
|
||||
if netdev.Transport.isVirtioPCI(nil) {
|
||||
netdev.Bus = "/pci-bus/pcie.0"
|
||||
netdev.Addr = "255"
|
||||
} else if netdev.Transport.isVirtioCCW(nil) {
|
||||
netdev.DevNo = DevNo
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkStringMq, t)
|
||||
}
|
||||
|
||||
func TestAppendDeviceNetworkPCI(t *testing.T) {
|
||||
|
||||
netdev := NetDevice{
|
||||
Driver: VirtioNet,
|
||||
Type: TAP,
|
||||
ID: "tap0",
|
||||
IFName: "ceth0",
|
||||
Bus: "/pci-bus/pcie.0",
|
||||
Addr: "255",
|
||||
Script: "no",
|
||||
DownScript: "no",
|
||||
VHost: true,
|
||||
MACAddress: "01:02:de:ad:be:ef",
|
||||
DisableModern: true,
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if !netdev.Transport.isVirtioPCI(nil) {
|
||||
t.Skip("Test valid only for PCI devices")
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkPCIString, t)
|
||||
}
|
||||
|
||||
func TestAppendDeviceNetworkPCIMq(t *testing.T) {
|
||||
foo, _ := ioutil.TempFile(os.TempDir(), "govmm-qemu-test")
|
||||
bar, _ := ioutil.TempFile(os.TempDir(), "govmm-qemu-test")
|
||||
|
||||
defer func() {
|
||||
_ = foo.Close()
|
||||
_ = bar.Close()
|
||||
_ = os.Remove(foo.Name())
|
||||
_ = os.Remove(bar.Name())
|
||||
}()
|
||||
|
||||
netdev := NetDevice{
|
||||
Driver: VirtioNet,
|
||||
Type: TAP,
|
||||
ID: "tap0",
|
||||
IFName: "ceth0",
|
||||
Bus: "/pci-bus/pcie.0",
|
||||
Addr: "255",
|
||||
Script: "no",
|
||||
DownScript: "no",
|
||||
FDs: []*os.File{foo, bar},
|
||||
VHost: true,
|
||||
MACAddress: "01:02:de:ad:be:ef",
|
||||
DisableModern: true,
|
||||
ROMFile: romfile,
|
||||
}
|
||||
|
||||
if !netdev.Transport.isVirtioPCI(nil) {
|
||||
t.Skip("Test valid only for PCI devices")
|
||||
}
|
||||
|
||||
testAppend(netdev, deviceNetworkPCIStringMq, t)
|
||||
}
|
||||
|
||||
var deviceLegacySerialString = "-serial chardev:tlserial0"
|
||||
|
||||
func TestAppendLegacySerial(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user