From: Tim Kientzle Date: Sun, 2 Aug 2009 21:31:53 +0000 (-0400) Subject: Reduce diffs between libarchive/test/test.h and tar/test/test.h X-Git-Tag: v2.8.0~473 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e60ac984d3aabbd2bf0a24a46146fdd8399b0d90;p=thirdparty%2Flibarchive.git Reduce diffs between libarchive/test/test.h and tar/test/test.h SVN-Revision: 1314 --- diff --git a/libarchive/test/test.h b/libarchive/test/test.h index ec8d072fd..806d8a858 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -51,15 +51,11 @@ #ifdef USE_DMALLOC #include #endif -#if !defined(_WIN32) || defined(__CYGWIN__) +#if HAVE_DIRENT_H #include #else #include -#endif -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS +#define dirent direct #endif #include #include @@ -78,6 +74,29 @@ #include #endif +/* + * System-specific tweaks. We really want to minimize these + * as much as possible, since they make it harder to understand + * the mainline code. + */ + +#if defined(_WIN32) && !defined(__CYGWIN__) +#include "../bsdtar_windows.h" +#define strdup _strdup +#define LOCALE_DE "deu" +#else +#define LOCALE_DE "de_DE.UTF-8" +#endif + +#ifdef _MSC_VER +#define snprintf sprintf_s +#endif + +#if defined(__CYGWIN__) +/* Cygwin-1.7.x is lazy about populating nlinks, so don't + * expect it to be accurate. */ +# define NLINKS_INACCURATE_FOR_DIRS +#endif #ifdef __FreeBSD__ #include /* For __FBSDID */ @@ -90,17 +109,6 @@ #endif #endif -#ifdef _MSC_VER -#define snprintf sprintf_s -#endif - -#if defined(_WIN32) && !defined(__CYGWIN__) -#define LOCALE_DE "deu" -#define strdup _strdup -#else -#define LOCALE_DE "de_DE.UTF-8" -#endif - #ifndef O_BINARY #define O_BINARY 0 #endif @@ -159,10 +167,10 @@ test_setup(__FILE__, __LINE__);test_assert_text_file_contents #define assertIsDir(pathname, mode) \ test_assert_is_dir(__FILE__, __LINE__, pathname, mode) -#define assertIsSymlink(pathname, contents) \ - test_assert_is_symlink(__FILE__, __LINE__, pathname, contents) #define assertIsReg(pathname, mode) \ test_assert_is_reg(__FILE__, __LINE__, pathname, mode) +#define assertIsSymlink(pathname, contents) \ + test_assert_is_symlink(__FILE__, __LINE__, pathname, contents) /* Create a directory, report error if it fails. */ #define assertMakeDir(dirname, mode) \ test_assert_make_dir(__FILE__, __LINE__, dirname, mode) @@ -203,8 +211,8 @@ int test_assert_file_not_exists(const char *, ...); int test_assert_file_nlinks(const char *, int, const char *, int); int test_assert_file_size(const char *, int, const char *, long); int test_assert_is_dir(const char *, int, const char *, int); -int test_assert_is_symlink(const char *, int, const char *, const char *); int test_assert_is_reg(const char *, int, const char *, int); +int test_assert_is_symlink(const char *, int, const char *, const char *); int test_assert_make_dir(const char *, int, const char *, int); int test_assert_make_hardlink(const char *, int, const char *newpath, const char *); int test_assert_make_symlink(const char *, int, const char *newpath, const char *); diff --git a/tar/test/test.h b/tar/test/test.h index 996eb6b35..da44ec683 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -45,40 +45,57 @@ #error Oops: No config.h and no pre-built configuration in test.h. #endif -#if !defined(_WIN32) || defined(__CYGWIN__) +#include /* Windows requires this before sys/stat.h */ +#include + +#ifdef USE_DMALLOC +#include +#endif +#if HAVE_DIRENT_H #include #else -#define dirent direct -#include "../bsdtar_windows.h" #include -#endif -#if defined(__CYGWIN__) -/* In cygwin-1.7.x, the .nlinks field of directories is - * deliberately inaccurate, because to populate it requires - * stat'ing every file in the directory, which is slow. - * So, as an optimization cygwin doesn't do that in newer - * releases; all correct applications on any platform should - * never rely on it being > 1, so this optimization doesn't - * impact the operation of correctly coded applications. - * Therefore, the cpio test should not check its accuracy - */ -# define NLINKS_INACCURATE_FOR_DIRS +#define dirent direct #endif #include #include +#ifdef HAVE_IO_H +#include +#endif #include #include #include -#include /* Windows requires this before sys/stat.h */ -#include -#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#ifdef HAVE_UNISTD_H #include #endif -#include #include +#ifdef HAVE_WINDOWS_H +#include +#endif -#ifdef USE_DMALLOC -#include +/* + * System-specific tweaks. We really want to minimize these + * as much as possible, since they make it harder to understand + * the mainline code. + */ + +#if defined(_WIN32) && !defined(__CYGWIN__) +#include "../bsdtar_windows.h" +#define strdup _strdup +#define LOCALE_DE "deu" +#else +#define LOCALE_DE "de_DE.UTF-8" +#endif + +#ifdef _MSC_VER +#define snprintf sprintf_s +#endif + +#if defined(__CYGWIN__) +/* Cygwin-1.7.x is lazy about populating nlinks, so don't + * expect it to be accurate. */ +# define NLINKS_INACCURATE_FOR_DIRS #endif #ifdef __FreeBSD__ @@ -92,16 +109,6 @@ #endif #endif -#ifdef _MSC_VER -#define snprintf sprintf_s -#endif - -#if defined(_WIN32) && !defined(__CYGWIN__) -#define LOCALE_DE "deu" -#else -#define LOCALE_DE "de_DE.UTF-8" -#endif - /* * Redefine DEFINE_TEST for use in defining the test functions. */