Explorar o código

devicemapper: Fix tests on fedora

If /dev/loop-control exists on the system running the test then
ioctlLoopCtlGetFree() will be called, but if not it won't.  It does
not exist in the standard docker build environment, so the tests
currently require this to not be called. This makes it instead
optional, allowing the tests to run on e.g. Fedora.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Alexander Larsson %!s(int64=11) %!d(string=hai) anos
pai
achega
eb4578daee
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      graphdriver/devmapper/driver_test.go

+ 8 - 1
graphdriver/devmapper/driver_test.go

@@ -136,7 +136,12 @@ type Set map[string]bool
 
 func (r Set) Assert(t *testing.T, names ...string) {
 	for _, key := range names {
-		if _, exists := r[key]; !exists {
+		required := true
+		if strings.HasPrefix(key, "?") {
+			key = key[1:]
+			required = false
+		}
+		if _, exists := r[key]; !exists && required {
 			t.Fatalf("Key not set: %s", key)
 		}
 		delete(r, key)
@@ -486,6 +491,7 @@ func TestDriverCreate(t *testing.T) {
 			"ioctl.blkgetsize",
 			"ioctl.loopsetfd",
 			"ioctl.loopsetstatus",
+			"?ioctl.loopctlgetfree",
 		)
 
 		if err := d.Create("1", ""); err != nil {
@@ -603,6 +609,7 @@ func TestDriverRemove(t *testing.T) {
 			"ioctl.blkgetsize",
 			"ioctl.loopsetfd",
 			"ioctl.loopsetstatus",
+			"?ioctl.loopctlgetfree",
 		)
 
 		if err := d.Create("1", ""); err != nil {