2015-04-27 10:53:12 -04:00
|
|
|
// +build linux
|
|
|
|
|
2014-04-30 08:43:51 -04:00
|
|
|
package btrfs
|
|
|
|
|
|
|
|
import (
|
2015-12-15 15:16:06 -05:00
|
|
|
"os"
|
|
|
|
"path"
|
2014-04-30 08:43:51 -04:00
|
|
|
"testing"
|
2015-08-24 19:18:01 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/graphdriver/graphtest"
|
2014-04-30 08:43:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// This avoids creating a new driver for each test if all tests are run
|
|
|
|
// Make sure to put new tests between TestBtrfsSetup and TestBtrfsTeardown
|
|
|
|
func TestBtrfsSetup(t *testing.T) {
|
|
|
|
graphtest.GetDriver(t, "btrfs")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBtrfsCreateEmpty(t *testing.T) {
|
|
|
|
graphtest.DriverTestCreateEmpty(t, "btrfs")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBtrfsCreateBase(t *testing.T) {
|
|
|
|
graphtest.DriverTestCreateBase(t, "btrfs")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBtrfsCreateSnap(t *testing.T) {
|
|
|
|
graphtest.DriverTestCreateSnap(t, "btrfs")
|
|
|
|
}
|
|
|
|
|
2015-12-15 15:16:06 -05:00
|
|
|
func TestBtrfsSubvolDelete(t *testing.T) {
|
|
|
|
d := graphtest.GetDriver(t, "btrfs")
|
2016-11-09 15:59:58 -05:00
|
|
|
if err := d.CreateReadWrite("test", "", nil); err != nil {
|
2015-12-15 15:16:06 -05:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer graphtest.PutDriver(t)
|
|
|
|
|
2017-08-03 20:22:00 -04:00
|
|
|
dirFS, err := d.Get("test", "")
|
2015-12-15 15:16:06 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer d.Put("test")
|
|
|
|
|
2017-08-03 20:22:00 -04:00
|
|
|
dir := dirFS.Path()
|
|
|
|
|
2015-12-15 15:16:06 -05:00
|
|
|
if err := subvolCreate(dir, "subvoltest"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(path.Join(dir, "subvoltest")); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := d.Remove("test"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(path.Join(dir, "subvoltest")); !os.IsNotExist(err) {
|
|
|
|
t.Fatalf("expected not exist error on nested subvol, got: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-30 08:43:51 -04:00
|
|
|
func TestBtrfsTeardown(t *testing.T) {
|
|
|
|
graphtest.PutDriver(t)
|
|
|
|
}
|