2015-04-08 03:28:04 +00:00
|
|
|
#!/bin/sh -x
|
|
|
|
|
|
|
|
expect_failure() {
|
2016-06-30 08:05:57 +00:00
|
|
|
if "$@"; then return 1; else return 0; fi
|
2015-04-08 03:28:04 +00:00
|
|
|
}
|
|
|
|
set -e
|
|
|
|
|
|
|
|
mkdir -p d1/d2
|
|
|
|
mkdir -p d1/d3
|
|
|
|
mkdir d1/.snap/foo
|
|
|
|
mkdir d1/d2/.snap/foo
|
|
|
|
mkdir d1/d3/.snap/foo
|
|
|
|
mkdir d1/d3/.snap/bar
|
|
|
|
mv d1/d2/.snap/foo d1/d2/.snap/bar
|
|
|
|
# snapshot name can't start with _
|
|
|
|
expect_failure mv d1/d2/.snap/bar d1/d2/.snap/_bar
|
|
|
|
# can't rename parent snapshot
|
|
|
|
expect_failure mv d1/d2/.snap/_foo_* d1/d2/.snap/foo
|
|
|
|
expect_failure mv d1/d2/.snap/_foo_* d1/d2/.snap/_foo_1
|
|
|
|
# can't rename snapshot to different directroy
|
|
|
|
expect_failure mv d1/d2/.snap/bar d1/.snap/
|
|
|
|
# can't overwrite existing snapshot
|
2019-12-19 18:38:03 +00:00
|
|
|
expect_failure python3 -c "import os; os.rename('d1/d3/.snap/foo', 'd1/d3/.snap/bar')"
|
2015-04-08 03:28:04 +00:00
|
|
|
# can't move snaphost out of snapdir
|
2019-12-19 18:38:03 +00:00
|
|
|
expect_failure python3 -c "import os; os.rename('d1/.snap/foo', 'd1/foo')"
|
2015-04-08 03:28:04 +00:00
|
|
|
|
|
|
|
rmdir d1/.snap/foo
|
|
|
|
rmdir d1/d2/.snap/bar
|
|
|
|
rmdir d1/d3/.snap/foo
|
|
|
|
rmdir d1/d3/.snap/bar
|
|
|
|
rm -rf d1
|
|
|
|
|
|
|
|
echo OK
|