]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Various fixes to symlink-related tests:
authorTim Kientzle <kientzle@gmail.com>
Mon, 14 Sep 2009 04:38:40 +0000 (00:38 -0400)
committerTim Kientzle <kientzle@gmail.com>
Mon, 14 Sep 2009 04:38:40 +0000 (00:38 -0400)
 * canSymlink() is no longer hardwired to always return false
 * cpio/test/test_gcpio_compat now has symlink-free test archives
   for use on platforms that lack symlink support
 * several other tests have slightly finer-grained avoidance of
   checks that rely on symlink support

SVN-Revision: 1458

12 files changed:
cpio/test/main.c
cpio/test/test_gcpio_compat.c
cpio/test/test_gcpio_compat_ref_nosym.bin.uu [new file with mode: 0644]
cpio/test/test_gcpio_compat_ref_nosym.crc.uu [new file with mode: 0644]
cpio/test/test_gcpio_compat_ref_nosym.newc.uu [new file with mode: 0644]
cpio/test/test_gcpio_compat_ref_nosym.ustar.uu [new file with mode: 0644]
cpio/test/test_option_L_upper.c
libarchive/config_freebsd.h
libarchive/test/main.c
tar/test/main.c
tar/test/test_strip_components.c
tar/test/test_symlink_dir.c

index d0d58013d699b17177adac3113893d0f7165c089..a525562de09199e44c79ede42b42ae50e3891415 100644 (file)
@@ -1331,7 +1331,7 @@ int
 canSymlink(void)
 {
        /* Remember the test result */
-       static int value = 0, tested = 1;
+       static int value = 0, tested = 0;
        if (tested)
                return (value);
 
index 2a98dfc66939f23416cbf3b44f78d3fe1fdf0019..1e1e594bdc520816a7704100dbf42b1235101c6e 100644 (file)
@@ -45,8 +45,11 @@ unpack_test(const char *from, const char *options, const char *se)
        assertEqualInt(r, 0);
 
        /* Verify that nothing went to stderr. */
-       failure("Error invoking %s -i %s < %s", testprog, options, from);
-       assertTextFileContents(se, "unpack.err");
+       if (canSymlink()) {
+               failure("Error invoking %s -i %s < %s",
+                   testprog, options, from);
+               assertTextFileContents(se, "unpack.err");
+       }
 
        /*
         * Verify unpacked files.
@@ -61,7 +64,8 @@ unpack_test(const char *from, const char *options, const char *se)
        assertIsHardlink("linkfile", "file");
 
        /* Symlink */
-       assertIsSymlink("symlink", "file");
+       if (canSymlink())
+               assertIsSymlink("symlink", "file");
 
        /* dir */
        assertIsDir("dir", 0775);
@@ -74,9 +78,25 @@ DEFINE_TEST(test_gcpio_compat)
        assertUmask(0);
 
        /* Dearchive sample files with a variety of options. */
-       unpack_test("test_gcpio_compat_ref.bin", "--no-preserve-owner", "1 block\n");
-       unpack_test("test_gcpio_compat_ref.crc", "--no-preserve-owner", "2 blocks\n");
-       unpack_test("test_gcpio_compat_ref.newc", "--no-preserve-owner", "2 blocks\n");
-       /* gcpio-2.9 only reads 6 blocks here */
-       unpack_test("test_gcpio_compat_ref.ustar", "--no-preserve-owner", "7 blocks\n");
+       if (canSymlink()) {
+               unpack_test("test_gcpio_compat_ref.bin",
+                   "--no-preserve-owner", "1 block\n");
+               unpack_test("test_gcpio_compat_ref.crc",
+                   "--no-preserve-owner", "2 blocks\n");
+               unpack_test("test_gcpio_compat_ref.newc",
+                   "--no-preserve-owner", "2 blocks\n");
+               /* gcpio-2.9 only reads 6 blocks here */
+               unpack_test("test_gcpio_compat_ref.ustar",
+                   "--no-preserve-owner", "7 blocks\n");
+       } else {
+               unpack_test("test_gcpio_compat_ref_nosym.bin",
+                   "--no-preserve-owner", "1 block\n");
+               unpack_test("test_gcpio_compat_ref_nosym.crc",
+                   "--no-preserve-owner", "2 blocks\n");
+               unpack_test("test_gcpio_compat_ref_nosym.newc",
+                   "--no-preserve-owner", "2 blocks\n");
+               /* gcpio-2.9 only reads 6 blocks here */
+               unpack_test("test_gcpio_compat_ref_nosym.ustar",
+                   "--no-preserve-owner", "7 blocks\n");
+       }
 }
diff --git a/cpio/test/test_gcpio_compat_ref_nosym.bin.uu b/cpio/test/test_gcpio_compat_ref_nosym.bin.uu
new file mode 100644 (file)
index 0000000..a3e87a7
--- /dev/null
@@ -0,0 +1,15 @@
+begin 644 test_gcpio_compat_ref_nosym.bin
+MQW%4`-[Z_4'H`^@#`@`VNZU*NQX$``````!D:7(`QW%4`-SZI('H`^@#`@`G
+MNZU*NQX%````"@!F:6QE```Q,C,T-38W.#D*QW%4`-SZI('H`^@#`@`GNZU*
+MNQX)````"@!L:6YK9FEL90``,3(S-#4V-S@Y"L=Q``````````````$`````
+M````"P``````5%)!24Q%4B$A(0``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+1````````````````````````
+`
+end
diff --git a/cpio/test/test_gcpio_compat_ref_nosym.crc.uu b/cpio/test/test_gcpio_compat_ref_nosym.crc.uu
new file mode 100644 (file)
index 0000000..38ba9fe
--- /dev/null
@@ -0,0 +1,15 @@
+begin 644 test_gcpio_compat_ref_nosym.crc
+M,#<P-S`R,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
+M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
+M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#(P,#4V1D%$0S`P,#`X
+M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
+M,&9I;&4``#`W,#<P,C`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
+M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
+M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,44W;&EN:V9I;&4``#$R,S0U-C<X
+M.0H``#`W,#<P,C`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
+M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
+1````````````````````````
+`
+end
diff --git a/cpio/test/test_gcpio_compat_ref_nosym.newc.uu b/cpio/test/test_gcpio_compat_ref_nosym.newc.uu
new file mode 100644 (file)
index 0000000..2404964
--- /dev/null
@@ -0,0 +1,15 @@
+begin 644 test_gcpio_compat_ref_nosym.newc
+M,#<P-S`Q,#`U-D9!1$4P,#`P-#%&1#`P,#`P,T4X,#`P,#`S13@P,#`P,#`P
+M,C1!040Q14)",#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P0D(P,35"
+M,#`S-C`P,#`P,#`T,#`P,#`P,#!D:7(````P-S`W,#$P,#4V1D%$0S`P,#`X
+M,4$T,#`P,#`S13@P,#`P,#-%.#`P,#`P,#`R-$%!1#%%0D(P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P-30P,#`P,#!"0C`Q-4(P,#(W,#`P,#`P,#4P,#`P,#`P
+M,&9I;&4``#`W,#<P,3`P-39&041#,#`P,#@Q030P,#`P,#-%.#`P,#`P,T4X
+M,#`P,#`P,#(T04%$,45"0C`P,#`P,#!!,#`P,#`P,#`P,#`P,#`U-#`P,#`P
+M,$)",#$U0C`P,C<P,#`P,#`P.3`P,#`P,#`P;&EN:V9I;&4``#$R,S0U-C<X
+M.0H``#`W,#<P,3`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
+M,#`P,#$P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P0C`P,#`P,#`P5%)!24Q%4B$A(0``````````````
+1````````````````````````
+`
+end
diff --git a/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu b/cpio/test/test_gcpio_compat_ref_nosym.ustar.uu
new file mode 100644 (file)
index 0000000..5f9fcbe
--- /dev/null
@@ -0,0 +1,72 @@
+begin 644 test_gcpio_compat_ref_nosym.ustar
+M9&ER+P``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`W-S4`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#`P
+M`#$Q,C4S,C$W,C<S`#`P,3$S-3$`-0``````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
+M````````````````````````````````````=&EM````````````````````
+M```````````````````P,#`P,C<S`#8V,#`P-C8`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!F:6QE````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````,#`P,#8T-``P,#`Q-S4P`#`P
+M,#$W-3``,#`P,#`P,#`P,3(`,3$R-3,R,3<R-S,`,#`Q,30R,P`P````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````'5S=&%R`#`P=&EM``````````````````````````````````````!T
+M:6T``````````````````````````````````````#`P,#`R-S,`-C8P,#`T
+M-P``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````#$R,S0U-C<X.0H`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````;&EN:V9I;&4`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
+M,#`P,#`P`#$Q,C4S,C$W,C<S`#`P,3,Q,S<`,69I;&4`````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!U<W1A<@`P
+M,'1I;0``````````````````````````````````````=&EM````````````
+M```````````````````````````P,#`P,C<S`#8V,#`P-#<`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+,````````````````
+`
+end
index 219f610b2396e15108b7b68f2c442d9b73dc8967..abe669facf293bf4b7ebb22d1c8c885d632c1536 100644 (file)
@@ -25,6 +25,9 @@
 #include "test.h"
 __FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
 
+/* This is a little pointless, as Windows doesn't support symlinks
+ * (except for the seriously crippled CreateSymbolicLink API) so these
+ * tests won't run on Windows. */
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define CAT "type"
 #else
@@ -36,6 +39,11 @@ DEFINE_TEST(test_option_L_upper)
        FILE *filelist;
        int r;
 
+       if (!canSymlink()) {
+               skipping("Symlink tests");
+               return;
+       }
+
        filelist = fopen("filelist", "w");
 
        /* Create a file and a symlink to the file. */
@@ -51,10 +59,8 @@ DEFINE_TEST(test_option_L_upper)
        r = systemf(CAT " filelist | %s -pd copy >copy.out 2>copy.err", testprog);
        assertEqualInt(r, 0);
 
-#if !defined(_WIN32) || defined(__CYGWIN__)
        failure("Regular -p without -L should preserve symlinks.");
        assertIsSymlink("copy/symlink", NULL);
-#endif
 
        r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
        assertEqualInt(r, 0);
@@ -68,32 +74,22 @@ DEFINE_TEST(test_option_L_upper)
        assertEqualInt(r, 0);
 
        assertMakeDir("unpack", 0755);
-#if defined(_WIN32) && !defined(__CYGWIN__)
        assertChdir("unpack");
-       r = systemf("type ..\\archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+       r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog);
        assertChdir("..");
-#else
-       r = systemf("cat archive.out | (cd unpack ; %s -i >unpack.out 2>unpack.err)", testprog);
-#endif
        failure("Error invoking %s -i", testprog);
        assertEqualInt(r, 0);
 
-#if !defined(_WIN32) || defined(__CYGWIN__)
        assertIsSymlink("unpack/symlink", NULL);
-#endif
 
        r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
        failure("Error invoking %s -oL", testprog);
        assertEqualInt(r, 0);
 
        assertMakeDir("unpack-L", 0755);
-#if defined(_WIN32) && !defined(__CYGWIN__)
        assertChdir("unpack-L");
-       r = systemf("type ..\\archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+       r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
        assertChdir("..");
-#else
-       r = systemf("cat archive-L.out | (cd unpack-L ; %s -i >unpack-L.out 2>unpack-L.err)", testprog);
-#endif
        failure("Error invoking %s -i < archive-L.out", testprog);
        assertEqualInt(r, 0);
        assertIsReg("unpack-L/symlink", -1);
index 2ebfe209148b0744d28620768d461ce3bf7ff382..1e27c2cd12e9ebbb4aba9604b6695d6ed1754751 100644 (file)
 #define        HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
 #define        HAVE_STRUCT_STAT_ST_FLAGS 1
 #define        HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define        HAVE_SYMLINK 1
+/* #define     HAVE_SYMLINK 1 */
 #define        HAVE_SYS_IOCTL_H 1
 #define        HAVE_SYS_SELECT_H 1
 #define        HAVE_SYS_STAT_H 1
index 0436ca6d564437e5c65e3148d3a5da55310c048a..18693d4ef2c811797136fc1834f550ac1dbe727e 100644 (file)
@@ -1330,7 +1330,7 @@ int
 canSymlink(void)
 {
        /* Remember the test result */
-       static int value = 0, tested = 1;
+       static int value = 0, tested = 0;
        if (tested)
                return (value);
 
index 51a468393fe2759b1a38c1c595be6e756888582b..ea8686591220c47cf040f6f9473ed0e7836cc417 100644 (file)
@@ -1141,6 +1141,9 @@ is_symlink(const char *file, int line,
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
        assertion_count(file, line);
+       /* Windows sort-of has real symlinks, but they're only usable
+        * by privileged users and are crippled even then, so there's
+        * really not much point in bothering with this. */
        return (0);
 #else
        char buff[300];
@@ -1330,7 +1333,7 @@ int
 canSymlink(void)
 {
        /* Remember the test result */
-       static int value = 0, tested = 1;
+       static int value = 0, tested = 0;
        if (tested)
                return (value);
 
index 2ae1081840f4f7f7470c21f076b1df786c9d39dd..c9028a4d766170338ad16f1dc425af1217215c5d 100644 (file)
@@ -47,8 +47,10 @@ DEFINE_TEST(test_strip_components)
        assertEqualInt(1, touch("d1/d2/f1"));
        assertMakeHardlink("l1", "d1/d2/f1");
        assertMakeHardlink("d1/l2", "d1/d2/f1");
-       assertMakeSymlink("s1", "d1/d2/f1");
-       assertMakeSymlink("d1/s2", "d2/f1");
+       if (canSymlink()) {
+               assertMakeSymlink("s1", "d1/d2/f1");
+               assertMakeSymlink("d1/s2", "d2/f1");
+       }
        assertChdir("..");
 
        assertEqualInt(0, systemf("%s -cf test.tar d0", testprog));
@@ -62,12 +64,11 @@ DEFINE_TEST(test_strip_components)
        failure("d0/d1/ is too short and should not get restored");
        assertFileNotExists("target/d1");
        failure("d0/d1/s2 is a symlink to something that won't be extracted");
-#if !defined(_WIN32) || defined(__CYGWIN__)
+       /* If platform supports symlinks, target/s2 is a broken symlink. */
+       /* If platform does not support symlink, target/s2 doesn't exist. */
        assertFileNotExists("target/s2");
-       assertIsSymlink("target/s2", "d2/f1");
-#else
-       skipping("symlink");
-#endif
+       if (canSymlink())
+               assertIsSymlink("target/s2", "d2/f1");
        failure("d0/d1/d2 should be extracted");
        assertIsDir("target/d2", -1);
 
index 3a50e08cc4b645328384bb09fe60ffbb831b300b..33d59579f32efd725973905b2a2bdd4547719f37 100644 (file)
@@ -49,10 +49,6 @@ mkfile(const char *name, int mode, const char *contents, size_t size)
 
 DEFINE_TEST(test_symlink_dir)
 {
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       struct stat st;
-       struct stat st2;
-#endif
        assertUmask(0);
 
        assertMakeDir("source", 0755);
@@ -76,27 +72,25 @@ DEFINE_TEST(test_symlink_dir)
         * Extract with -x and without -P.
         */
        assertMakeDir("dest1", 0755);
-       /* "dir" is a symlink to an existing "real_dir" */
+       /* "dir" is a symlink to an existing "dest1/real_dir" */
        assertMakeDir("dest1/real_dir", 0755);
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       assertEqualInt(0, symlink("real_dir", "dest1/dir"));
-       /* "dir2" is a symlink to a non-existing "real_dir2" */
-       assertEqualInt(0, symlink("real_dir2", "dest1/dir2"));
-#else
-       skipping("symlink does not work on this platform");
-#endif
+       if (canSymlink()) {
+               assertMakeSymlink("dest1/dir", "real_dir");
+               /* "dir2" is a symlink to a non-existing "real_dir2" */
+               assertMakeSymlink("dest1/dir2", "real_dir2");
+       } else {
+               skipping("some symlink checks");
+       }
        /* "dir3" is a symlink to an existing "non_dir3" */
        assertEqualInt(0, mkfile("dest1/non_dir3", 0755, "abcdef", 6));
        assertMakeSymlink("dest1/dir3", "non_dir3");
        /* "file" is a symlink to existing "real_file" */
        assertEqualInt(0, mkfile("dest1/real_file", 0755, "abcdefg", 7));
-       assertMakeSymlink("dest1/file", "real_file");
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       /* "file2" is a symlink to non-existing "real_file2" */
-       assertMakeSymlink("dest1/file2", "real_file2");
-#else
-       skipping("symlink does not work on this platform");
-#endif
+       if (canSymlink()) {
+               assertMakeSymlink("dest1/file", "real_file");
+               /* "file2" is a symlink to non-existing "real_file2" */
+               assertMakeSymlink("dest1/file2", "real_file2");
+       }
        assertEqualInt(0, systemf("%s -xf test.tar -C dest1", testprog));
 
        /* dest1/dir symlink should be replaced */
@@ -121,47 +115,25 @@ DEFINE_TEST(test_symlink_dir)
        assertMakeDir("dest2", 0755);
        /* "dir" is a symlink to existing "real_dir" */
        assertMakeDir("dest2/real_dir", 0755);
-#if !defined(_WIN32) || defined(__CYGWIN__)
        assertMakeSymlink("dest2/dir", "real_dir");
        /* "dir2" is a symlink to a non-existing "real_dir2" */
        assertMakeSymlink("dest2/dir2", "real_dir2");
-#else
-       skipping("symlink does not work on this platform");
-#endif
        /* "dir3" is a symlink to an existing "non_dir3" */
        assertEqualInt(0, mkfile("dest2/non_dir3", 0755, "abcdefgh", 8));
        assertMakeSymlink("dest2/dir3", "non_dir3");
        /* "file" is a symlink to existing "real_file" */
        assertEqualInt(0, mkfile("dest2/real_file", 0755, "abcdefghi", 9));
        assertMakeSymlink("dest2/file", "real_file");
-#if !defined(_WIN32) || defined(__CYGWIN__)
        /* "file2" is a symlink to non-existing "real_file2" */
        assertMakeSymlink("dest2/file2", "real_file2");
-#else
-       skipping("symlink does not work on this platform");
-#endif
        assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog));
 
        /* dest2/dir symlink should be followed */
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       assertEqualInt(0, lstat("dest2/dir", &st));
-       failure("tar -xP removed symlink instead of following it");
-       if (assert(S_ISLNK(st.st_mode))) {
-               /* Only verify what the symlink points to if it
-                * really is a symlink. */
-               failure("The symlink should point to a directory");
-               assertEqualInt(0, stat("dest2/dir", &st));
-               assert(S_ISDIR(st.st_mode));
-               failure("The pre-existing directory should still be there");
-               assertEqualInt(0, lstat("dest2/real_dir", &st2));
-               assert(S_ISDIR(st2.st_mode));
-               assertEqualInt(st.st_dev, st2.st_dev);
-               failure("symlink should still point to the existing directory");
-               assertEqualInt(st.st_ino, st2.st_ino);
+       if (canSymlink()) {
+               assertIsSymlink("dest2/dir", "real_dir");
+               assertIsDir("dest2/real_dir", -1);
        }
-#else
-       skipping("symlink does not work on this platform");
-#endif
+
        /* Contents of 'dir' should be restored */
        assertIsDir("dest2/dir/d", -1);
        assertIsReg("dest2/dir/f", -1);