]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Testsuite fixes for cygwin-1.5
authorCharles Wilson <cwilso11@gmail.com>
Fri, 10 Jul 2009 19:45:33 +0000 (15:45 -0400)
committerCharles Wilson <cwilso11@gmail.com>
Fri, 10 Jul 2009 19:45:33 +0000 (15:45 -0400)
* configure.ac: Detect cygwin-1.7.
* tar/test/test_copy.c: Better tuning for long filename tests.

NOTE: this change causes a new cygwin-1.7 failure, but that is
actually a bug in the current cygwin-1.7 beta:
  http://cygwin.com/ml/cygwin/2009-07/msg00386.html
It's assumed this will be fixed in cygwin, soon.

SVN-Revision: 1220

configure.ac
tar/test/test_copy.c

index 9833762d0b0d516d0f58ffcfbe0040c5865a31a5..0ef962f3c0d774b065e7929ada7cd188e379dc13 100644 (file)
@@ -335,6 +335,8 @@ AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale])
 AC_CHECK_FUNCS([strchr strdup strerror strrchr timegm])
 AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
 AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
+# detects cygwin-1.7, as opposed to older versions
+AC_CHECK_FUNCS([cygwin_conv_path])
 
 # FreeBSD's nl_langinfo supports an option to specify whether the
 # current locale uses month/day or day/month ordering.  It makes the
index a45d512a0e1e90214448d72424f7a6ea2639889d..85640e7603552b304ff44283b30ce432444e628e 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD: src/usr.bin/tar/test/test_copy.c,v 1.3 2008/08/15 06:12:02 kientzle Exp $");
 
-#define        LOOP_MAX        170
+#if defined(__CYGWIN__)
+# include <limits.h>
+# include <sys/cygwin.h>
+#endif
+
+/* assumes that cwd is the top of the test tree. Furthermore,
+ * assumes that this function is first called with the "longest"
+ * cwd involved in the tests.  That is, from
+ *  <testdir>/original
+ * as opposed to
+ *  <testdir>/plain or <testdir>/ustar
+ */
+static int
+compute_loop_max(void)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       static int LOOP_MAX = 0;
+       char buf[MAX_PATH];
+       size_t cwdlen;
+
+       if (LOOP_MAX == 0) {
+               assert(_getcwd(buf, MAX_PATH) != NULL);
+               cwdlen = strlen(buf);
+               /* on windows, can't create a directory in which there is not
+                * enough room left in MAX_PATH to /also/ create an 8.3 file.
+                * Thus, max path len for mkdir is MAX_PATH - 12 ("12345678.123")
+                * It is possible also that windows counts the length of cwd against
+                * the MAX_PATH maximum, so account for that. Next, account also for
+                * "/".  And lastly, account for the fact that the relative path
+                * has 4 characters when the loop count i = 0.
+                */
+                LOOP_MAX = MAX_PATH - 12 - (int)cwdlen - 1 - 4;
+       }
+       return LOOP_MAX;
+#elif defined(__CYGWIN__) && !defined(HAVE_CYGWIN_CONV_PATH)
+       static int LOOP_MAX = 0;
+       if (LOOP_MAX == 0) {
+               char wbuf[PATH_MAX];
+               char pbuf[PATH_MAX];
+               size_t wcwdlen;
+               size_t pcwdlen;
+               size_t cwdlen;
+               assert(getcwd(pbuf, PATH_MAX) != NULL);
+               pcwdlen = strlen(pbuf);
+               cygwin_conv_to_full_win32_path(pbuf, wbuf);
+               wcwdlen = strlen(wbuf);
+               cwdlen = ((wcwdlen > pcwdlen) ? wcwdlen : pcwdlen);
+               /* on windows, can't create a directory in which there is not
+                * enough room left in PATH_MAX to /also/ create an 8.3 file.
+                * Thus, max path len for mkdir is PATH_MAX - 12 ("12345678.123")
+                * Then, because cygwin treats even relative paths as if they were
+                * absolute, and cwd counts against the PATH_MAX maximum, we must
+                * account for that (using worst case of posix or win32 equivalents).
+                * Next, account also for "/../" (as used in symlink creation test).
+                * And lastly, account for the fact that the relative path has 4
+                * characters when the loop count i = 0. These calculations do not
+                * apply to cygwin-1.7, because unlike older cygwin, it uses the "wide"
+                * functions of the win32 system for all file and directory access.
+                */
+               LOOP_MAX = PATH_MAX - 12 - (int)cwdlen - 4 - 4;
+       }
+       return LOOP_MAX;
+#else
+       /* cygwin-1.7 ends up here, along with "normal" unix */
+       return 200; /* restore pre-r278 depth */
+#endif
+}
 
 static void
 create_tree(void)
@@ -34,9 +100,12 @@ create_tree(void)
        char buff2[260];
        int i;
        FILE *f;
+       int LOOP_MAX;
 
        assertEqualInt(0, mkdir("original", 0775));
        chdir("original");
+       LOOP_MAX = compute_loop_max();
+
        assertEqualInt(0, mkdir("f", 0775));
        assertEqualInt(0, mkdir("l", 0775));
        assertEqualInt(0, mkdir("m", 0775));
@@ -97,13 +166,15 @@ verify_tree(int limit)
        char name1[260];
        char name2[260];
        char contents[260];
-       int i, j, r;
+       int i, j, r, LOOP_MAX;
        FILE *f;
        int len;
        const char *p, *dp;
        DIR *d;
        struct dirent *de;
 
+       LOOP_MAX = compute_loop_max();
+
        /* Generate the names we know should be there and verify them. */
        for (i = 1; i < LOOP_MAX; i++) {
                /* Generate a base name of the correct length. */
@@ -254,6 +325,12 @@ copy_basic(void)
 {
        int r;
 
+       /* NOTE: for proper operation on cygwin-1.5 and windows, the
+        * length of the name of the directory below, "plain", must be
+        * less than or equal to the lengthe of the name of the original
+        * directory, "original"  This restriction derives from the
+        * extremely limited pathname lengths on those platforms.
+        */
        assertEqualInt(0, mkdir("plain", 0775));
        assertEqualInt(0, chdir("plain"));
 
@@ -290,6 +367,12 @@ copy_ustar(void)
        const char *target = "ustar";
        int r;
 
+       /* NOTE: for proper operation on cygwin-1.5 and windows, the
+        * length of the name of the directory below, "ustar", must be
+        * less than or equal to the lengthe of the name of the original
+        * directory, "original"  This restriction derives from the
+        * extremely limited pathname lengths on those platforms.
+        */
        assertEqualInt(0, mkdir(target, 0775));
        assertEqualInt(0, chdir(target));