summaryrefslogtreecommitdiff
path: root/tests/root_test/root_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/root_test/root_test.go')
-rw-r--r--tests/root_test/root_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/root_test/root_test.go b/tests/root_test/root_test.go
index 8547e4e..e68f86a 100644
--- a/tests/root_test/root_test.go
+++ b/tests/root_test/root_test.go
@@ -12,6 +12,8 @@ import (
"syscall"
"testing"
+ "github.com/rfjakob/gocryptfs/internal/syscallcompat"
+
"golang.org/x/sys/unix"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
@@ -311,3 +313,50 @@ func TestAcl(t *testing.T) {
dumpAcl()
}
}
+
+// TestBtrfsQuirks needs root permissions because it creates a loop disk
+func TestBtrfsQuirks(t *testing.T) {
+ if os.Getuid() != 0 {
+ t.Skip("must run as root")
+ }
+
+ img := filepath.Join(test_helpers.TmpDir, t.Name()+".img")
+ f, err := os.Create(img)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ // minimum size for each btrfs device is 114294784
+ err = f.Truncate(200 * 1024 * 1024)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // Format as Btrfs
+ cmd := exec.Command("mkfs.btrfs", img)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Log(string(out))
+ t.Fatal(err)
+ }
+
+ // Mount
+ mnt := img + ".mnt"
+ err = os.Mkdir(mnt, 0600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cmd = exec.Command("mount", img, mnt)
+ out, err = cmd.CombinedOutput()
+ if err != nil {
+ t.Log(string(out))
+ t.Fatal(err)
+ }
+ defer syscall.Unlink(img)
+ defer syscall.Unmount(mnt, 0)
+
+ quirk := syscallcompat.DetectQuirks(mnt)
+ if quirk != syscallcompat.QuirkBrokenFalloc {
+ t.Errorf("wrong quirk: %v", quirk)
+ }
+}