Commit e59e9ced authored by Vincent Bernat's avatar Vincent Bernat

test: ensure we don't have any connection leak

If ConnectionClose() method doesn't return 0, this means we have either
an error, either there is still a reference to the connection by another
object (we don't have virConnectRef()). In all tests, check that return
code and ensure this is 0. Fix tests that weren't releasing all objects
correctly.
parent b3caa922
......@@ -10,7 +10,9 @@ func TestDomainListAllInterfaceAddresses(t *testing.T) {
dom, conn := buildTestQEMUDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......
......@@ -54,7 +54,9 @@ func TestUndefineDomain(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
name, err := dom.GetName()
if err != nil {
......@@ -76,7 +78,9 @@ func TestGetDomainName(t *testing.T) {
defer func() {
dom.Undefine()
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := dom.GetName(); err != nil {
t.Error(err)
......@@ -88,7 +92,9 @@ func TestGetDomainState(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
state, err := dom.GetState()
if err != nil {
......@@ -109,7 +115,9 @@ func TestGetDomainID(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
......@@ -128,7 +136,9 @@ func TestGetDomainUUID(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := dom.GetUUID()
// how to test uuid validity?
......@@ -142,7 +152,9 @@ func TestGetDomainUUIDString(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := dom.GetUUIDString()
if err != nil {
......@@ -155,7 +167,9 @@ func TestGetDomainInfo(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := dom.GetInfo()
if err != nil {
......@@ -168,7 +182,9 @@ func TestGetDomainXMLDesc(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := dom.GetXMLDesc(0)
if err != nil {
......@@ -181,7 +197,9 @@ func TestCreateDomainSnapshotXML(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
ss, err := dom.CreateSnapshotXML(`
<domainsnapshot>
......@@ -199,7 +217,9 @@ func TestSaveDomain(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
// get the name so we can get a handle on it later
domName, err := dom.GetName()
......@@ -216,9 +236,11 @@ func TestSaveDomain(t *testing.T) {
t.Error(err)
return
}
if _, err = conn.LookupDomainByName(domName); err != nil {
if dom2, err := conn.LookupDomainByName(domName); err != nil {
t.Error(err)
return
} else {
dom2.Free()
}
}
......@@ -226,7 +248,9 @@ func TestSaveDomainFlags(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
const srcFile = "/tmp/libvirt-go-test.tmp"
if err := dom.SaveFlags(srcFile, "", 0); err == nil {
......@@ -239,7 +263,9 @@ func TestCreateDestroyDomain(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -271,7 +297,12 @@ func TestCreateDestroyDomain(t *testing.T) {
func TestShutdownDomain(t *testing.T) {
dom, conn := buildTestDomain()
defer conn.CloseConnection()
defer func() {
dom.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
return
......@@ -295,7 +326,9 @@ func TestShutdownReboot(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Reboot(0); err != nil {
t.Error(err)
......@@ -307,7 +340,9 @@ func TestDomainAutostart(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
as, err := dom.GetAutostart()
if err != nil {
......@@ -337,7 +372,9 @@ func TestDomainIsActive(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Log(err)
......@@ -372,9 +409,13 @@ func TestDomainIsPersistent(t *testing.T) {
dom2, conn2 := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
dom2.Free()
conn2.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
if res, _ := conn2.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
persistent, err := dom.IsPersistent()
if err != nil {
......@@ -401,7 +442,9 @@ func TestDomainSetMaxMemory(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.SetMaxMemory(mem); err != nil {
t.Error(err)
......@@ -413,7 +456,9 @@ func TestDomainSetMemory(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -429,7 +474,9 @@ func TestDomainSetVcpus(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -447,7 +494,11 @@ func TestDomainSetVcpus(t *testing.T) {
func TestDomainFree(t *testing.T) {
dom, conn := buildTestDomain()
defer conn.CloseConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Free(); err != nil {
t.Error(err)
return
......@@ -458,7 +509,9 @@ func TestDomainSuspend(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -474,7 +527,11 @@ func TestDomainSuspend(t *testing.T) {
func TesDomainShutdownFlags(t *testing.T) {
dom, conn := buildTestDomain()
defer conn.CloseConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
return
......@@ -496,7 +553,11 @@ func TesDomainShutdownFlags(t *testing.T) {
func TesDomainDestoryFlags(t *testing.T) {
dom, conn := buildTestDomain()
defer conn.CloseConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
return
......@@ -520,7 +581,9 @@ func TestDomainScreenshot(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -544,7 +607,9 @@ func TestDomainGetVcpus(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -570,7 +635,9 @@ func TestDomainGetVcpusFlags(t *testing.T) {
dom, conn := buildTestDomain()
defer func() {
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
t.Error(err)
......@@ -594,7 +661,9 @@ func TestQemuMonitorCommand(t *testing.T) {
dom.Destroy()
dom.Undefine()
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.Create(); err != nil {
......@@ -616,9 +685,12 @@ func TestQemuMonitorCommand(t *testing.T) {
func TestDomainCreateWithFlags(t *testing.T) {
dom, conn := buildTestQEMUDomain()
defer func() {
dom.Destroy()
dom.Undefine()
dom.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := dom.CreateWithFlags(VIR_DOMAIN_START_PAUSED); err != nil {
......
......@@ -35,7 +35,14 @@ func TestConnectionErrorCallback(t *testing.T) {
errors = append(errors, err)
f()
})
conn := buildTestConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
conn.SetErrorFunc(callback, func() {
nbErrors++
})
......@@ -46,6 +53,7 @@ func TestConnectionErrorCallback(t *testing.T) {
if err != nil {
panic(err)
}
defer domain.Free()
err = domain.SetMemory(100000000000)
if err == nil {
t.Fatalf("Was expecting an error when setting memory to too high value")
......
......@@ -17,7 +17,9 @@ func TestDomainEventRegister(t *testing.T) {
t.Errorf("got %d on DomainEventDeregister instead of 0", ret)
}
}
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
nodom := VirDomain{}
......
This diff is collapsed.
......@@ -26,8 +26,12 @@ func generateRandomMac() string {
func TestCreateDestroyInterface(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer iface.Free()
defer conn.CloseConnection()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := iface.Create(0); err != nil {
t.Error(err)
return
......@@ -39,8 +43,12 @@ func TestCreateDestroyInterface(t *testing.T) {
func TestUndefineInterface(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer iface.Free()
defer conn.CloseConnection()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
name, err := iface.GetName()
if err != nil {
t.Error(err)
......@@ -57,8 +65,12 @@ func TestUndefineInterface(t *testing.T) {
func TestGetInterfaceName(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer iface.Free()
defer conn.CloseConnection()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := iface.GetName(); err != nil {
t.Fatal(err)
}
......@@ -66,8 +78,12 @@ func TestGetInterfaceName(t *testing.T) {
func TestInterfaceIsActive(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer iface.Free()
defer conn.CloseConnection()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := iface.Create(0); err != nil {
t.Log(err)
return
......@@ -97,8 +113,12 @@ func TestInterfaceIsActive(t *testing.T) {
func TestGetMACString(t *testing.T) {
origMac := generateRandomMac()
iface, conn := buildTestInterface(origMac)
defer iface.Free()
defer conn.CloseConnection()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
mac, err := iface.GetMACString()
if err != nil {
t.Error(err)
......@@ -111,8 +131,12 @@ func TestGetMACString(t *testing.T) {
func TestGetInterfaceXMLDesc(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer conn.CloseConnection()
defer iface.Free()
defer func() {
iface.Free()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := iface.GetXMLDesc(0); err != nil {
t.Error(err)
}
......@@ -120,7 +144,11 @@ func TestGetInterfaceXMLDesc(t *testing.T) {
func TestInterfaceFree(t *testing.T) {
iface, conn := buildTestInterface(generateRandomMac())
defer conn.CloseConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := iface.Free(); err != nil {
t.Error(err)
return
......
This diff is collapsed.
......@@ -36,7 +36,9 @@ func TestGetNetworkName(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := net.GetName(); err != nil {
t.Fatal(err)
......@@ -48,7 +50,9 @@ func TestGetNetworkUUID(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := net.GetUUID()
if err != nil {
......@@ -61,7 +65,9 @@ func TestGetNetworkUUIDString(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
_, err := net.GetUUIDString()
if err != nil {
......@@ -74,7 +80,9 @@ func TestGetNetworkXMLDesc(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := net.GetXMLDesc(0); err != nil {
t.Error(err)
......@@ -86,7 +94,9 @@ func TestCreateDestroyNetwork(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := net.Create(); err != nil {
t.Error(err)
......@@ -103,7 +113,9 @@ func TestNetworkAutostart(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
as, err := net.GetAutostart()
if err != nil {
......@@ -133,7 +145,9 @@ func TestNetworkIsActive(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := net.Create(); err != nil {
t.Log(err)
......@@ -167,7 +181,9 @@ func TestNetworkGetBridgeName(t *testing.T) {
net, conn := buildTestNetwork("")
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := net.Create(); err != nil {
t.Error(err)
......@@ -182,7 +198,11 @@ func TestNetworkGetBridgeName(t *testing.T) {
func TestNetworkFree(t *testing.T) {
net, conn := buildTestNetwork("")
defer conn.CloseConnection()
defer func() {
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := net.Free(); err != nil {
t.Error(err)
return
......@@ -198,7 +218,9 @@ func TestNetworkCreateXML(t *testing.T) {
}
defer func() {
net.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if is_active, err := net.IsActive(); err != nil {
......
......@@ -30,7 +30,9 @@ func TestStoragePoolBuild(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Build(VIR_STORAGE_POOL_BUILD_NEW); err != nil {
t.Fatal(err)
......@@ -41,7 +43,9 @@ func TestUndefineStoragePool(t *testing.T) {
pool, conn := buildTestStoragePool("")
defer func() {
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
name, err := pool.GetName()
if err != nil {
......@@ -63,7 +67,9 @@ func TestGetStoragePoolName(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := pool.GetName(); err != nil {
t.Error(err)
......@@ -75,7 +81,9 @@ func TestGetStoragePoolUUID(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := pool.GetUUID(); err != nil {
t.Error(err)
......@@ -87,7 +95,9 @@ func TestGetStoragePoolUUIDString(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := pool.GetUUIDString(); err != nil {
t.Error(err)
......@@ -99,7 +109,9 @@ func TestGetStoragePoolInfo(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := pool.GetInfo(); err != nil {
t.Error(err)
......@@ -111,7 +123,9 @@ func TestGetStoragePoolXMLDesc(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if _, err := pool.GetXMLDesc(0); err != nil {
t.Error(err)
......@@ -124,7 +138,9 @@ func TestStoragePoolRefresh(t *testing.T) {
pool.Destroy()
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
t.Error(err)
......@@ -140,7 +156,9 @@ func TestCreateDestroyStoragePool(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
t.Error(err)
......@@ -174,7 +192,9 @@ func TestStoragePoolAutostart(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
as, err := pool.GetAutostart()
if err != nil {
......@@ -203,7 +223,9 @@ func TestStoragePoolIsActive(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
......@@ -237,7 +259,9 @@ func TestStorageVolCreateDelete(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
t.Error(err)
......@@ -259,7 +283,9 @@ func TestStorageVolCreateFromDelete(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
t.Error(err)
......@@ -296,7 +322,9 @@ func TestLookupStorageVolByName(t *testing.T) {
defer func() {
pool.Undefine()
pool.Free()
conn.CloseConnection()
if res, _ := conn.CloseConnection(); res != 0 {
t.Errorf("CloseConnection() == %d, expected 0", res)
}
}()
if err := pool.Create(0); err != nil {
t.Error(err)
......@@ -313,12 +341,13 @@ func TestLookupStorageVolByName(t *testing.T) {
vol.Delete(VIR_STORAGE_VOL_DELETE_NORMAL)
vol.Free()
}()
vol, err = pool.LookupStorageVolByName(defVolName)
vol2, err := pool.LookupStorageVolByName(defVolName)
if err != nil {