aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2014-06-25 20:09:16 +0100
committerDavid Howells <dhowells@redhat.com>2014-06-25 21:32:26 +0100
commit40244ad3fe73f245d96582c78744a77886bde467 (patch)
tree9a9ae08b23718b6d804eb3fbe67c557a3042798e
parent84beff095b6b3b8953be22bece20d4c8010e9755 (diff)
Hardlinking symlink test
-rwxr-xr-xrun1
-rw-r--r--tests/hard-link-sym.py112
2 files changed, 113 insertions, 0 deletions
diff --git a/run b/run
index 640e16c..a08bb28 100755
--- a/run
+++ b/run
@@ -164,6 +164,7 @@ tests = [
"rmdir",
"hard-link",
"hard-link-dir",
+ "hard-link-sym",
"unlink",
"rename-file",
"rename-empty-dir",
diff --git a/tests/hard-link-sym.py b/tests/hard-link-sym.py
new file mode 100644
index 0000000..59fb3b6
--- /dev/null
+++ b/tests/hard-link-sym.py
@@ -0,0 +1,112 @@
+from errno import *
+
+###############################################################################
+#
+# Try to hardlink symlinks
+#
+###############################################################################
+
+# Hard link a symlink
+def subtest_1(ctx):
+ """Hard link symlink"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.no_file() + ctx.termslash()
+
+ ctx.link(f, f2)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f2, ro=1, read=":xxx:yyy:zzz")
+
+# Hard link a dangling symlink
+def subtest_2(ctx):
+ """Hard link dangling symlink"""
+ f = ctx.pointless() + ctx.termslash()
+ f2 = ctx.no_file() + ctx.termslash()
+
+ ctx.link(f, f2)
+ ctx.open_file(f, ro=1, err=ELOOP)
+ ctx.open_file(f2, ro=1, err=ELOOP)
+
+# Hard link a non-existent file over a symlink
+def subtest_3(ctx):
+ """Hard link non-existent file over a symlink"""
+ f = ctx.no_file() + ctx.termslash()
+ f2 = ctx.direct_sym() + ctx.termslash()
+
+ ctx.link(f, f2, err=ENOENT)
+ ctx.open_file(f, ro=1, err=ENOENT)
+ ctx.open_file(f2, ro=1, read=":xxx:yyy:zzz")
+
+# Hard link a symlink over a file
+def subtest_4(ctx):
+ """Hard link symlink over file"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.non_empty_dir() + "/a" + ctx.termslash()
+
+ ctx.link(f, f2, err=EEXIST)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f2, ro=1, read="")
+
+# Hard link a symlink over a new file
+def subtest_5(ctx):
+ """Hard link symlink over new file"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.reg_file() + "-new" + ctx.termslash()
+
+ ctx.open_file(f2, wo=1, crt=1, write="aaaa")
+ ctx.link(f, f2, err=EEXIST)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f2, ro=1, read="aaaa")
+
+# Hard link a new file over a symlink
+def subtest_6(ctx):
+ """Hard link new file over symlink"""
+ f = ctx.reg_file() + "-new" + ctx.termslash()
+ f2 = ctx.direct_sym() + ctx.termslash()
+
+ ctx.open_file(f, wo=1, crt=1, write="aaaa")
+ ctx.link(f, f2, err=EEXIST)
+ ctx.open_file(f, ro=1, read="aaaa")
+ ctx.open_file(f2, ro=1, read=":xxx:yyy:zzz")
+
+# Hard link a symlink over itself
+def subtest_7(ctx):
+ """Hard link symlink over itself"""
+ f = ctx.direct_sym() + ctx.termslash()
+
+ ctx.link(f, f, err=EEXIST)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+
+# Hard link a symlink over another symlink
+def subtest_8(ctx):
+ """Hard link symlink over another symlink"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.pointless() + ctx.termslash()
+
+ ctx.link(f, f2, err=EEXIST)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f2, ro=1, err=ENOENT)
+
+# Hard link an unlinked symlink
+def subtest_9(ctx):
+ """Hard link unlinked symlink"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.no_file() + ctx.termslash()
+
+ ctx.unlink(f)
+ ctx.link(f, f2, err=ENOENT)
+ ctx.open_file(f, ro=1, err=ENOENT)
+ ctx.open_file(f2, ro=1, err=ENOENT)
+
+# Hard link a renamed symlink
+def subtest_10(ctx):
+ """Hard link renamed symlink"""
+ f = ctx.direct_sym() + ctx.termslash()
+ f2 = ctx.no_file() + ctx.termslash()
+ f3 = ctx.no_file() + "-a" + ctx.termslash()
+
+ ctx.rename(f, f2)
+ ctx.link(f, f3, err=ENOENT)
+ ctx.link(f2, f)
+ ctx.open_file(f, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f2, ro=1, read=":xxx:yyy:zzz")
+ ctx.open_file(f3, ro=1, err=ENOENT)