From 68201cc76b430c1122c0f3c665c9af649ba54311 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Sep 2006 07:05:41 +0000 Subject: r18419: fix include paths of the configure tests metze (This used to be commit 8774eeb0dc8a72a9871d42bf1652ce4f7d4a29b7) --- source4/lib/replace/test/os2_delete.c | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 source4/lib/replace/test/os2_delete.c (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c new file mode 100644 index 0000000000..288e4a5d8f --- /dev/null +++ b/source4/lib/replace/test/os2_delete.c @@ -0,0 +1,110 @@ +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REPLACE_READDIR +#include "lib/replace/repdir/repdir.h" +#endif + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} -- cgit From 764f74c565e4d5472c68ac9d820b6d1b1dbd598a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 06:11:53 +0000 Subject: r18442: run the os2_delete test in the testsuite too that shows that Tru64 is broken... It doesn't have getdirent() and the the replacement code doesn't work there. tridge: do you have any idea how to fix this? metze (This used to be commit a5ebfd0ab71f4f4288697f6fd3183a440ce7506b) --- source4/lib/replace/test/os2_delete.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 288e4a5d8f..c73b7e54cd 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -12,9 +12,6 @@ #include #include #include -#ifdef REPLACE_READDIR -#include "lib/replace/repdir/repdir.h" -#endif #define NUM_FILES 700 #define READDIR_SIZE 100 @@ -22,7 +19,10 @@ #define TESTDIR "test.dir" -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) +static int test_readdir_os2_delete_ret; + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define CHECK do { if (test_readdir_os2_delete_ret != 0) return test_readdir_os2_delete_ret; } while (0) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -78,7 +78,7 @@ static int os2_delete(DIR *d) return j; } -int main(void) +int test_readdir_os2_delete(void) { int total_deleted = 0; DIR *d; -- cgit From cac47350c23793842cc2a5f5a0f17da739044729 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 07:35:42 +0000 Subject: r18444: return the correct value on error metze (This used to be commit d65e94fea910ff435b5cb6fe146f81b01df9abf6) --- source4/lib/replace/test/os2_delete.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c73b7e54cd..641b8c8d93 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -22,7 +22,6 @@ static int test_readdir_os2_delete_ret; #define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) -#define CHECK do { if (test_readdir_os2_delete_ret != 0) return test_readdir_os2_delete_ret; } while (0) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -84,6 +83,8 @@ int test_readdir_os2_delete(void) DIR *d; struct dirent *de; + test_readdir_os2_delete_ret = 0; + cleanup(); create_files(); @@ -106,5 +107,5 @@ int test_readdir_os2_delete(void) rmdir(TESTDIR) == 0 || FAILED("rmdir"); - return 0; + return test_readdir_os2_delete_ret; } -- cgit From 90c3e8b9060722190e2537069bb7eafe1491c611 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 23:13:44 +0000 Subject: r18491: fixed a warning (This used to be commit 1b17f0f08f85238717e88966cba311ff4b933a9a) --- source4/lib/replace/test/os2_delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 641b8c8d93..d0aadb24ba 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -34,7 +34,7 @@ static void cleanup(void) mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); } -static void create_files() +static void create_files(void) { int i; for (i=0;i Date: Mon, 2 Oct 2006 08:56:35 +0000 Subject: r19029: test if opendir() on a file sets errno = ENOTDIR metze (This used to be commit 6b5f06b059583f9d685d71d48299ab334581c179) --- source4/lib/replace/test/os2_delete.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index d0aadb24ba..8501e0bb40 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -21,7 +21,7 @@ static int test_readdir_os2_delete_ret; -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -87,7 +87,11 @@ int test_readdir_os2_delete(void) cleanup(); create_files(); - + + d = opendir(TESTDIR "/test0.txt"); + if (d != NULL) FAILED("opendir() on file succeed"); + if (errno != ENOTDIR) FAILED("opendir() on file didn't give ENOTDIR"); + d = opendir(TESTDIR); /* skip past . and .. */ -- cgit From 8acb0575c716c8ca680835764cd3bc5483f3707c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 17 Oct 2006 14:54:47 +0000 Subject: r19373: Merge changes from subunit branch: Convert libreplace testsuite to a standalone program that speaks subunit. (This used to be commit 48d316e7594dfc29b8e6a710e32bb5a6a036b7cf) --- source4/lib/replace/test/os2_delete.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 8501e0bb40..c8abfccff9 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -21,7 +21,7 @@ static int test_readdir_os2_delete_ret; -#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -107,7 +107,7 @@ int test_readdir_os2_delete(void) } closedir(d); - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); rmdir(TESTDIR) == 0 || FAILED("rmdir"); -- cgit From 34952e81fadc06ff2ae68d982963b26d41f4872c Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 20 Apr 2007 17:55:36 +0000 Subject: r22415: Remove test directory once we are finished. Merge -r 22393:22394 from SAMBA_3_0. (This used to be commit a8fe3c34e2964c7080ec3702b53ec141d58b7e5f) --- source4/lib/replace/test/os2_delete.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c8abfccff9..c6ef180017 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -111,5 +111,7 @@ int test_readdir_os2_delete(void) rmdir(TESTDIR) == 0 || FAILED("rmdir"); + system("rm -rf " TESTDIR); + return test_readdir_os2_delete_ret; } -- cgit From 35f33a26404866c676285356a17e42b56523008a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 27 Mar 2008 11:26:33 +0100 Subject: libreplace: fix coverity ID 517 - untangle close from open in test/os2_delete.c This is not a proper bug but the code is clearer now and we are tracking failure of open separate from that of close. Michael (This used to be commit 4ae4692bc6c6da15483a6f4a3363cdc23121efc7) --- source4/lib/replace/test/os2_delete.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/os2_delete.c') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c6ef180017..b45c135355 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -39,8 +39,15 @@ static void create_files(void) int i; for (i=0;i