From 0f100b3d74ef15789aa61a556fd9899ea437dad2 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Thu, 6 Aug 2009 00:52:37 -0400 Subject: [PATCH] bsdcpio_test builds cleanly on VS9 and MinGW with this revision. SVN-Revision: 1342 --- cpio/test/CMakeLists.txt | 1 - cpio/test/main.c | 13 +++++++++++++ cpio/test/test.h | 3 +++ cpio/test/test_option_a.c | 5 +---- cpio/test/test_owner_parse.c | 17 +++++++++-------- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/cpio/test/CMakeLists.txt b/cpio/test/CMakeLists.txt index 072e68f00..22bfd7ad6 100644 --- a/cpio/test/CMakeLists.txt +++ b/cpio/test/CMakeLists.txt @@ -39,7 +39,6 @@ IF(ENABLE_CPIO AND ENABLE_TEST) test_pathmatch.c ) IF(WIN32 AND NOT CYGWIN) - LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.c) LIST(APPEND bsdcpio_test_SOURCES ../cpio_windows.h) ENDIF(WIN32 AND NOT CYGWIN) diff --git a/cpio/test/main.c b/cpio/test/main.c index 068821e70..1f6877a28 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -1753,3 +1753,16 @@ int main(int argc, char **argv) return (tests_failed); } + +void +sleepUntilAfter(time_t t) +{ + /* If utime() is supported above, there's no sleep here which + * makes the test faster. */ + while (t >= time(NULL)) +#if defined(_WIN32) && !defined(__CYGWIN__) + Sleep(500); +#else + sleep(1); +#endif +} diff --git a/cpio/test/test.h b/cpio/test/test.h index 13dd380da..ad504770c 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -221,6 +221,9 @@ void test_skipping(const char *fmt, ...); /* Like sprintf, then system() */ int systemf(const char * fmt, ...); +/* Delay until time() returns a value after this. */ +void sleepUntilAfter(time_t); + /* Suck file into string allocated via malloc(). Call free() when done. */ /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */ char *slurpfile(size_t *, const char *fmt, ...); diff --git a/cpio/test/test_option_a.c b/cpio/test/test_option_a.c index a597bd8d6..815845736 100644 --- a/cpio/test/test_option_a.c +++ b/cpio/test/test_option_a.c @@ -83,10 +83,7 @@ test_create(void) } /* Wait until the atime on the last file is actually in the past. */ - /* If utime() is supported above, there's no sleep here which - * makes the test faster. */ - while (files[numfiles - 1].atime_sec >= time(NULL)) - sleep(1); + sleepUntilAfter(files[numfiles - 1].atime_sec); } DEFINE_TEST(test_option_a) diff --git a/cpio/test/test_owner_parse.c b/cpio/test/test_owner_parse.c index 7288bb496..e63ba8949 100644 --- a/cpio/test/test_owner_parse.c +++ b/cpio/test/test_owner_parse.c @@ -28,7 +28,11 @@ __FBSDID("$FreeBSD$"); #include "../cpio.h" #include "err.h" -#if defined(__CYGWIN__) +#if !defined(_WIN32) +#define ROOT "root" +static int root_uids[] = { 0 }; +static int root_gids[] = { 0 }; +#elif defined(__CYGWIN__) /* On cygwin, the Administrator user most likely exists (unless * it has been renamed or is in a non-English localization), but * its primary group membership depends on how the user set up @@ -40,12 +44,9 @@ __FBSDID("$FreeBSD$"); #define ROOT "Administrator" static int root_uids[] = { 500 }; static int root_gids[] = { 513, 545, 544 }; -#else -#define ROOT "root" -static int root_uids[] = { 0 }; -static int root_gids[] = { 0 }; #endif +#if defined(ROOT) static int int_in_list(int i, int *l, size_t n) { @@ -55,12 +56,12 @@ int_in_list(int i, int *l, size_t n) failure("%d", i); return (0); } +#endif DEFINE_TEST(test_owner_parse) { -#if defined(_WIN32) && !defined(__CYGWIN__) - /* TODO: Does this need cygwin style handling of uid/gid ? */ - skipping("Windows cannot handle uid/gid as UNIX like system"); +#if !defined(ROOT) + skipping("No uid/gid configuration for this OS"); #else int uid, gid; -- 2.47.3