Skip to content

Commit

Permalink
fixup! tests: Add basic e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
cfergeau committed Oct 10, 2023
1 parent 6c23e62 commit 5c4bad2
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions test/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ var pciidTests = map[string]pciidTest{
return config.VirtioFsNew("./", "vfkit-share-test")
},
},
}

var pciidMacOS13Tests = map[string]pciidTest{
"virtio-gpu": {
vendorID: 0x1af4, // Red Hat
deviceID: 0x1050,
Expand All @@ -225,6 +228,22 @@ var pciidTests = map[string]pciidTest{
},
}

func testPCIId(t *testing.T, test pciidTest, provider OsProvider) {
vm := NewTestVM(t, provider)
defer vm.Close(t)
require.NotNil(t, vm)

vm.AddSSH(t, "tcp")
dev, err := test.createDev(t)
require.NoError(t, err)
vm.AddDevice(t, dev)

vm.Start(t)
vm.WaitForSSH(t)
checkPCIDevice(t, vm, test.vendorID, test.deviceID)
vm.Stop(t)
}

func TestPCIIds(t *testing.T) {
puipuiProvider := NewPuipuiProvider()
log.Info("fetching os image")
Expand All @@ -234,19 +253,13 @@ func TestPCIIds(t *testing.T) {

for name, test := range pciidTests {
t.Run(name, func(t *testing.T) {
vm := NewTestVM(t, puipuiProvider)
defer vm.Close(t)
require.NotNil(t, vm)

vm.AddSSH(t, "tcp")
dev, err := test.createDev(t)
require.NoError(t, err)
vm.AddDevice(t, dev)
testPCIId(t, test, puipuiProvider)
})
}

vm.Start(t)
vm.WaitForSSH(t)
checkPCIDevice(t, vm, test.vendorID, test.deviceID)
vm.Stop(t)
for name, test := range pciidMacOS13Tests {
t.Run(name, func(t *testing.T) {
testPCIId(t, test, puipuiProvider)
})
}
}
Expand Down

0 comments on commit 5c4bad2

Please sign in to comment.