From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/tests/crypttest.c | 6 +- source3/tests/fcntl_lock.c | 10 +- source3/tests/fcntl_lock64.c | 12 +-- source3/tests/ftruncate.c | 4 +- source3/tests/getgroups.c | 14 +-- source3/tests/os2_delete.c | 214 +++++++++++++++++++++++++++++++++++++++++++ source3/tests/shared_mmap.c | 16 ++-- source3/tests/summary.c | 1 - source3/tests/trivial.c | 1 - source3/tests/unixsock.c | 21 ++--- 10 files changed, 250 insertions(+), 49 deletions(-) create mode 100644 source3/tests/os2_delete.c (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index ee5a23235e..0e500d5481 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -813,7 +813,7 @@ main() if((strcmp(c_out1, expected_out) != 0) && (strcmp(c_out2, expected_out) == 0)) - return 1; + exit(1); #ifdef HAVE_BIGCRYPT /* @@ -842,10 +842,10 @@ main() if((strcmp(big_c_out1, big_expected_out) != 0) && (strcmp(big_c_out2, big_expected_out) == 0)) - return 1; + exit(1); } #endif - return 0; + exit(0); } diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 728f94b612..3dc12a3897 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - return 1; + exit(1); } lock.l_type = F_WRLCK; @@ -74,9 +74,9 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno); - return 1; + exit(1); } else { - return 0; + exit(0); } } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - return 1; + exit(1); } lock.l_type = F_WRLCK; @@ -117,5 +117,5 @@ int main(int argc, char *argv[]) status); } - return status; + exit(status); } diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c index b218fa9282..e5ecd88fd0 100644 --- a/source3/tests/fcntl_lock64.c +++ b/source3/tests/fcntl_lock64.c @@ -16,10 +16,6 @@ #include #endif -#ifdef HAVE_SYS_WAIT_H -#include -#endif - #include static int sys_waitpid(pid_t pid,int *status,int options) @@ -44,7 +40,7 @@ int main(int argc, char *argv[]) sleep(2); fd = open64(DATA, O_RDONLY); - if (fd == -1) return 1; + if (fd == -1) exit(1); lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -60,10 +56,10 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { /* printf("No lock conflict\n"); */ - return 1; + exit(1); } else { /* printf("lock conflict\n"); */ - return 0; + exit(0); } } @@ -96,5 +92,5 @@ int main(int argc, char *argv[]) unlink(DATA); - return status; + exit(status); } diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c index 700d5c8ce5..93282782ee 100644 --- a/source3/tests/ftruncate.c +++ b/source3/tests/ftruncate.c @@ -21,7 +21,7 @@ main() unlink(DATA); if (lseek(fd, 0, SEEK_END) == LEN) { - return 0; + exit(0); } - return 1; + exit(1); } diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c index c73cd21650..343fd5a184 100644 --- a/source3/tests/getgroups.c +++ b/source3/tests/getgroups.c @@ -11,10 +11,6 @@ #include #endif -#if defined(HAVE_STDLIB_H) -#include -#endif - #include #include #include @@ -30,7 +26,7 @@ main() if (sizeof(gid_t) == sizeof(int)) { fprintf(stderr,"gid_t and int are the same size\n"); - return 1; + exit(1); } if (ngroups <= 0) @@ -48,7 +44,7 @@ main() if (ngroups == 0) { printf("WARNING: can't determine getgroups return type\n"); - return 1; + exit(1); } cgroups = (char *)igroups; @@ -56,15 +52,15 @@ main() if (ngroups == 1 && cgroups[2] == 0x42 && cgroups[3] == 0x42) { fprintf(stderr,"getgroups returns gid_t\n"); - return 1; + exit(1); } for (i=0;i +#include +#include +#include +#include +#include +#include +#include +#include + +#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; +} +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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; +} diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c index 6af9ba0b39..fcef75d0d6 100644 --- a/source3/tests/shared_mmap.c +++ b/source3/tests/shared_mmap.c @@ -22,7 +22,7 @@ main() int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); int count=7; - if (fd == -1) return 1; + if (fd == -1) exit(1); for (i=0;i<10000;i++) { write(fd,&i,sizeof(i)); @@ -32,7 +32,7 @@ main() if (fork() == 0) { fd = open(DATA,O_RDWR); - if (fd == -1) return 1; + if (fd == -1) exit(1); buf = (int *)mmap(NULL, 10000*sizeof(int), (PROT_READ | PROT_WRITE), @@ -41,21 +41,21 @@ main() while (count-- && buf[9124] != 55732) sleep(1); - if (count <= 0) return 1; + if (count <= 0) exit(1); buf[1763] = 7268; - return 0; + exit(0); } fd = open(DATA,O_RDWR); - if (fd == -1) return 1; + if (fd == -1) exit(1); buf = (int *)mmap(NULL, 10000*sizeof(int), (PROT_READ | PROT_WRITE), MAP_FILE | MAP_SHARED, fd, 0); - if (buf == (int *)-1) return 1; + if (buf == (int *)-1) exit(1); buf[9124] = 55732; @@ -63,6 +63,6 @@ main() unlink(DATA); - if (count > 0) return 0; - return 1; + if (count > 0) exit(0); + exit(1); } diff --git a/source3/tests/summary.c b/source3/tests/summary.c index c3da22f170..8fcde7bd99 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -1,4 +1,3 @@ -#include #include main() diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c index ae368a1398..2723637a0f 100644 --- a/source3/tests/trivial.c +++ b/source3/tests/trivial.c @@ -1,4 +1,3 @@ -#include main() { exit(0); diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c index ba384ae362..f2765d68f6 100644 --- a/source3/tests/unixsock.c +++ b/source3/tests/unixsock.c @@ -1,5 +1,4 @@ -/* - * -*- c-file-style: "linux" -*- +/* -*- c-file-style: "linux" -*- * * Try creating a Unix-domain socket, opening it, and reading from it. * The POSIX name for these is AF_LOCAL/PF_LOCAL. @@ -9,17 +8,15 @@ * on which they are broken under some conditions, such as RedHat 7.0 * (unpatched). We can't build WinBind there at the moment. * - * Martin Pool , June 2000. - */ + * Coding standard says to always use exit() for this, not return, so + * we do. + * + * Martin Pool , June 2000. */ /* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ #include -#if defined(HAVE_UNISTD_H) -#include -#endif - #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -51,7 +48,7 @@ static int bind_socket(char const *filename) /* Create the socket. */ if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { perror ("socket(PF_LOCAL, SOCK_STREAM)"); - return 1; + exit(1); } /* Bind a name to the socket. */ @@ -70,7 +67,7 @@ static int bind_socket(char const *filename) if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) { perror ("bind"); - return 1; + exit(1); } return sock_fd; @@ -87,10 +84,10 @@ int main(void) alarm(15); /* secs */ if ((sock_fd = bind_socket(filename)) < 0) - return 1; + exit(1); /* the socket will be deleted when autoconf cleans up these files. */ - return 0; + exit(0); } -- cgit