Skip to content

Commit

Permalink
virtcontainers: Add to bridges unit test
Browse files Browse the repository at this point in the history
Add function that creates new bridges to increase unit test coverage
for virtcontainers/types/bridges.

Fixes kata-containers#2827

Signed-off-by: Chelsea Mafrica <[email protected]>
  • Loading branch information
Chelsea Mafrica committed Jul 13, 2020
1 parent a885b1b commit 50a4015
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions virtcontainers/types/bridges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,40 @@ func testAddRemoveDevice(t *testing.T, b *Bridge) {
}
}

func TestAddressFormat(t *testing.T) {
assert := assert.New(t)

var ccwbridge = NewBridge(CCW, "", make(map[uint32]string), 0)
_, err := ccwbridge.AddressFormatCCW("0")
assert.NoError(err)
_, err = ccwbridge.AddressFormatCCWForVirtServer("0")
assert.NoError(err)

var pcibridge = NewBridge(PCI, "", make(map[uint32]string), 0)
_, err = pcibridge.AddressFormatCCW("0")
assert.Error(err)
_, err = pcibridge.AddressFormatCCWForVirtServer("0")
assert.Error(err)

}

func TestNewBridge(t *testing.T) {
assert := assert.New(t)

var pci Type = "pci"
var pcie Type = "pcie"
var ccw Type = "ccw"

var pcibridge = NewBridge(PCI, "", make(map[uint32]string), 0)
assert.Equal(pcibridge.Type, pci, "Type should be PCI")

var pciebridge = NewBridge(PCIE, "", make(map[uint32]string), 0)
assert.Equal(pciebridge.Type, pcie, "Type should be PCIE")

var ccwbridge = NewBridge(CCW, "", make(map[uint32]string), 0)
assert.Equal(ccwbridge.Type, ccw, "Type should be CCW")
}

func TestAddRemoveDevicePCI(t *testing.T) {

// create a pci bridge
Expand Down

0 comments on commit 50a4015

Please sign in to comment.