Merge pull request #5539 from alakesh/btrfs-test

Do not run btrfs tests if btrfs kernel module is not loaded
This commit is contained in:
Derek McGowan 2021-05-26 20:30:31 -07:00 committed by GitHub
commit 925ff5a21b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@
package btrfs package btrfs
import ( import (
"bytes"
"context" "context"
"io/ioutil" "io/ioutil"
"os" "os"
@ -44,7 +45,10 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap
t.Skipf("could not find mkfs.btrfs: %v", err) t.Skipf("could not find mkfs.btrfs: %v", err)
} }
// TODO: Check for btrfs in /proc/module and skip if not loaded procModules, err := ioutil.ReadFile("/proc/modules")
if err == nil && !bytes.Contains(procModules, []byte("btrfs")) {
t.Skip("check for btrfs kernel module failed, skipping test")
}
return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {