From 76381c4493b6273fa1aa3ea6f5277f7471d42d7e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 28 Apr 2007 10:57:58 +0200 Subject: added make test and make valgrindtest targets (This used to be ctdb commit b69fb43643993ee5aaabf8711bb874f95d468f35) --- ctdb/Makefile.in | 8 +- ctdb/lib/replace/test/os2_delete.c | 115 --------- ctdb/lib/replace/test/shared_mmap.c | 68 ----- ctdb/lib/replace/test/testsuite.c | 481 ----------------------------------- ctdb/lib/replace/tests/os2_delete.c | 115 +++++++++ ctdb/lib/replace/tests/shared_mmap.c | 68 +++++ ctdb/lib/replace/tests/testsuite.c | 481 +++++++++++++++++++++++++++++++++++ ctdb/tests/run_tests.sh | 8 + 8 files changed, 679 insertions(+), 665 deletions(-) delete mode 100644 ctdb/lib/replace/test/os2_delete.c delete mode 100644 ctdb/lib/replace/test/shared_mmap.c delete mode 100644 ctdb/lib/replace/test/testsuite.c create mode 100644 ctdb/lib/replace/tests/os2_delete.c create mode 100644 ctdb/lib/replace/tests/shared_mmap.c create mode 100644 ctdb/lib/replace/tests/testsuite.c create mode 100755 ctdb/tests/run_tests.sh diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in index 7837ff1f91..a80908c638 100644 --- a/ctdb/Makefile.in +++ b/ctdb/Makefile.in @@ -105,12 +105,18 @@ distclean: clean rm -f config.log config.status config.cache config.h rm -f Makefile -install: +install: all mkdir -p $(bindir) mkdir -p $(includedir) cp $(BINS) $(bindir) cp $(srcdir)/include/ctdb.h $(includedir) +test: + tests/run_tests.sh + +valgrindtest: + VALGRIND="valgrind -q --trace-children=yes" tests/run_tests.sh + realdistclean: distclean rm -f configure config.h.in diff --git a/ctdb/lib/replace/test/os2_delete.c b/ctdb/lib/replace/test/os2_delete.c deleted file mode 100644 index c8abfccff9..0000000000 --- a/ctdb/lib/replace/test/os2_delete.c +++ /dev/null @@ -1,115 +0,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" - -static int test_readdir_os2_delete_ret; - -#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)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files(void) -{ - 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); - - fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return test_readdir_os2_delete_ret; -} diff --git a/ctdb/lib/replace/test/shared_mmap.c b/ctdb/lib/replace/test/shared_mmap.c deleted file mode 100644 index 50dad8d696..0000000000 --- a/ctdb/lib/replace/test/shared_mmap.c +++ /dev/null @@ -1,68 +0,0 @@ -/* this tests whether we can use a shared writeable mmap on a file - - as needed for the mmap variant of FAST_SHARE_MODES */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include - -#define DATA "conftest.mmap" - -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif - -main() -{ - int *buf; - int i; - int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); - int count=7; - - if (fd == -1) exit(1); - - for (i=0;i<10000;i++) { - write(fd,&i,sizeof(i)); - } - - close(fd); - - if (fork() == 0) { - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - while (count-- && buf[9124] != 55732) sleep(1); - - if (count <= 0) exit(1); - - buf[1763] = 7268; - exit(0); - } - - fd = open(DATA,O_RDWR); - 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) exit(1); - - buf[9124] = 55732; - - while (count-- && buf[1763] != 7268) sleep(1); - - unlink(DATA); - - if (count > 0) exit(0); - exit(1); -} diff --git a/ctdb/lib/replace/test/testsuite.c b/ctdb/lib/replace/test/testsuite.c deleted file mode 100644 index effbdb13ef..0000000000 --- a/ctdb/lib/replace/test/testsuite.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - libreplace tests - - Copyright (C) Jelmer Vernooij 2006 - - ** NOTE! The following LGPL license applies to the talloc - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "replace.h" - -/* - we include all the system/ include files here so that libreplace tests - them in the build farm -*/ -#include "system/capability.h" -#include "system/dir.h" -#include "system/filesys.h" -#include "system/glob.h" -#include "system/iconv.h" -#include "system/locale.h" -#include "system/network.h" -#include "system/passwd.h" -#include "system/printing.h" -#include "system/readline.h" -#include "system/select.h" -#include "system/shmem.h" -#include "system/syslog.h" -#include "system/terminal.h" -#include "system/time.h" -#include "system/wait.h" -#include "system/aio.h" - -#define TESTFILE "testfile.dat" - -/* - test ftruncate() function - */ -static int test_ftruncate(void) -{ - struct stat st; - int fd; - const int size = 1234; - printf("test: ftruncate\n"); - unlink(TESTFILE); - fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); - if (fd == -1) { - printf("failure: ftruncate [\n" - "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); - return false; - } - if (ftruncate(fd, size) != 0) { - printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); - return false; - } - if (fstat(fd, &st) != 0) { - printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); - return false; - } - if (st.st_size != size) { - printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", - (int)st.st_size, size); - return false; - } - unlink(TESTFILE); - printf("success: ftruncate\n"); - return true; -} - -/* - test strlcpy() function. - see http://www.gratisoft.us/todd/papers/strlcpy.html - */ -static int test_strlcpy(void) -{ - char buf[4]; - const struct { - const char *src; - size_t result; - } tests[] = { - { "abc", 3 }, - { "abcdef", 6 }, - { "abcd", 4 }, - { "", 0 }, - { NULL, 0 } - }; - int i; - printf("test: strlcpy\n"); - for (i=0;tests[i].src;i++) { - if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("failure: strlcpy [\ntest %d failed\n]\n", i); - return false; - } - } - printf("success: strlcpy\n"); - return true; -} - -static int test_strlcat(void) -{ - /* FIXME */ - return true; -} - -static int test_mktime(void) -{ - /* FIXME */ - return true; -} - -static int test_innetgr(void) -{ - /* FIXME */ - return true; -} - -static int test_initgroups(void) -{ - /* FIXME */ - return true; -} - -static int test_memmove(void) -{ - /* FIXME */ - return true; -} - -static int test_strdup(void) -{ - /* FIXME */ - return true; -} - -static int test_setlinebuf(void) -{ - printf("test: setlinebuf\n"); - setlinebuf(stdout); - printf("success: setlinebuf\n"); - return true; -} - -static int test_vsyslog(void) -{ - /* FIXME */ - return true; -} - -static int test_timegm(void) -{ - /* FIXME */ - return true; -} - -static int test_setenv(void) -{ - /* FIXME */ - return true; -} - -static int test_strndup(void) -{ - /* FIXME */ - return true; -} - -static int test_strnlen(void) -{ - /* FIXME */ - return true; -} - -static int test_waitpid(void) -{ - /* FIXME */ - return true; -} - -static int test_seteuid(void) -{ - /* FIXME */ - return true; -} - -static int test_setegid(void) -{ - /* FIXME */ - return true; -} - -static int test_asprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_snprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_vasprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_vsnprintf(void) -{ - /* FIXME */ - return true; -} - -static int test_opendir(void) -{ - /* FIXME */ - return true; -} - -extern int test_readdir_os2_delete(void); - -static int test_readdir(void) -{ - printf("test: readdir\n"); - if (test_readdir_os2_delete() != 0) { - return false; - } - printf("success: readdir\n"); - return true; -} - -static int test_telldir(void) -{ - /* FIXME */ - return true; -} - -static int test_seekdir(void) -{ - /* FIXME */ - return true; -} - -static int test_dlopen(void) -{ - /* FIXME: test dlopen, dlsym, dlclose, dlerror */ - return true; -} - - -static int test_chroot(void) -{ - /* FIXME: chroot() */ - return true; -} - -static int test_bzero(void) -{ - /* FIXME: bzero */ - return true; -} - -static int test_strerror(void) -{ - /* FIXME */ - return true; -} - -static int test_errno(void) -{ - /* FIXME */ - return true; -} - -static int test_mkdtemp(void) -{ - /* FIXME */ - return true; -} - -static int test_mkstemp(void) -{ - /* FIXME */ - return true; -} - -static int test_pread(void) -{ - /* FIXME */ - return true; -} - -static int test_pwrite(void) -{ - /* FIXME */ - return true; -} - -static int test_getpass(void) -{ - /* FIXME */ - return true; -} - -static int test_inet_ntoa(void) -{ - /* FIXME */ - return true; -} - -static int test_strtoll(void) -{ - /* FIXME */ - return true; -} - -static int test_strtoull(void) -{ - /* FIXME */ - return true; -} - -/* -FIXME: -Types: -bool -socklen_t -uint_t -uint{8,16,32,64}_t -int{8,16,32,64}_t -intptr_t - -Constants: -PATH_NAME_MAX -UINT{16,32,64}_MAX -INT32_MAX -*/ - -static int test_va_copy(void) -{ - /* FIXME */ - return true; -} - -static int test_FUNCTION(void) -{ - /* FIXME: test __FUNCTION__ macro */ - return true; -} - -static int test_MIN(void) -{ - /* FIXME */ - return true; -} - -static int test_MAX(void) -{ - /* FIXME */ - return true; -} - -static int test_socketpair(void) -{ - int sock[2]; - char buf[20]; - - printf("test: socketpair\n"); - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) { - printf("failure: socketpair [\n" - "socketpair() failed\n" - "]\n"); - return false; - } - - if (write(sock[1], "automatisch", 12) == -1) { - printf("failure: socketpair [\n" - "write() failed: %s\n" - "]\n", strerror(errno)); - return false; - } - - if (read(sock[0], buf, 12) == -1) { - printf("failure: socketpair [\n" - "read() failed: %s\n" - "]\n", strerror(errno)); - return false; - } - - if (strcmp(buf, "automatisch") != 0) { - printf("failure: socketpair [\n" - "expected: automatisch, got: %s\n" - "]\n", buf); - return false; - } - - printf("success: socketpair\n"); - - return true; -} - -struct torture_context; -bool torture_local_replace(struct torture_context *ctx) -{ - bool ret = true; - ret &= test_ftruncate(); - ret &= test_strlcpy(); - ret &= test_strlcat(); - ret &= test_mktime(); - ret &= test_innetgr(); - ret &= test_initgroups(); - ret &= test_memmove(); - ret &= test_strdup(); - ret &= test_setlinebuf(); - ret &= test_vsyslog(); - ret &= test_timegm(); - ret &= test_setenv(); - ret &= test_strndup(); - ret &= test_strnlen(); - ret &= test_waitpid(); - ret &= test_seteuid(); - ret &= test_setegid(); - ret &= test_asprintf(); - ret &= test_snprintf(); - ret &= test_vasprintf(); - ret &= test_vsnprintf(); - ret &= test_opendir(); - ret &= test_readdir(); - ret &= test_telldir(); - ret &= test_seekdir(); - ret &= test_dlopen(); - ret &= test_chroot(); - ret &= test_bzero(); - ret &= test_strerror(); - ret &= test_errno(); - ret &= test_mkdtemp(); - ret &= test_mkstemp(); - ret &= test_pread(); - ret &= test_pwrite(); - ret &= test_getpass(); - ret &= test_inet_ntoa(); - ret &= test_strtoll(); - ret &= test_strtoll(); - ret &= test_strtoull(); - ret &= test_va_copy(); - ret &= test_FUNCTION(); - ret &= test_MIN(); - ret &= test_MAX(); - ret &= test_socketpair(); - - return ret; -} - -#if _SAMBA_BUILD_<4 -int main(void) -{ - bool ret = torture_local_replace(NULL); - if (ret) - return 0; - return -1; -} -#endif diff --git a/ctdb/lib/replace/tests/os2_delete.c b/ctdb/lib/replace/tests/os2_delete.c new file mode 100644 index 0000000000..c8abfccff9 --- /dev/null +++ b/ctdb/lib/replace/tests/os2_delete.c @@ -0,0 +1,115 @@ +/* + 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" + +static int test_readdir_os2_delete_ret; + +#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)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files(void) +{ + 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); + + fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return test_readdir_os2_delete_ret; +} diff --git a/ctdb/lib/replace/tests/shared_mmap.c b/ctdb/lib/replace/tests/shared_mmap.c new file mode 100644 index 0000000000..50dad8d696 --- /dev/null +++ b/ctdb/lib/replace/tests/shared_mmap.c @@ -0,0 +1,68 @@ +/* this tests whether we can use a shared writeable mmap on a file - + as needed for the mmap variant of FAST_SHARE_MODES */ + +#if defined(HAVE_UNISTD_H) +#include +#endif +#include +#include +#include +#include + +#define DATA "conftest.mmap" + +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + +main() +{ + int *buf; + int i; + int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); + int count=7; + + if (fd == -1) exit(1); + + for (i=0;i<10000;i++) { + write(fd,&i,sizeof(i)); + } + + close(fd); + + if (fork() == 0) { + fd = open(DATA,O_RDWR); + if (fd == -1) exit(1); + + buf = (int *)mmap(NULL, 10000*sizeof(int), + (PROT_READ | PROT_WRITE), + MAP_FILE | MAP_SHARED, + fd, 0); + + while (count-- && buf[9124] != 55732) sleep(1); + + if (count <= 0) exit(1); + + buf[1763] = 7268; + exit(0); + } + + fd = open(DATA,O_RDWR); + 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) exit(1); + + buf[9124] = 55732; + + while (count-- && buf[1763] != 7268) sleep(1); + + unlink(DATA); + + if (count > 0) exit(0); + exit(1); +} diff --git a/ctdb/lib/replace/tests/testsuite.c b/ctdb/lib/replace/tests/testsuite.c new file mode 100644 index 0000000000..effbdb13ef --- /dev/null +++ b/ctdb/lib/replace/tests/testsuite.c @@ -0,0 +1,481 @@ +/* + Unix SMB/CIFS implementation. + + libreplace tests + + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "replace.h" + +/* + we include all the system/ include files here so that libreplace tests + them in the build farm +*/ +#include "system/capability.h" +#include "system/dir.h" +#include "system/filesys.h" +#include "system/glob.h" +#include "system/iconv.h" +#include "system/locale.h" +#include "system/network.h" +#include "system/passwd.h" +#include "system/printing.h" +#include "system/readline.h" +#include "system/select.h" +#include "system/shmem.h" +#include "system/syslog.h" +#include "system/terminal.h" +#include "system/time.h" +#include "system/wait.h" +#include "system/aio.h" + +#define TESTFILE "testfile.dat" + +/* + test ftruncate() function + */ +static int test_ftruncate(void) +{ + struct stat st; + int fd; + const int size = 1234; + printf("test: ftruncate\n"); + unlink(TESTFILE); + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: ftruncate [\n" + "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); + return false; + } + if (ftruncate(fd, size) != 0) { + printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); + return false; + } + if (fstat(fd, &st) != 0) { + printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); + return false; + } + if (st.st_size != size) { + printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", + (int)st.st_size, size); + return false; + } + unlink(TESTFILE); + printf("success: ftruncate\n"); + return true; +} + +/* + test strlcpy() function. + see http://www.gratisoft.us/todd/papers/strlcpy.html + */ +static int test_strlcpy(void) +{ + char buf[4]; + const struct { + const char *src; + size_t result; + } tests[] = { + { "abc", 3 }, + { "abcdef", 6 }, + { "abcd", 4 }, + { "", 0 }, + { NULL, 0 } + }; + int i; + printf("test: strlcpy\n"); + for (i=0;tests[i].src;i++) { + if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { + printf("failure: strlcpy [\ntest %d failed\n]\n", i); + return false; + } + } + printf("success: strlcpy\n"); + return true; +} + +static int test_strlcat(void) +{ + /* FIXME */ + return true; +} + +static int test_mktime(void) +{ + /* FIXME */ + return true; +} + +static int test_innetgr(void) +{ + /* FIXME */ + return true; +} + +static int test_initgroups(void) +{ + /* FIXME */ + return true; +} + +static int test_memmove(void) +{ + /* FIXME */ + return true; +} + +static int test_strdup(void) +{ + /* FIXME */ + return true; +} + +static int test_setlinebuf(void) +{ + printf("test: setlinebuf\n"); + setlinebuf(stdout); + printf("success: setlinebuf\n"); + return true; +} + +static int test_vsyslog(void) +{ + /* FIXME */ + return true; +} + +static int test_timegm(void) +{ + /* FIXME */ + return true; +} + +static int test_setenv(void) +{ + /* FIXME */ + return true; +} + +static int test_strndup(void) +{ + /* FIXME */ + return true; +} + +static int test_strnlen(void) +{ + /* FIXME */ + return true; +} + +static int test_waitpid(void) +{ + /* FIXME */ + return true; +} + +static int test_seteuid(void) +{ + /* FIXME */ + return true; +} + +static int test_setegid(void) +{ + /* FIXME */ + return true; +} + +static int test_asprintf(void) +{ + /* FIXME */ + return true; +} + +static int test_snprintf(void) +{ + /* FIXME */ + return true; +} + +static int test_vasprintf(void) +{ + /* FIXME */ + return true; +} + +static int test_vsnprintf(void) +{ + /* FIXME */ + return true; +} + +static int test_opendir(void) +{ + /* FIXME */ + return true; +} + +extern int test_readdir_os2_delete(void); + +static int test_readdir(void) +{ + printf("test: readdir\n"); + if (test_readdir_os2_delete() != 0) { + return false; + } + printf("success: readdir\n"); + return true; +} + +static int test_telldir(void) +{ + /* FIXME */ + return true; +} + +static int test_seekdir(void) +{ + /* FIXME */ + return true; +} + +static int test_dlopen(void) +{ + /* FIXME: test dlopen, dlsym, dlclose, dlerror */ + return true; +} + + +static int test_chroot(void) +{ + /* FIXME: chroot() */ + return true; +} + +static int test_bzero(void) +{ + /* FIXME: bzero */ + return true; +} + +static int test_strerror(void) +{ + /* FIXME */ + return true; +} + +static int test_errno(void) +{ + /* FIXME */ + return true; +} + +static int test_mkdtemp(void) +{ + /* FIXME */ + return true; +} + +static int test_mkstemp(void) +{ + /* FIXME */ + return true; +} + +static int test_pread(void) +{ + /* FIXME */ + return true; +} + +static int test_pwrite(void) +{ + /* FIXME */ + return true; +} + +static int test_getpass(void) +{ + /* FIXME */ + return true; +} + +static int test_inet_ntoa(void) +{ + /* FIXME */ + return true; +} + +static int test_strtoll(void) +{ + /* FIXME */ + return true; +} + +static int test_strtoull(void) +{ + /* FIXME */ + return true; +} + +/* +FIXME: +Types: +bool +socklen_t +uint_t +uint{8,16,32,64}_t +int{8,16,32,64}_t +intptr_t + +Constants: +PATH_NAME_MAX +UINT{16,32,64}_MAX +INT32_MAX +*/ + +static int test_va_copy(void) +{ + /* FIXME */ + return true; +} + +static int test_FUNCTION(void) +{ + /* FIXME: test __FUNCTION__ macro */ + return true; +} + +static int test_MIN(void) +{ + /* FIXME */ + return true; +} + +static int test_MAX(void) +{ + /* FIXME */ + return true; +} + +static int test_socketpair(void) +{ + int sock[2]; + char buf[20]; + + printf("test: socketpair\n"); + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) { + printf("failure: socketpair [\n" + "socketpair() failed\n" + "]\n"); + return false; + } + + if (write(sock[1], "automatisch", 12) == -1) { + printf("failure: socketpair [\n" + "write() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (read(sock[0], buf, 12) == -1) { + printf("failure: socketpair [\n" + "read() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (strcmp(buf, "automatisch") != 0) { + printf("failure: socketpair [\n" + "expected: automatisch, got: %s\n" + "]\n", buf); + return false; + } + + printf("success: socketpair\n"); + + return true; +} + +struct torture_context; +bool torture_local_replace(struct torture_context *ctx) +{ + bool ret = true; + ret &= test_ftruncate(); + ret &= test_strlcpy(); + ret &= test_strlcat(); + ret &= test_mktime(); + ret &= test_innetgr(); + ret &= test_initgroups(); + ret &= test_memmove(); + ret &= test_strdup(); + ret &= test_setlinebuf(); + ret &= test_vsyslog(); + ret &= test_timegm(); + ret &= test_setenv(); + ret &= test_strndup(); + ret &= test_strnlen(); + ret &= test_waitpid(); + ret &= test_seteuid(); + ret &= test_setegid(); + ret &= test_asprintf(); + ret &= test_snprintf(); + ret &= test_vasprintf(); + ret &= test_vsnprintf(); + ret &= test_opendir(); + ret &= test_readdir(); + ret &= test_telldir(); + ret &= test_seekdir(); + ret &= test_dlopen(); + ret &= test_chroot(); + ret &= test_bzero(); + ret &= test_strerror(); + ret &= test_errno(); + ret &= test_mkdtemp(); + ret &= test_mkstemp(); + ret &= test_pread(); + ret &= test_pwrite(); + ret &= test_getpass(); + ret &= test_inet_ntoa(); + ret &= test_strtoll(); + ret &= test_strtoll(); + ret &= test_strtoull(); + ret &= test_va_copy(); + ret &= test_FUNCTION(); + ret &= test_MIN(); + ret &= test_MAX(); + ret &= test_socketpair(); + + return ret; +} + +#if _SAMBA_BUILD_<4 +int main(void) +{ + bool ret = torture_local_replace(NULL); + if (ret) + return 0; + return -1; +} +#endif diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh new file mode 100755 index 0000000000..983afa0adb --- /dev/null +++ b/ctdb/tests/run_tests.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +tests/fetch.sh || exit 1 +tests/bench.sh || exit 1 +tests/test.sh || exit 1 + +echo "All OK" +exit 0 -- cgit