From 38fdde5d9bf15b10caa60ee216d278ba8d870c2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4) --- source4/lib/replace/test/testsuite.c | 366 +++++++++++++++++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 source4/lib/replace/test/testsuite.c (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c new file mode 100644 index 0000000000..2c68fd6664 --- /dev/null +++ b/source4/lib/replace/test/testsuite.c @@ -0,0 +1,366 @@ +/* + 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" +#include + +int test_ftruncate() +{ + /* FIXME */ + return true; +} + +int test_strlcpy() +{ + /* FIXME */ + return true; +} + +int test_strlcat() +{ + /* FIXME */ + return true; +} + +int test_mktime() +{ + /* FIXME */ + return true; +} + +int test_rename() +{ + /* FIXME */ + return true; +} + +int test_innetgr() +{ + /* FIXME */ + return true; +} + +int test_initgroups() +{ + /* FIXME */ + return true; +} + +int test_memmove() +{ + /* FIXME */ + return true; +} + +int test_strdup() +{ + /* FIXME */ + return true; +} + +int test_setlinebuf() +{ + /* FIXME */ + return true; +} + +int test_vsyslog() +{ + /* FIXME */ + return true; +} + +int test_timegm() +{ + /* FIXME */ + return true; +} + +int test_setenv() +{ + /* FIXME */ + return true; +} + +int test_strndup() +{ + /* FIXME */ + return true; +} + +int test_strnlen() +{ + /* FIXME */ + return true; +} + +int test_waitpid() +{ + /* FIXME */ + return true; +} + +int test_seteuid() +{ + /* FIXME */ + return true; +} + +int test_setegid() +{ + /* FIXME */ + return true; +} + +int test_asprintf() +{ + /* FIXME */ + return true; +} + +int test_snprintf() +{ + /* FIXME */ + return true; +} + +int test_vasprintf() +{ + /* FIXME */ + return true; +} + +int test_vsnprintf() +{ + /* FIXME */ + return true; +} + +int test_opendir() +{ + /* FIXME */ + return true; +} + +int test_readdir() +{ + /* FIXME */ + return true; +} + +int test_telldir() +{ + /* FIXME */ + return true; +} + +int test_seekdir() +{ + /* FIXME */ + return true; +} + +int test_dlopen() +{ + /* FIXME: test dlopen, dlsym, dlclose, dlerror */ + return true; +} + + +int test_chroot() +{ + /* FIXME: chroot() */ + return true; +} + +int test_bzero() +{ + /* FIXME: bzero */ + return true; +} + +int test_strerror() +{ + /* FIXME */ + return true; +} + +int test_errno() +{ + /* FIXME */ + return true; +} + +int test_mkdtemp() +{ + /* FIXME */ + return true; +} + +int test_mkstemp() +{ + /* FIXME */ + return true; +} + +int test_pread() +{ + /* FIXME */ + return true; +} + +int test_pwrite() +{ + /* FIXME */ + return true; +} + +int test_getpass() +{ + /* FIXME */ + return true; +} + +int test_inet_ntoa() +{ + /* FIXME */ + return true; +} + +int test_strtoll() +{ + /* FIXME */ + return true; +} + +int test_strtoull() +{ + /* 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 +*/ + +int test_va_copy() +{ + /* FIXME */ + return true; +} + +int test_FUNCTION() +{ + /* FIXME: test __FUNCTION__ macro */ + return true; +} + +int test_MIN() +{ + /* FIXME */ + return true; +} + +int test_MAX() +{ + /* FIXME */ + return true; +} + +int torture_local_replace() +{ + int ret = true; +; + ret &= test_ftruncate(); + ret &= test_strlcpy(); + ret &= test_strlcat(); + ret &= test_mktime(); + ret &= test_rename(); + 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(); + + return ret; +} + +#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) +int main(void) +{ + if (!torture_local_replace(NULL)) { + printf("ERROR: TESTSUITE FAILED\n"); + return -1; + } + return 0; +} +#endif -- cgit From 6cf5528e20685585d4d1e3b779088f488f664273 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:57:40 +0000 Subject: r18038: make test fns static (This used to be commit 2dda101a5fcc40702df9fa2f932d6fe97ae64163) --- source4/lib/replace/test/testsuite.c | 86 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 2c68fd6664..83da05ce45 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,236 +27,236 @@ #include "../replace.h" #include -int test_ftruncate() +static int test_ftruncate() { /* FIXME */ return true; } -int test_strlcpy() +static int test_strlcpy() { /* FIXME */ return true; } -int test_strlcat() +static int test_strlcat() { /* FIXME */ return true; } -int test_mktime() +static int test_mktime() { /* FIXME */ return true; } -int test_rename() +static int test_rename() { /* FIXME */ return true; } -int test_innetgr() +static int test_innetgr() { /* FIXME */ return true; } -int test_initgroups() +static int test_initgroups() { /* FIXME */ return true; } -int test_memmove() +static int test_memmove() { /* FIXME */ return true; } -int test_strdup() +static int test_strdup() { /* FIXME */ return true; } -int test_setlinebuf() +static int test_setlinebuf() { /* FIXME */ return true; } -int test_vsyslog() +static int test_vsyslog() { /* FIXME */ return true; } -int test_timegm() +static int test_timegm() { /* FIXME */ return true; } -int test_setenv() +static int test_setenv() { /* FIXME */ return true; } -int test_strndup() +static int test_strndup() { /* FIXME */ return true; } -int test_strnlen() +static int test_strnlen() { /* FIXME */ return true; } -int test_waitpid() +static int test_waitpid() { /* FIXME */ return true; } -int test_seteuid() +static int test_seteuid() { /* FIXME */ return true; } -int test_setegid() +static int test_setegid() { /* FIXME */ return true; } -int test_asprintf() +static int test_asprintf() { /* FIXME */ return true; } -int test_snprintf() +static int test_snprintf() { /* FIXME */ return true; } -int test_vasprintf() +static int test_vasprintf() { /* FIXME */ return true; } -int test_vsnprintf() +static int test_vsnprintf() { /* FIXME */ return true; } -int test_opendir() +static int test_opendir() { /* FIXME */ return true; } -int test_readdir() +static int test_readdir() { /* FIXME */ return true; } -int test_telldir() +static int test_telldir() { /* FIXME */ return true; } -int test_seekdir() +static int test_seekdir() { /* FIXME */ return true; } -int test_dlopen() +static int test_dlopen() { /* FIXME: test dlopen, dlsym, dlclose, dlerror */ return true; } -int test_chroot() +static int test_chroot() { /* FIXME: chroot() */ return true; } -int test_bzero() +static int test_bzero() { /* FIXME: bzero */ return true; } -int test_strerror() +static int test_strerror() { /* FIXME */ return true; } -int test_errno() +static int test_errno() { /* FIXME */ return true; } -int test_mkdtemp() +static int test_mkdtemp() { /* FIXME */ return true; } -int test_mkstemp() +static int test_mkstemp() { /* FIXME */ return true; } -int test_pread() +static int test_pread() { /* FIXME */ return true; } -int test_pwrite() +static int test_pwrite() { /* FIXME */ return true; } -int test_getpass() +static int test_getpass() { /* FIXME */ return true; } -int test_inet_ntoa() +static int test_inet_ntoa() { /* FIXME */ return true; } -int test_strtoll() +static int test_strtoll() { /* FIXME */ return true; } -int test_strtoull() +static int test_strtoull() { /* FIXME */ return true; @@ -278,25 +278,25 @@ UINT{16,32,64}_MAX INT32_MAX */ -int test_va_copy() +static int test_va_copy() { /* FIXME */ return true; } -int test_FUNCTION() +static int test_FUNCTION() { /* FIXME: test __FUNCTION__ macro */ return true; } -int test_MIN() +static int test_MIN() { /* FIXME */ return true; } -int test_MAX() +static int test_MAX() { /* FIXME */ return true; -- cgit From 4c4e6a9a1c7c433095183662c673bbd48299da5c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 13:10:49 +0000 Subject: r18041: started on the bodies of the testsuite functions for libreplace (This used to be commit a2a6782ec721312e329cd16b609fb3eff8ad284d) --- source4/lib/replace/test/testsuite.c | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 83da05ce45..c00e2a788f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,9 +27,51 @@ #include "../replace.h" #include +#if HAVE_STDLIB_H +#include +#endif + +#if HAVE_TYPES_H +#include +#endif + +#if HAVE_SYS_STAT_H +#include +#endif + +#include +#include + +#define TESTFILE "testfile.dat" + +/* + test ftruncate() function + */ static int test_ftruncate() { - /* FIXME */ + struct stat st; + int fd, i; + const int size; + printf("testing ftruncate\n"); + unlink(TESTFILE); + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno)); + return false; + } + if (ftruncate(fd, size) != 0) { + printf("ftruncate failed - %s\n", strerror(errno)); + return false; + } + if (fstat(fd, &st) != 0) { + printf("fstat failed - %s\n", strerror(errno)); + return false; + } + if (st.st_size != size) { + printf("ftruncate gave wrong size %d - expected %d\n", + (int)st.st_size, size); + return false; + } return true; } -- cgit From 73493a095ae4802cd3e1222b22321454db17b988 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 13:28:54 +0000 Subject: r18043: added strlcpy() test (This used to be commit a68b3395199d2d47af3b23959e6da7109a9c5193) --- source4/lib/replace/test/testsuite.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c00e2a788f..5d20c345f8 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -75,9 +75,31 @@ static int test_ftruncate() return true; } +/* + test strlcpy() function. + see http://www.gratisoft.us/todd/papers/strlcpy.html + */ static int test_strlcpy() { - /* FIXME */ + char buf[4]; + const struct { + const char *src; + int result; + } tests[] = { + { "abc", 3 }, + { "abcdef", 6 }, + { "abcd", 4 }, + { "", 0 }, + { NULL, 0 } + }; + int i; + printf("testing strlcpy\n"); + for (i=0;tests[i].src;i++) { + if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { + printf("strlcpy test %d failed\n"); + return false; + } + } return true; } @@ -347,7 +369,6 @@ static int test_MAX() int torture_local_replace() { int ret = true; -; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); -- cgit From c13ea9b3a6601406d29c5970734891fbc7eccaac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 13:47:57 +0000 Subject: r18045: Update format, list "test" target as phony. (This used to be commit 1f431dcd0a1f9a2cd5a0a3b73fbf8b05b8bc6793) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5d20c345f8..998715f63f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -96,7 +96,7 @@ static int test_strlcpy() printf("testing strlcpy\n"); for (i=0;tests[i].src;i++) { if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("strlcpy test %d failed\n"); + printf("strlcpy test %d failed\n", i); return false; } } -- cgit From a0202040e2b99117e6307e886fd08401330d20f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 22:49:30 +0000 Subject: r18051: - add gcc warning flags - fix piles of warnings and ftruncate bug in libreplace testsuite (This used to be commit f5fc88f0c4c752a2773d5280ed4d94818e2d4744) --- source4/lib/replace/test/testsuite.c | 100 +++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 46 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 998715f63f..0dad3de9db 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -39,6 +39,14 @@ #include #endif +#if HAVE_UNISTD_H +#include +#endif + +#if HAVE_STRING_H +#include +#endif + #include #include @@ -47,11 +55,11 @@ /* test ftruncate() function */ -static int test_ftruncate() +static int test_ftruncate(void) { struct stat st; - int fd, i; - const int size; + int fd; + const int size = 1234; printf("testing ftruncate\n"); unlink(TESTFILE); fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); @@ -79,7 +87,7 @@ static int test_ftruncate() test strlcpy() function. see http://www.gratisoft.us/todd/papers/strlcpy.html */ -static int test_strlcpy() +static int test_strlcpy(void) { char buf[4]; const struct { @@ -103,224 +111,224 @@ static int test_strlcpy() return true; } -static int test_strlcat() +static int test_strlcat(void) { /* FIXME */ return true; } -static int test_mktime() +static int test_mktime(void) { /* FIXME */ return true; } -static int test_rename() +static int test_rename(void) { /* FIXME */ return true; } -static int test_innetgr() +static int test_innetgr(void) { /* FIXME */ return true; } -static int test_initgroups() +static int test_initgroups(void) { /* FIXME */ return true; } -static int test_memmove() +static int test_memmove(void) { /* FIXME */ return true; } -static int test_strdup() +static int test_strdup(void) { /* FIXME */ return true; } -static int test_setlinebuf() +static int test_setlinebuf(void) { /* FIXME */ return true; } -static int test_vsyslog() +static int test_vsyslog(void) { /* FIXME */ return true; } -static int test_timegm() +static int test_timegm(void) { /* FIXME */ return true; } -static int test_setenv() +static int test_setenv(void) { /* FIXME */ return true; } -static int test_strndup() +static int test_strndup(void) { /* FIXME */ return true; } -static int test_strnlen() +static int test_strnlen(void) { /* FIXME */ return true; } -static int test_waitpid() +static int test_waitpid(void) { /* FIXME */ return true; } -static int test_seteuid() +static int test_seteuid(void) { /* FIXME */ return true; } -static int test_setegid() +static int test_setegid(void) { /* FIXME */ return true; } -static int test_asprintf() +static int test_asprintf(void) { /* FIXME */ return true; } -static int test_snprintf() +static int test_snprintf(void) { /* FIXME */ return true; } -static int test_vasprintf() +static int test_vasprintf(void) { /* FIXME */ return true; } -static int test_vsnprintf() +static int test_vsnprintf(void) { /* FIXME */ return true; } -static int test_opendir() +static int test_opendir(void) { /* FIXME */ return true; } -static int test_readdir() +static int test_readdir(void) { /* FIXME */ return true; } -static int test_telldir() +static int test_telldir(void) { /* FIXME */ return true; } -static int test_seekdir() +static int test_seekdir(void) { /* FIXME */ return true; } -static int test_dlopen() +static int test_dlopen(void) { /* FIXME: test dlopen, dlsym, dlclose, dlerror */ return true; } -static int test_chroot() +static int test_chroot(void) { /* FIXME: chroot() */ return true; } -static int test_bzero() +static int test_bzero(void) { /* FIXME: bzero */ return true; } -static int test_strerror() +static int test_strerror(void) { /* FIXME */ return true; } -static int test_errno() +static int test_errno(void) { /* FIXME */ return true; } -static int test_mkdtemp() +static int test_mkdtemp(void) { /* FIXME */ return true; } -static int test_mkstemp() +static int test_mkstemp(void) { /* FIXME */ return true; } -static int test_pread() +static int test_pread(void) { /* FIXME */ return true; } -static int test_pwrite() +static int test_pwrite(void) { /* FIXME */ return true; } -static int test_getpass() +static int test_getpass(void) { /* FIXME */ return true; } -static int test_inet_ntoa() +static int test_inet_ntoa(void) { /* FIXME */ return true; } -static int test_strtoll() +static int test_strtoll(void) { /* FIXME */ return true; } -static int test_strtoull() +static int test_strtoull(void) { /* FIXME */ return true; @@ -342,31 +350,31 @@ UINT{16,32,64}_MAX INT32_MAX */ -static int test_va_copy() +static int test_va_copy(void) { /* FIXME */ return true; } -static int test_FUNCTION() +static int test_FUNCTION(void) { /* FIXME: test __FUNCTION__ macro */ return true; } -static int test_MIN() +static int test_MIN(void) { /* FIXME */ return true; } -static int test_MAX() +static int test_MAX(void) { /* FIXME */ return true; } -int torture_local_replace() +int torture_local_replace(void *ctx) { int ret = true; ret &= test_ftruncate(); -- cgit From a41abfd514ae2259207b3cb90b8bc76434164b91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:48:01 +0000 Subject: r18059: another cpp error (This used to be commit 64eff9d9d998ec2fd3d75393eb57028dfb942acf) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 0dad3de9db..af50edc2a3 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -31,7 +31,7 @@ #include #endif -#if HAVE_TYPES_H +#if HAVE_SYS_TYPES_H #include #endif -- cgit From a983b06d37c3b87a02444d9a9862777b88629344 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 04:44:32 +0000 Subject: r18129: moved the system includes into libreplace - this gives much more isolation of our portability environment from the main code, and also simplifies the includes system (no separate #ifdef _SAMBA_BUILD for tdb. ldb etc now) (This used to be commit 77d1a468e06290aba789e2f3affc769fc5159a21) --- source4/lib/replace/test/testsuite.c | 45 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index af50edc2a3..9dddc017be 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -24,31 +24,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../replace.h" -#include +#include "replace.h" -#if HAVE_STDLIB_H -#include -#endif - -#if HAVE_SYS_TYPES_H -#include -#endif - -#if HAVE_SYS_STAT_H -#include -#endif - -#if HAVE_UNISTD_H -#include -#endif - -#if HAVE_STRING_H -#include -#endif - -#include -#include +/* + we include all the system/*.h 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" #define TESTFILE "testfile.dat" -- cgit From 90f485eecd86490ba03fb3b46fef00f9d0c6c6b1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:20:29 +0000 Subject: r18141: an accidental nested C comment! (This used to be commit 47c305c7dc5d2b2b61afe9f42f77ee3652c61a79) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 9dddc017be..ddc9550f61 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,7 +27,7 @@ #include "replace.h" /* - we include all the system/*.h include files here so that libreplace tests + we include all the system/ include files here so that libreplace tests them in the build farm */ #include "system/capability.h" -- cgit From 3ca73facc59ed8a97abbc28c1b4bedde87e109a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 11:31:59 +0000 Subject: r18160: - pread and pwrite replacements need to be non-static - replacing rename() is pointless - all platforms have it (and the #define of rename breaks some code) - use system/locale.h in snprintf.c - fix passwd.h for initgroups - stdlib is in replace.h, not needed elsewhere - fix the initgroups replacement - fix mapping of dl functions to rep_* (This used to be commit 57cd0ca176387d6a3acabf9fedeef4f2a3a3dad7) --- source4/lib/replace/test/testsuite.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index ddc9550f61..33270d9a4a 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -120,12 +120,6 @@ static int test_mktime(void) return true; } -static int test_rename(void) -{ - /* FIXME */ - return true; -} - static int test_innetgr(void) { /* FIXME */ @@ -378,7 +372,6 @@ int torture_local_replace(void *ctx) ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); - ret &= test_rename(); ret &= test_innetgr(); ret &= test_initgroups(); ret &= test_memmove(); -- cgit From a8421e81078b91ae97ada3be352416eae26a9c7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 14:19:38 +0000 Subject: r18343: fixed setlinebuf() prototype, added test for it, and use it in two places to avoid a #ifdef (This used to be commit 095b8057740a4bb207e24e4c63a2dcb53521a72f) --- source4/lib/replace/test/testsuite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 33270d9a4a..89d2ae6a88 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -146,7 +146,8 @@ static int test_strdup(void) static int test_setlinebuf(void) { - /* FIXME */ + printf("testing setlinebuf\n"); + setlinebuf(stdout); return true; } -- 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/testsuite.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 89d2ae6a88..6644fce6bd 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -229,8 +229,15 @@ static int test_opendir(void) return true; } -static int test_readdir(void) +extern int test_readdir_os2_delete(void); + +static bool test_readdir(void) { + printf("testing readdir\n"); + if (test_readdir_os2_delete() != 0) { + return false; + } + /* FIXME */ return true; } -- cgit From 6ddc797e3a6a5852c0d587ed1206f84e95b54210 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 10:35:40 +0000 Subject: r19033: prepare to use the libreplace testsuite as LOCAL-REPLACE in smbtorture metze (This used to be commit 71fc73e11cee89f1b52cda5a32468a74a38cecc3) --- source4/lib/replace/test/testsuite.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 6644fce6bd..fa5265f66f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -89,7 +89,7 @@ static int test_strlcpy(void) char buf[4]; const struct { const char *src; - int result; + size_t result; } tests[] = { { "abc", 3 }, { "abcdef", 6 }, @@ -373,9 +373,11 @@ static int test_MAX(void) return true; } -int torture_local_replace(void *ctx) +struct torture_context; + +bool torture_local_replace(struct torture_context *torture) { - int ret = true; + bool ret = true; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); @@ -423,7 +425,7 @@ int torture_local_replace(void *ctx) return ret; } -#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) +#if _SAMBA_BUILD_<4 int main(void) { if (!torture_local_replace(NULL)) { -- cgit From 0f60472cb24b03b59114e5dc03918b75c652cb08 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 6 Oct 2006 07:44:36 +0000 Subject: r19116: fixed a checker warning (This used to be commit 48243721df27fa68b3232d71b411fba1e0ab7010) --- source4/lib/replace/test/testsuite.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index fa5265f66f..d45304103f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -231,14 +231,12 @@ static int test_opendir(void) extern int test_readdir_os2_delete(void); -static bool test_readdir(void) +static int test_readdir(void) { printf("testing readdir\n"); if (test_readdir_os2_delete() != 0) { return false; } - - /* FIXME */ return true; } @@ -400,7 +398,7 @@ bool torture_local_replace(struct torture_context *torture) ret &= test_vasprintf(); ret &= test_vsnprintf(); ret &= test_opendir(); - ret &= test_readdir() ; + ret &= test_readdir(); ret &= test_telldir(); ret &= test_seekdir(); ret &= test_dlopen(); -- 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/testsuite.c | 40 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index d45304103f..3e20e22e45 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -57,26 +57,28 @@ static int test_ftruncate(void) struct stat st; int fd; const int size = 1234; - printf("testing ftruncate\n"); + printf("test: ftruncate\n"); unlink(TESTFILE); fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); if (fd == -1) { - printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno)); + printf("failure: ftruncate [\n" + "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); return false; } if (ftruncate(fd, size) != 0) { - printf("ftruncate failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); return false; } if (fstat(fd, &st) != 0) { - printf("fstat failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); return false; } if (st.st_size != size) { - printf("ftruncate gave wrong size %d - expected %d\n", + printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", (int)st.st_size, size); return false; } + printf("success: ftruncate\n"); return true; } @@ -98,13 +100,14 @@ static int test_strlcpy(void) { NULL, 0 } }; int i; - printf("testing strlcpy\n"); + printf("test: strlcpy\n"); for (i=0;tests[i].src;i++) { if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("strlcpy test %d failed\n", i); + printf("failure: strlcpy [\ntest %d failed\n]\n", i); return false; } } + printf("success: strlcpy\n"); return true; } @@ -146,8 +149,9 @@ static int test_strdup(void) static int test_setlinebuf(void) { - printf("testing setlinebuf\n"); + printf("test: setlinebuf\n"); setlinebuf(stdout); + printf("success: setlinebuf\n"); return true; } @@ -233,10 +237,11 @@ extern int test_readdir_os2_delete(void); static int test_readdir(void) { - printf("testing readdir\n"); + printf("test: readdir\n"); if (test_readdir_os2_delete() != 0) { return false; } + printf("success: readdir\n"); return true; } @@ -373,7 +378,7 @@ static int test_MAX(void) struct torture_context; -bool torture_local_replace(struct torture_context *torture) +int main() { bool ret = true; ret &= test_ftruncate(); @@ -420,16 +425,7 @@ bool torture_local_replace(struct torture_context *torture) ret &= test_MIN(); ret &= test_MAX(); - return ret; + if (ret) + return 0; + return -1; } - -#if _SAMBA_BUILD_<4 -int main(void) -{ - if (!torture_local_replace(NULL)) { - printf("ERROR: TESTSUITE FAILED\n"); - return -1; - } - return 0; -} -#endif -- cgit From f9a0ada725b012261ec9460185105f57206c70c3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 16:08:22 +0000 Subject: r19393: Add replacement function for socketpair() (This used to be commit 448a3ecc0184bfa063db1eb3ae6dc16b8b792792) --- source4/lib/replace/test/testsuite.c | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 3e20e22e45..e921a7fc97 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -376,6 +376,46 @@ static int test_MAX(void) return true; } +static bool 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[0], "automatisch", 12) == -1) { + printf("failure: socketpair [\n" + "write() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (read(sock[1], 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; int main() @@ -424,6 +464,7 @@ int main() ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); + ret &= test_socketpair(); if (ret) return 0; -- cgit From 21948f18a71d6d3de4b05f884a8cbe204c9c6fb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 08:58:55 +0000 Subject: r19410: - fixed checker error - close the sockets after the socketpair test (This used to be commit e679163ac26dccee028ca501e4ef6229a3c761ee) --- source4/lib/replace/test/testsuite.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index e921a7fc97..d119424362 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -376,7 +376,7 @@ static int test_MAX(void) return true; } -static bool test_socketpair(void) +static int test_socketpair(void) { int sock[2]; char buf[20]; @@ -411,6 +411,9 @@ static bool test_socketpair(void) return false; } + close(sock[0]); + close(sock[1]); + printf("success: socketpair\n"); return true; -- cgit From c3e4b2d2782832bcb0072cd7cbb7f0f94910d4bc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 09:35:05 +0000 Subject: r19411: sigh - we can't call close here as its mapped to swrap_close() in the build farm (This used to be commit be43b8c5692f6bb6f1cc74d07f24376b43593256) --- source4/lib/replace/test/testsuite.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index d119424362..a57247377b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -411,9 +411,6 @@ static int test_socketpair(void) return false; } - close(sock[0]); - close(sock[1]); - printf("success: socketpair\n"); return true; -- cgit From bc596cf917a25569f71d7d2b72ba11f3cb34dd54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Oct 2006 14:58:05 +0000 Subject: r19495: Stop linking binaries twice (once before installation, once during build). Make TORTURE-TALLOC and TORTURE-REPLACE builtin again rather than separate binaries. (This used to be commit 8913d60c72a67b041b08d569c9bd048953106c85) --- source4/lib/replace/test/testsuite.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a57247377b..48197cf721 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -417,8 +417,7 @@ static int test_socketpair(void) } struct torture_context; - -int main() +bool torture_local_replace(struct torture_context *ctx) { bool ret = true; ret &= test_ftruncate(); @@ -466,7 +465,15 @@ int main() ret &= test_MAX(); ret &= test_socketpair(); + return ret; +} + +#ifndef _SAMBA_BUILD_ +int main() +{ + bool ret = torture_local_replace(NULL); if (ret) return 0; return -1; } +#endif -- cgit From 0c1218cbac93b1919a5c1cec28b4b716092fafc3 Mon Sep 17 00:00:00 2001 From: Paul Green Date: Wed, 29 Nov 2006 18:44:54 +0000 Subject: r19952: Fix socketpair() test case to write to fd(1) and read from fd(0) because when pipe files are substituting for unix domain sockets, pipes provide only uni-directional i/o capabilities. (This used to be commit d0a376732ed7b4f807b99a1c46c54ad1f07c85cf) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 48197cf721..a5defaf89d 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -390,14 +390,14 @@ static int test_socketpair(void) return false; } - if (write(sock[0], "automatisch", 12) == -1) { + if (write(sock[1], "automatisch", 12) == -1) { printf("failure: socketpair [\n" "write() failed: %s\n" "]\n", strerror(errno)); return false; } - if (read(sock[1], buf, 12) == -1) { + if (read(sock[0], buf, 12) == -1) { printf("failure: socketpair [\n" "read() failed: %s\n" "]\n", strerror(errno)); -- cgit From 8c75df8b2c5c2bc62ed1ef080c2f83f7ce365c09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 17:55:26 +0000 Subject: r20810: unlink the test file when the test is done metze (This used to be commit d3e10679afe436b994813e60b117bc42e6c2ed8f) --- source4/lib/replace/test/testsuite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a5defaf89d..669f825b90 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -78,6 +78,7 @@ static int test_ftruncate(void) (int)st.st_size, size); return false; } + unlink(TESTFILE); printf("success: ftruncate\n"); return true; } -- cgit From 28438101bd07a96ef5a3725660eb43b486a0eae0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 19:05:11 +0000 Subject: r20815: merge from samba3 metze (This used to be commit 5b8387969dcc1575a71eaf2daa8f42b94c87bbd0) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 669f825b90..8a9fb9ab87 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -469,7 +469,7 @@ bool torture_local_replace(struct torture_context *ctx) return ret; } -#ifndef _SAMBA_BUILD_ +#if _SAMBA_BUILD_<4 int main() { bool ret = torture_local_replace(NULL); -- cgit From 0ce02a2c0eb322502bd931e83fa23ce476198e06 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 19:27:45 +0000 Subject: r20819: - include system/aio.h - use full prototype for main - use ifdef instead if metze (This used to be commit b3a3c44f42455d6f84ab2f1f282fb177f8b6013c) --- source4/lib/replace/test/testsuite.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 8a9fb9ab87..effbdb13ef 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -46,6 +46,7 @@ #include "system/terminal.h" #include "system/time.h" #include "system/wait.h" +#include "system/aio.h" #define TESTFILE "testfile.dat" @@ -470,7 +471,7 @@ bool torture_local_replace(struct torture_context *ctx) } #if _SAMBA_BUILD_<4 -int main() +int main(void) { bool ret = torture_local_replace(NULL); if (ret) -- cgit From d358087227727a9a8e8661c8eae2990115f8fb80 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 09:59:48 +0000 Subject: r21794: add setenv()/unsetenv() testsuite metze (This used to be commit 3df206ddfadea5bf39a22e8c4c262764c79d302c) --- source4/lib/replace/test/testsuite.c | 62 +++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index effbdb13ef..c2f5ff9a6b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -171,7 +171,67 @@ static int test_timegm(void) static int test_setenv(void) { - /* FIXME */ +#define TEST_SETENV(key, value, overwrite, result) do { \ + int _ret; \ + char *_v; \ + _ret = setenv(key, value, overwrite); \ + if (_ret != 0) { \ + printf("failure: setenv [\n" \ + "setenv(%s, %s, %d) failed\n" \ + "]\n", \ + key, value, overwrite); \ + return false; \ + } \ + _v=getenv(key); \ + if (!_v) { \ + printf("failure: setenv [\n" \ + "getenv(%s) returned NULL\n" \ + "]\n", \ + key); \ + return false; \ + } \ + if (strcmp(result, _v) != 0) { \ + printf("failure: setenv [\n" \ + "getenv(%s): '%s' != '%s'\n" \ + "]\n", \ + key, result, _v); \ + return false; \ + } \ +} while(0) + +#define TEST_UNSETENV(key) do { \ + int _ret; \ + char *_v; \ + _ret = unsetenv(key); \ + if (_ret != 0) { \ + printf("failure: setenv [\n" \ + "unsetenv(%s) failed\n" \ + "]\n", \ + key); \ + return false; \ + } \ + _v=getenv(key); \ + if (_v) { \ + printf("failure: setenv [\n" \ + "getenv(%s): NULL != '%s'\n" \ + "]\n", \ + SETENVTEST_KEY, _v); \ + return false; \ + } \ +} while (0) + +#define SETENVTEST_KEY "SETENVTESTKEY" +#define SETENVTEST_VAL "SETENVTESTVAL" + + printf("test: setenv\n"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"1", 0, SETENVTEST_VAL"1"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"2", 0, SETENVTEST_VAL"1"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4"); + TEST_UNSETENV(SETENVTEST_KEY); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5"); + TEST_UNSETENV(SETENVTEST_KEY); + printf("success: setenv\n"); return true; } -- cgit From de75e93817da856f1e79f616e4fc09c27ab626c0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:31:06 +0000 Subject: r21796: check if unsetenv() works on an non-existing key metze (This used to be commit c6b4f2d1518c989cacdc8869df89f02dc54857d7) --- source4/lib/replace/test/testsuite.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c2f5ff9a6b..44c218270c 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -229,8 +229,10 @@ static int test_setenv(void) TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3"); TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4"); TEST_UNSETENV(SETENVTEST_KEY); + TEST_UNSETENV(SETENVTEST_KEY); TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5"); TEST_UNSETENV(SETENVTEST_KEY); + TEST_UNSETENV(SETENVTEST_KEY); printf("success: setenv\n"); return true; } -- cgit From 8988113a4261a484962eb104408ada661809ce3a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:37:12 +0000 Subject: r21798: unsetenv() returns void on some platforms (BSD) metze (This used to be commit 9cdb9f1cee9af47e42e11357397b828b86632805) --- source4/lib/replace/test/testsuite.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 44c218270c..5ed6b3e7a5 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -200,16 +200,8 @@ static int test_setenv(void) } while(0) #define TEST_UNSETENV(key) do { \ - int _ret; \ char *_v; \ - _ret = unsetenv(key); \ - if (_ret != 0) { \ - printf("failure: setenv [\n" \ - "unsetenv(%s) failed\n" \ - "]\n", \ - key); \ - return false; \ - } \ + unsetenv(key); \ _v=getenv(key); \ if (_v) { \ printf("failure: setenv [\n" \ -- cgit From 4cc500433d07decf8fc2551b117e15537f6c8558 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Apr 2007 16:00:13 +0000 Subject: r22152: merge from samba3: remove netgr functions from libreplace they're not used in samba4 currently and samba3 has explicit configure checks for them. should fix bug #4496 metze (This used to be commit dd83a8dad8ad89a1485598fa6e11c9128d04e6d7) --- source4/lib/replace/test/testsuite.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5ed6b3e7a5..40ee0650b0 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -125,12 +125,6 @@ static int test_mktime(void) return true; } -static int test_innetgr(void) -{ - /* FIXME */ - return true; -} - static int test_initgroups(void) { /* FIXME */ @@ -480,7 +474,6 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); - ret &= test_innetgr(); ret &= test_initgroups(); ret &= test_memmove(); ret &= test_strdup(); -- cgit From f2e611f355b5f937ed03d622e46ddeefe859d564 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 12 Apr 2007 19:54:15 +0000 Subject: r22203: Improve the replace testsuite a bit. (This used to be commit 7003a6fa1ae1d163160ad509a7811f836be3aa6f) --- source4/lib/replace/test/testsuite.c | 162 ++++++++++++++++++++++++++++++++--- 1 file changed, 151 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 40ee0650b0..1e881aa10e 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -115,7 +115,27 @@ static int test_strlcpy(void) static int test_strlcat(void) { - /* FIXME */ + char tmp[10]; + printf("test: strlcat\n"); + strcpy(tmp, ""); + if (strlcat(tmp, "bla", 3) != 3) { + printf("failure: strlcat [\ninvalid return code\n]\n"); + return false; + } + if (strcmp(tmp, "bl") != 0) { + printf("failure: strlcat [\nexpected \"bl\", got \"%s\"\n]\n", + tmp); + return false; + } + + strcpy(tmp, "da"); + if (strlcat(tmp, "me", 4) != 4) { + printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n", + tmp); + return false; + } + + printf("success: strlcat\n"); return true; } @@ -139,7 +159,16 @@ static int test_memmove(void) static int test_strdup(void) { - /* FIXME */ + char *x; + printf("test: strdup\n"); + x = strdup("bla"); + if (strcmp("bla", x) != 0) { + printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n", + x); + return false; + } + free(x); + printf("success: strdup\n"); return true; } @@ -225,13 +254,49 @@ static int test_setenv(void) static int test_strndup(void) { - /* FIXME */ + char *x; + printf("test: strndup\n"); + x = strndup("bla", 0); + if (strcmp(x, "") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + x = strndup("bla", 2); + if (strcmp(x, "bl") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + x = strndup("bla", 10); + if (strcmp(x, "bla") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + printf("success: strndup\n"); return true; } static int test_strnlen(void) { - /* FIXME */ + printf("test: strnlen\n"); + if (strnlen("bla", 2) != 2) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + if (strnlen("some text\n", 0) != 0) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + if (strnlen("some text", 20) != 9) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + printf("success: strnlen\n"); return true; } @@ -255,13 +320,43 @@ static int test_setegid(void) static int test_asprintf(void) { - /* FIXME */ + char *x; + printf("test: asprintf\n"); + if (asprintf(&x, "%d", 9) != 1) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (strcmp(x, "9") != 0) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (asprintf(&x, "dat%s", "a") != 4) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (strcmp(x, "data") != 0) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + printf("success: asprintf\n"); return true; } static int test_snprintf(void) { - /* FIXME */ + char tmp[10]; + printf("test: snprintf\n"); + if (snprintf(tmp, 3, "foo%d", 9) != 4) { + printf("failure: snprintf [\nsnprintf return code failed\n]\n"); + return false; + } + + if (strcmp(tmp, "fo") != 0) { + printf("failure: snprintf [\nsnprintf failed\n]\n"); + return false; + } + + printf("success: snprintf\n"); return true; } @@ -328,13 +423,22 @@ static int test_bzero(void) static int test_strerror(void) { + printf("test: strerror\n"); /* FIXME */ + printf("failure: sterror\n"); return true; } static int test_errno(void) { - /* FIXME */ + printf("test: errno\n"); + errno = 3; + if (errno != 3) { + printf("failure: errno [\nerrno failed\n]\n"); + return false; + } + + printf("success: errno\n"); return true; } @@ -376,7 +480,20 @@ static int test_inet_ntoa(void) static int test_strtoll(void) { - /* FIXME */ + printf("test: strtoll\n"); + if (strtoll("15", NULL, 10) != 15) { + printf("failure: strtoll [\nstrtoll failed\n]\n"); + return false; + } + if (strtoll("10", NULL, 16) != 16) { + printf("failure: strtoll [\nstrtoll hex failed\n]\n"); + return false; + } + if (strtoll("11", NULL, 2) != 3) { + printf("failure: strtoll [\nstrtoll binary failed\n]\n"); + return false; + } + printf("success: strtoll\n"); return true; } @@ -410,19 +527,42 @@ static int test_va_copy(void) static int test_FUNCTION(void) { - /* FIXME: test __FUNCTION__ macro */ + printf("test: FUNCTION\n"); + if (strcmp(__FUNCTION__, "test_FUNCTION") != 0) { + printf("failure: FAILURE [\nFAILURE invalid\n]\n"); + return false; + } + printf("success: FUNCTION\n"); return true; } static int test_MIN(void) { - /* FIXME */ + printf("test: MIN\n"); + if (MIN(20, 1) != 1) { + printf("failure: MIN [\nMIN invalid\n]\n"); + return false; + } + if (MIN(1, 20) != 1) { + printf("failure: MIN [\nMIN invalid\n]\n"); + return false; + } + printf("success: MIN\n"); return true; } static int test_MAX(void) { - /* FIXME */ + printf("test: MAX\n"); + if (MAX(20, 1) != 20) { + printf("failure: MAX [\nMAX invalid\n]\n"); + return false; + } + if (MAX(1, 20) != 20) { + printf("failure: MAX [\nMAX invalid\n]\n"); + return false; + } + printf("success: MAX\n"); return true; } -- cgit From eb49760603a043163b7cc80c781a16eac376aee2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 14 Apr 2007 09:14:40 +0000 Subject: r22215: add strptime replacement to libreplace based on the patch from jojowil@hvcc.edu to bug 4063 also add a testsuite for strptime() metze (This used to be commit aba64521707143e6505b3322c390882a918a148a) --- source4/lib/replace/test/testsuite.c | 110 +++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 1e881aa10e..a992fd8c0f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -606,6 +606,115 @@ static int test_socketpair(void) return true; } +static int test_strptime(void) +{ + const char *s = "20070414101546Z"; + char *ret; + struct tm t, t2; + + printf("test: strptime\n"); + + ret = strptime(s, "%Y%m%d%H%M%S", &t); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL\n" + "]\n"); + return false; + } + + ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL with Z\n" + "]\n"); + return false; + } + + if (memcmp(&t, &t2, sizeof(t)) == 0) { + printf("failure: strptime [\n" + "result differs if the format string has a 'Z' at the end\n" + "]\n"); + return false; + } + + if (t.tm_sec != 46) { + printf("failure: strptime [\n" + "tm_sec: expected: 46, got: %d\n" + "]\n", + t.tm_sec); + return false; + } + + if (t.tm_min != 15) { + printf("failure: strptime [\n" + "tm_min: expected: 15, got: %d\n" + "]\n", + t.tm_min); + return false; + } + + if (t.tm_hour != 10) { + printf("failure: strptime [\n" + "tm_hour: expected: 10, got: %d\n" + "]\n", + t.tm_hour); + return false; + } + + if (t.tm_mday != 14) { + printf("failure: strptime [\n" + "tm_mday: expected: 14, got: %d\n" + "]\n", + t.tm_mday); + return false; + } + + if (t.tm_mon != 3) { + printf("failure: strptime [\n" + "tm_mon: expected: 3, got: %d\n" + "]\n", + t.tm_mon); + return false; + } + + if (t.tm_year != 107) { + printf("failure: strptime [\n" + "tm_year: expected: 107, got: %d\n" + "]\n", + t.tm_year); + return false; + } + + if (t.tm_wday != 6) { /* saturday */ + printf("failure: strptime [\n" + "tm_wday: expected: 6, got: %d\n" + "]\n", + t.tm_wday); + return false; + } + + if (t.tm_yday != 103) { + printf("failure: strptime [\n" + "tm_yday: expected: 103, got: %d\n" + "]\n", + t.tm_yday); + return false; + } + + /* we don't test this as it depends on the host configuration + if (t.tm_isdst != 0) { + printf("failure: strptime [\n" + "tm_isdst: expected: 0, got: %d\n" + "]\n", + t.tm_isdst); + return false; + }*/ + + printf("success: strptime\n"); + + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -653,6 +762,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_MIN(); ret &= test_MAX(); ret &= test_socketpair(); + ret &= test_strptime(); return ret; } -- cgit From aea41afb52e24077e7b1e28f5090326665d7c3f6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 16:13:06 +0000 Subject: r22216: move strptime testsuite into it's own file so we can include it for the configure test as it seems that strptime() is really broken on some hosts in the build farm, re should use the replacement code when we detect this in the configure test metze (This used to be commit 08a5e9760643b9fbf00fdcf7163de7cf50e841e6) --- source4/lib/replace/test/testsuite.c | 108 +---------------------------------- 1 file changed, 3 insertions(+), 105 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a992fd8c0f..7d45feec6b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -606,113 +606,11 @@ static int test_socketpair(void) return true; } +extern int libreplace_test_strptime(void); + static int test_strptime(void) { - const char *s = "20070414101546Z"; - char *ret; - struct tm t, t2; - - printf("test: strptime\n"); - - ret = strptime(s, "%Y%m%d%H%M%S", &t); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL\n" - "]\n"); - return false; - } - - ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL with Z\n" - "]\n"); - return false; - } - - if (memcmp(&t, &t2, sizeof(t)) == 0) { - printf("failure: strptime [\n" - "result differs if the format string has a 'Z' at the end\n" - "]\n"); - return false; - } - - if (t.tm_sec != 46) { - printf("failure: strptime [\n" - "tm_sec: expected: 46, got: %d\n" - "]\n", - t.tm_sec); - return false; - } - - if (t.tm_min != 15) { - printf("failure: strptime [\n" - "tm_min: expected: 15, got: %d\n" - "]\n", - t.tm_min); - return false; - } - - if (t.tm_hour != 10) { - printf("failure: strptime [\n" - "tm_hour: expected: 10, got: %d\n" - "]\n", - t.tm_hour); - return false; - } - - if (t.tm_mday != 14) { - printf("failure: strptime [\n" - "tm_mday: expected: 14, got: %d\n" - "]\n", - t.tm_mday); - return false; - } - - if (t.tm_mon != 3) { - printf("failure: strptime [\n" - "tm_mon: expected: 3, got: %d\n" - "]\n", - t.tm_mon); - return false; - } - - if (t.tm_year != 107) { - printf("failure: strptime [\n" - "tm_year: expected: 107, got: %d\n" - "]\n", - t.tm_year); - return false; - } - - if (t.tm_wday != 6) { /* saturday */ - printf("failure: strptime [\n" - "tm_wday: expected: 6, got: %d\n" - "]\n", - t.tm_wday); - return false; - } - - if (t.tm_yday != 103) { - printf("failure: strptime [\n" - "tm_yday: expected: 103, got: %d\n" - "]\n", - t.tm_yday); - return false; - } - - /* we don't test this as it depends on the host configuration - if (t.tm_isdst != 0) { - printf("failure: strptime [\n" - "tm_isdst: expected: 0, got: %d\n" - "]\n", - t.tm_isdst); - return false; - }*/ - - printf("success: strptime\n"); - - return true; + return libreplace_test_strptime(); } struct torture_context; -- cgit From 69370d05c94e2fceb55e19e1d886d4f7135b40a4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 06:08:06 +0000 Subject: r22239: use strlcpy instead of strcpy to make the IBM checker happy metze (This used to be commit d51af1b3ac8c332481f978b909ee461941f8a50d) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 7d45feec6b..165d222261 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -117,7 +117,7 @@ static int test_strlcat(void) { char tmp[10]; printf("test: strlcat\n"); - strcpy(tmp, ""); + strlcpy(tmp, "", sizeof(tmp)); if (strlcat(tmp, "bla", 3) != 3) { printf("failure: strlcat [\ninvalid return code\n]\n"); return false; @@ -128,7 +128,7 @@ static int test_strlcat(void) return false; } - strcpy(tmp, "da"); + strlcpy(tmp, "da", sizeof(tmp)); if (strlcat(tmp, "me", 4) != 4) { printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n", tmp); -- cgit From abe4d9a93f75f31d04d6a71c86a5b89cfa683a22 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 06:29:45 +0000 Subject: r22243: remove useless printf's metze (This used to be commit 8267e2964eddf0afc13edec8e91f9e7ca1d72644) --- source4/lib/replace/test/testsuite.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 165d222261..4c21de7aa3 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -423,9 +423,7 @@ static int test_bzero(void) static int test_strerror(void) { - printf("test: strerror\n"); /* FIXME */ - printf("failure: sterror\n"); return true; } -- cgit From 4b2b3bb7068a6d09b3cd4628bb25e74bd2a47ef6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 07:40:32 +0000 Subject: r22246: only test strtoll once metze (This used to be commit 236def3494f20c59ad44464a5359f3387acbb708) --- source4/lib/replace/test/testsuite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 4c21de7aa3..a394810f61 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -651,7 +651,6 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_getpass(); ret &= test_inet_ntoa(); ret &= test_strtoll(); - ret &= test_strtoll(); ret &= test_strtoull(); ret &= test_va_copy(); ret &= test_FUNCTION(); -- cgit From 43b16443de76bb8bc11be811ac515374337970bd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 09:43:48 +0000 Subject: r22253: - make the strtoll tests more verbose - add initial strtoull tests metze (This used to be commit 5d1e0f167add3c75955a27aa1ff3b16523ccf5c2) --- source4/lib/replace/test/testsuite.c | 63 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a394810f61..025e5256f9 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -478,26 +478,75 @@ static int test_inet_ntoa(void) static int test_strtoll(void) { + int64_t v; + printf("test: strtoll\n"); - if (strtoll("15", NULL, 10) != 15) { - printf("failure: strtoll [\nstrtoll failed\n]\n"); + + v = strtoll("15", NULL, 10); + if (v != 15) { + printf("failure: strtoll [\n" + "strtoll failed: %lld != 15\n" + "]\n", + v); return false; } - if (strtoll("10", NULL, 16) != 16) { - printf("failure: strtoll [\nstrtoll hex failed\n]\n"); + + v = strtoll("10", NULL, 16); + if (v != 16) { + printf("failure: strtoll [\n" + "strtoll hex failed: %lld != 16\n" + "]\n", + v); return false; } - if (strtoll("11", NULL, 2) != 3) { - printf("failure: strtoll [\nstrtoll binary failed\n]\n"); + + v = strtoll("11", NULL, 2); + if (v != 3) { + printf("failure: strtoll [\n" + "strtoll binary failed: %lld != 3\n" + "]\n", + v); return false; } + printf("success: strtoll\n"); return true; } static int test_strtoull(void) { - /* FIXME */ + uint64_t v; + + printf("test: strtoull\n"); + + v = strtoull("15", NULL, 10); + if (v != 15) { + printf("failure: strtoull [\n" + "strtoull failed: %llu != 15\n" + "]\n", + v); + return false; + } + + v = strtoull("10", NULL, 16); + if (v != 16) { + printf("failure: strtoull [\n" + "strtoull hex failed: %llu != 16\n" + "]\n", + v); + return false; + } + + v = strtoull("11", NULL, 2); + if (v != 3) { + printf("failure: strtoull [\n" + "strtoull binary failed: %llu != 3\n" + "]\n", + v); + return false; + } + + printf("success: strtuoll\n"); return true; } -- cgit From 5b7afb8a9f331eb63842969564a4dcb72f747726 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:55:51 +0000 Subject: r22279: add a lot more detailed strtoll() and strtoull() tests metze (This used to be commit 8b6d9076040b27fb13b99209116973f5abcec667) --- source4/lib/replace/test/testsuite.c | 310 ++++++++++++++++++++++++++++------- 1 file changed, 254 insertions(+), 56 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 025e5256f9..2d068c559f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -476,38 +476,140 @@ static int test_inet_ntoa(void) return true; } +#define TEST_STRTO_X(type,fmt,func,str,base,res,diff,rrnoo) do {\ + type _v; \ + char _s[64]; \ + char *_p = NULL;\ + char *_ep = NULL; \ + strlcpy(_s, str, sizeof(_s));\ + if (diff >= 0) { \ + _ep = &_s[diff]; \ + } \ + errno = 0; \ + _v = func(_s, &_p, base); \ + if (errno != rrnoo) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ + "\terrno: %d != %d\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v, rrnoo, errno); \ + return false; \ + } else if (_v != res) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " != " fmt "\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v); \ + return false; \ + } else if (_p != _ep) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ + "\tptr: %p - %p = %d != %d\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v, _ep, _p, diff - (_ep - _p), diff); \ + return false; \ + } \ +} while (0) + static int test_strtoll(void) { - int64_t v; - printf("test: strtoll\n"); - v = strtoll("15", NULL, 10); - if (v != 15) { - printf("failure: strtoll [\n" - "strtoll failed: %lld != 15\n" - "]\n", - v); - return false; - } - - v = strtoll("10", NULL, 16); - if (v != 16) { - printf("failure: strtoll [\n" - "strtoll hex failed: %lld != 16\n" - "]\n", - v); - return false; - } - - v = strtoll("11", NULL, 2); - if (v != 3) { - printf("failure: strtoll [\n" - "strtoll binary failed: %lld != 3\n" - "]\n", - v); - return false; - } +#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(int64_t, "%lld", strtoll,str,base,res,diff,errnoo) + + TEST_STRTOLL("15", 10, 15LL, 2, 0); + TEST_STRTOLL(" 15", 10, 15LL, 4, 0); + TEST_STRTOLL("15", 0, 15LL, 2, 0); + TEST_STRTOLL(" 15 ", 0, 15LL, 3, 0); + TEST_STRTOLL("+15", 10, 15LL, 3, 0); + TEST_STRTOLL(" +15", 10, 15LL, 5, 0); + TEST_STRTOLL("+15", 0, 15LL, 3, 0); + TEST_STRTOLL(" +15 ", 0, 15LL, 4, 0); + TEST_STRTOLL("-15", 10, -15LL, 3, 0); + TEST_STRTOLL(" -15", 10, -15LL, 5, 0); + TEST_STRTOLL("-15", 0, -15LL, 3, 0); + TEST_STRTOLL(" -15 ", 0, -15LL, 4, 0); + TEST_STRTOLL("015", 10, 15LL, 3, 0); + TEST_STRTOLL(" 015", 10, 15LL, 5, 0); + TEST_STRTOLL("015", 0, 13LL, 3, 0); + TEST_STRTOLL(" 015", 0, 13LL, 5, 0); + TEST_STRTOLL("0x15", 10, 0LL, 1, 0); + TEST_STRTOLL(" 0x15", 10, 0LL, 3, 0); + TEST_STRTOLL("0x15", 0, 21LL, 4, 0); + TEST_STRTOLL(" 0x15", 0, 21LL, 6, 0); + + TEST_STRTOLL("10", 16, 16LL, 2, 0); + TEST_STRTOLL(" 10 ", 16, 16LL, 4, 0); + TEST_STRTOLL("0x10", 16, 16LL, 4, 0); + TEST_STRTOLL("0x10", 0, 16LL, 4, 0); + TEST_STRTOLL(" 0x10 ", 0, 16LL, 5, 0); + TEST_STRTOLL("+10", 16, 16LL, 3, 0); + TEST_STRTOLL(" +10 ", 16, 16LL, 5, 0); + TEST_STRTOLL("+0x10", 16, 16LL, 5, 0); + TEST_STRTOLL("+0x10", 0, 16LL, 5, 0); + TEST_STRTOLL(" +0x10 ", 0, 16LL, 6, 0); + TEST_STRTOLL("-10", 16, -16LL, 3, 0); + TEST_STRTOLL(" -10 ", 16, -16LL, 5, 0); + TEST_STRTOLL("-0x10", 16, -16LL, 5, 0); + TEST_STRTOLL("-0x10", 0, -16LL, 5, 0); + TEST_STRTOLL(" -0x10 ", 0, -16LL, 6, 0); + TEST_STRTOLL("010", 16, 16LL, 3, 0); + TEST_STRTOLL(" 010 ", 16, 16LL, 5, 0); + TEST_STRTOLL("-010", 16, -16LL, 4, 0); + + TEST_STRTOLL("11", 8, 9LL, 2, 0); + TEST_STRTOLL("011", 8, 9LL, 3, 0); + TEST_STRTOLL("011", 0, 9LL, 3, 0); + TEST_STRTOLL("-11", 8, -9LL, 3, 0); + TEST_STRTOLL("-011", 8, -9LL, 4, 0); + TEST_STRTOLL("-011", 0, -9LL, 4, 0); + + TEST_STRTOLL("011", 8, 9LL, 3, 0); + TEST_STRTOLL("011", 0, 9LL, 3, 0); + TEST_STRTOLL("-11", 8, -9LL, 3, 0); + TEST_STRTOLL("-011", 8, -9LL, 4, 0); + TEST_STRTOLL("-011", 0, -9LL, 4, 0); + + TEST_STRTOLL("Text", 0, 0LL, 0, 0); + + TEST_STRTOLL("9223372036854775807", 10, 9223372036854775807LL, 19, 0); + TEST_STRTOLL("9223372036854775807", 0, 9223372036854775807LL, 19, 0); + TEST_STRTOLL("9223372036854775808", 0, 9223372036854775807LL, 19, ERANGE); + TEST_STRTOLL("9223372036854775808", 10, 9223372036854775807LL, 19, ERANGE); + TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LL, 18, 0); + TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 18, 0); + TEST_STRTOLL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 16, 0); + TEST_STRTOLL("0x8000000000000000", 0, 9223372036854775807LL, 18, ERANGE); + TEST_STRTOLL("0x8000000000000000", 16, 9223372036854775807LL, 18, ERANGE); + TEST_STRTOLL("80000000000000000", 16, 9223372036854775807LL, 17, ERANGE); + TEST_STRTOLL("0777777777777777777777", 0, 9223372036854775807LL, 22, 0); + TEST_STRTOLL("0777777777777777777777", 8, 9223372036854775807LL, 22, 0); + TEST_STRTOLL("777777777777777777777", 8, 9223372036854775807LL, 21, 0); + TEST_STRTOLL("01000000000000000000000", 0, 9223372036854775807LL, 23, ERANGE); + TEST_STRTOLL("01000000000000000000000", 8, 9223372036854775807LL, 23, ERANGE); + TEST_STRTOLL("1000000000000000000000", 8, 9223372036854775807LL, 22, ERANGE); + + TEST_STRTOLL("-9223372036854775808", 10, -9223372036854775807LL -1, 20, 0); + TEST_STRTOLL("-9223372036854775808", 0, -9223372036854775807LL -1, 20, 0); + TEST_STRTOLL("-9223372036854775809", 0, -9223372036854775807LL -1, 20, ERANGE); + TEST_STRTOLL("-9223372036854775809", 10, -9223372036854775807LL -1, 20, ERANGE); + TEST_STRTOLL("-0x8000000000000000", 0, -9223372036854775807LL -1, 19, 0); + TEST_STRTOLL("-0x8000000000000000", 16, -9223372036854775807LL -1, 19, 0); + TEST_STRTOLL("-8000000000000000", 16, -9223372036854775807LL -1, 17, 0); + TEST_STRTOLL("-0x8000000000000001", 0, -9223372036854775807LL -1, 19, ERANGE); + TEST_STRTOLL("-0x8000000000000001", 16, -9223372036854775807LL -1, 19, ERANGE); + TEST_STRTOLL("-80000000000000001", 16, -9223372036854775807LL -1, 18, ERANGE); + TEST_STRTOLL("-01000000000000000000000",0, -9223372036854775807LL -1, 24, 0); + TEST_STRTOLL("-01000000000000000000000",8, -9223372036854775807LL -1, 24, 0); + TEST_STRTOLL("-1000000000000000000000", 8, -9223372036854775807LL -1, 23, 0); + TEST_STRTOLL("-01000000000000000000001",0, -9223372036854775807LL -1, 24, ERANGE); + TEST_STRTOLL("-01000000000000000000001",8, -9223372036854775807LL -1, 24, ERANGE); + TEST_STRTOLL("-1000000000000000000001", 8, -9223372036854775807LL -1, 23, ERANGE); printf("success: strtoll\n"); return true; @@ -515,36 +617,132 @@ static int test_strtoll(void) static int test_strtoull(void) { - uint64_t v; - printf("test: strtoull\n"); - v = strtoull("15", NULL, 10); - if (v != 15) { - printf("failure: strtoull [\n" - "strtoull failed: %llu != 15\n" - "]\n", - v); - return false; - } - - v = strtoull("10", NULL, 16); - if (v != 16) { - printf("failure: strtoull [\n" - "strtoull hex failed: %llu != 16\n" - "]\n", - v); - return false; - } - - v = strtoull("11", NULL, 2); - if (v != 3) { - printf("failure: strtoull [\n" - "strtoull binary failed: %llu != 3\n" - "]\n", - v); - return false; - } +#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(uint64_t,"%llu",strtoull,str,base,res,diff,errnoo) + + TEST_STRTOULL("15", 10, 15LLU, 2, 0); + TEST_STRTOULL(" 15", 10, 15LLU, 4, 0); + TEST_STRTOULL("15", 0, 15LLU, 2, 0); + TEST_STRTOULL(" 15 ", 0, 15LLU, 3, 0); + TEST_STRTOULL("+15", 10, 15LLU, 3, 0); + TEST_STRTOULL(" +15", 10, 15LLU, 5, 0); + TEST_STRTOULL("+15", 0, 15LLU, 3, 0); + TEST_STRTOULL(" +15 ", 0, 15LLU, 4, 0); + TEST_STRTOULL("-15", 10, 18446744073709551601LLU, 3, 0); + TEST_STRTOULL(" -15", 10, 18446744073709551601LLU, 5, 0); + TEST_STRTOULL("-15", 0, 18446744073709551601LLU, 3, 0); + TEST_STRTOULL(" -15 ", 0, 18446744073709551601LLU, 4, 0); + TEST_STRTOULL("015", 10, 15LLU, 3, 0); + TEST_STRTOULL(" 015", 10, 15LLU, 5, 0); + TEST_STRTOULL("015", 0, 13LLU, 3, 0); + TEST_STRTOULL(" 015", 0, 13LLU, 5, 0); + TEST_STRTOULL("0x15", 10, 0LLU, 1, 0); + TEST_STRTOULL(" 0x15", 10, 0LLU, 3, 0); + TEST_STRTOULL("0x15", 0, 21LLU, 4, 0); + TEST_STRTOULL(" 0x15", 0, 21LLU, 6, 0); + + TEST_STRTOULL("10", 16, 16LLU, 2, 0); + TEST_STRTOULL(" 10 ", 16, 16LLU, 4, 0); + TEST_STRTOULL("0x10", 16, 16LLU, 4, 0); + TEST_STRTOULL("0x10", 0, 16LLU, 4, 0); + TEST_STRTOULL(" 0x10 ", 0, 16LLU, 5, 0); + TEST_STRTOULL("+10", 16, 16LLU, 3, 0); + TEST_STRTOULL(" +10 ", 16, 16LLU, 5, 0); + TEST_STRTOULL("+0x10", 16, 16LLU, 5, 0); + TEST_STRTOULL("+0x10", 0, 16LLU, 5, 0); + TEST_STRTOULL(" +0x10 ", 0, 16LLU, 6, 0); + TEST_STRTOULL("-10", 16, -16LLU, 3, 0); + TEST_STRTOULL(" -10 ", 16, -16LLU, 5, 0); + TEST_STRTOULL("-0x10", 16, -16LLU, 5, 0); + TEST_STRTOULL("-0x10", 0, -16LLU, 5, 0); + TEST_STRTOULL(" -0x10 ", 0, -16LLU, 6, 0); + TEST_STRTOULL("010", 16, 16LLU, 3, 0); + TEST_STRTOULL(" 010 ", 16, 16LLU, 5, 0); + TEST_STRTOULL("-010", 16, -16LLU, 4, 0); + + TEST_STRTOULL("11", 8, 9LLU, 2, 0); + TEST_STRTOULL("011", 8, 9LLU, 3, 0); + TEST_STRTOULL("011", 0, 9LLU, 3, 0); + TEST_STRTOULL("-11", 8, -9LLU, 3, 0); + TEST_STRTOULL("-011", 8, -9LLU, 4, 0); + TEST_STRTOULL("-011", 0, -9LLU, 4, 0); + + TEST_STRTOULL("011", 8, 9LLU, 3, 0); + TEST_STRTOULL("011", 0, 9LLU, 3, 0); + TEST_STRTOULL("-11", 8, -9LLU, 3, 0); + TEST_STRTOULL("-011", 8, -9LLU, 4, 0); + TEST_STRTOULL("-011", 0, -9LLU, 4, 0); + + TEST_STRTOULL("Text", 0, 0LLU, 0, 0); + + TEST_STRTOULL("9223372036854775807", 10, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("9223372036854775807", 0, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("9223372036854775808", 0, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("9223372036854775808", 10, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LLU, 18, 0); + TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 18, 0); + TEST_STRTOULL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 16, 0); + TEST_STRTOULL("0x8000000000000000", 0, 9223372036854775808LLU, 18, 0); + TEST_STRTOULL("0x8000000000000000", 16, 9223372036854775808LLU, 18, 0); + TEST_STRTOULL("8000000000000000", 16, 9223372036854775808LLU, 16, 0); + TEST_STRTOULL("0777777777777777777777", 0, 9223372036854775807LLU, 22, 0); + TEST_STRTOULL("0777777777777777777777", 8, 9223372036854775807LLU, 22, 0); + TEST_STRTOULL("777777777777777777777", 8, 9223372036854775807LLU, 21, 0); + TEST_STRTOULL("01000000000000000000000",0, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("01000000000000000000000",8, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("1000000000000000000000", 8, 9223372036854775808LLU, 22, 0); + + TEST_STRTOULL("-9223372036854775808", 10, 9223372036854775808LLU, 20, 0); + TEST_STRTOULL("-9223372036854775808", 0, 9223372036854775808LLU, 20, 0); + TEST_STRTOULL("-9223372036854775809", 0, 9223372036854775807LLU, 20, 0); + TEST_STRTOULL("-9223372036854775809", 10, 9223372036854775807LLU, 20, 0); + TEST_STRTOULL("-0x8000000000000000", 0, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("-0x8000000000000000", 16, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("-8000000000000000", 16, 9223372036854775808LLU, 17, 0); + TEST_STRTOULL("-0x8000000000000001", 0, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("-0x8000000000000001", 16, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("-8000000000000001", 16, 9223372036854775807LLU, 17, 0); + TEST_STRTOULL("-01000000000000000000000",0, 9223372036854775808LLU, 24, 0); + TEST_STRTOULL("-01000000000000000000000",8, 9223372036854775808LLU, 24, 0); + TEST_STRTOULL("-1000000000000000000000",8, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("-01000000000000000000001",0, 9223372036854775807LLU, 24, 0); + TEST_STRTOULL("-01000000000000000000001",8, 9223372036854775807LLU, 24, 0); + TEST_STRTOULL("-1000000000000000000001",8, 9223372036854775807LLU, 23, 0); + + TEST_STRTOULL("18446744073709551615", 0, 18446744073709551615LLU, 20, 0); + TEST_STRTOULL("18446744073709551615", 10, 18446744073709551615LLU, 20, 0); + TEST_STRTOULL("18446744073709551616", 0, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("18446744073709551616", 10, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 0, 18446744073709551615LLU, 18, 0); + TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 18, 0); + TEST_STRTOULL("FFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 16, 0); + TEST_STRTOULL("0x10000000000000000", 0, 18446744073709551615LLU, 19, ERANGE); + TEST_STRTOULL("0x10000000000000000", 16, 18446744073709551615LLU, 19, ERANGE); + TEST_STRTOULL("10000000000000000", 16, 18446744073709551615LLU, 17, ERANGE); + TEST_STRTOULL("01777777777777777777777",0, 18446744073709551615LLU, 23, 0); + TEST_STRTOULL("01777777777777777777777",8, 18446744073709551615LLU, 23, 0); + TEST_STRTOULL("1777777777777777777777", 8, 18446744073709551615LLU, 22, 0); + TEST_STRTOULL("02000000000000000000000",0, 18446744073709551615LLU, 23, ERANGE); + TEST_STRTOULL("02000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); + TEST_STRTOULL("2000000000000000000000", 8, 18446744073709551615LLU, 22, ERANGE); + + TEST_STRTOULL("-18446744073709551615", 0, 1LLU, 21, 0); + TEST_STRTOULL("-18446744073709551615", 10, 1LLU, 21, 0); + TEST_STRTOULL("-18446744073709551616", 0, 18446744073709551615LLU, 21, ERANGE); + TEST_STRTOULL("-18446744073709551616", 10, 18446744073709551615LLU, 21, ERANGE); + TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 0, 1LLU, 19, 0); + TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 16, 1LLU, 19, 0); + TEST_STRTOULL("-FFFFFFFFFFFFFFFF", 16, 1LLU, 17, 0); + TEST_STRTOULL("-0x10000000000000000", 0, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("-0x10000000000000000", 16, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("-10000000000000000", 16, 18446744073709551615LLU, 18, ERANGE); + TEST_STRTOULL("-01777777777777777777777",0, 1LLU, 24, 0); + TEST_STRTOULL("-01777777777777777777777",8, 1LLU, 24, 0); + TEST_STRTOULL("-1777777777777777777777",8, 1LLU, 23, 0); + TEST_STRTOULL("-02000000000000000000000",0, 18446744073709551615LLU, 24, ERANGE); + TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE); + TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); printf("success: strtuoll\n"); return true; -- cgit From e4161f9deee8198e9128e88458e3c5603e86cd3e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 4 May 2007 06:59:02 +0000 Subject: r22658: - add AC_GNU_SOURCE macro for systems which don't have it (sles8) - fix compiler warning on some systems metze (This used to be commit 2097ac64fc5b2b7e9a8221861a788c4a5f44948a) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 2d068c559f..54ffd6a66d 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -511,7 +511,7 @@ static int test_inet_ntoa(void) "\tptr: %p - %p = %d != %d\n" \ "]\n", \ __STRING(func), __location__, __STRING(func), \ - str, diff, base, res, _v, _ep, _p, diff - (_ep - _p), diff); \ + str, diff, base, res, _v, _ep, _p, (int)(diff - (_ep - _p)), diff); \ return false; \ } \ } while (0) -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 54ffd6a66d..48d597ce89 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -12,7 +12,7 @@ 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. + version 3 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 -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/replace/test/testsuite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 48d597ce89..9b684f31bb 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -20,8 +20,7 @@ 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 + License along with this library; if not, see . */ #include "replace.h" -- cgit From 6dad5b6e06242f29b7da6f9ea91d911b0f20d7b9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Jul 2007 07:48:14 +0000 Subject: r24054: Fix some warnings (This used to be commit b3473db397476d05e7ffca50a5f7a9b65e0a5b4a) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 9b684f31bb..8584bcaa66 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -519,7 +519,7 @@ static int test_strtoll(void) { printf("test: strtoll\n"); -#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(int64_t, "%lld", strtoll,str,base,res,diff,errnoo) +#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(long long int, "%lld", strtoll,str,base,res,diff,errnoo) TEST_STRTOLL("15", 10, 15LL, 2, 0); TEST_STRTOLL(" 15", 10, 15LL, 4, 0); @@ -618,7 +618,7 @@ static int test_strtoull(void) { printf("test: strtoull\n"); -#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(uint64_t,"%llu",strtoull,str,base,res,diff,errnoo) +#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(long long unsigned int,"%llu",strtoull,str,base,res,diff,errnoo) TEST_STRTOULL("15", 10, 15LLU, 2, 0); TEST_STRTOULL(" 15", 10, 15LLU, 4, 0); -- cgit From f96b1778a42d8388fd1c6384cd7c90b6e4bcd437 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 19:58:40 +0000 Subject: r24674: Make sure results are always on a new line, fix typo in test name. (This used to be commit 40c1635b39b4acff0acecc734583daa0217215ce) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 8584bcaa66..269a2ff5d6 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -743,7 +743,7 @@ static int test_strtoull(void) TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE); TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); - printf("success: strtuoll\n"); + printf("success: strtoull\n"); return true; } -- cgit From b24e7a15051518806b50768cfc2a840d2b395fe3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Nov 2007 14:42:14 +0100 Subject: r26102: libreplace: remove system/printing.h as it only contains samba3 stuff metze (This used to be commit 1ecb4ec01b0506c95a5f90a62040329e7a39ee93) --- source4/lib/replace/test/testsuite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 269a2ff5d6..5b95ae395c 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -37,7 +37,6 @@ #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" -- cgit From 41e45d690ff5074d861b486c8711bf03cffa2efc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 02:49:52 +0100 Subject: r26468: Match getifaddrs more closely, add trivial test. (This used to be commit 92898c043b5a2649a2e423d02bcdaea78ae55737) --- source4/lib/replace/test/testsuite.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5b95ae395c..c9f3301005 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -856,6 +856,25 @@ static int test_strptime(void) return libreplace_test_strptime(); } +static int test_getifaddrs(void) +{ + struct ifaddrs *ifa; + int ret; + + printf("test: getifaddrs\n"); + + ret = getifaddrs(&ifa); + if (ret != 0) { + printf("failure: getifaddrs\n"); + return false; + } + + freeifaddrs(ifa); + + printf("success: getifaddrs\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -903,6 +922,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); + ret &= test_getifaddrs(); return ret; } -- cgit From dfc84928d722191dad264a7206e20919c140e3ea Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 21:43:06 +0100 Subject: libreplace: add extended getifaddrs test that prints out the interfaces. Michael (This used to be commit 9d2bab09aac22c00fe23f1e1265a2dbd0901e9ce) --- source4/lib/replace/test/testsuite.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c9f3301005..b538360365 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -856,21 +856,18 @@ static int test_strptime(void) return libreplace_test_strptime(); } +extern int getifaddrs_test(void); + static int test_getifaddrs(void) { - struct ifaddrs *ifa; - int ret; printf("test: getifaddrs\n"); - ret = getifaddrs(&ifa); - if (ret != 0) { + if (getifaddrs_test() != 0) { printf("failure: getifaddrs\n"); return false; } - freeifaddrs(ifa); - printf("success: getifaddrs\n"); return true; } -- cgit From bbf4ce91462598cee1eebfb94a773194e56a7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 13:10:31 +0200 Subject: libreplace: always provide utime() and utimes() I'd like to also provide futimes(), but it seems that some systems doesn't support a it at kernel level. If someone knows how to write a portable replacement for futimes() please tell me... metze (This used to be commit a9604fe4a323dccb537cf02ea7594437b4995803) --- source4/lib/replace/test/testsuite.c | 145 +++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) (limited to 'source4/lib/replace/test/testsuite.c') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index b538360365..1e8290906e 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -872,6 +872,149 @@ static int test_getifaddrs(void) return true; } +static int test_utime(void) +{ + struct utimbuf u; + struct stat st1, st2, st3; + int fd; + + printf("test: utime\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utime [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utime [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + u.actime = st1.st_atime + 300; + u.modtime = st1.st_mtime - 300; + if (utime(TESTFILE, &u) != 0) { + printf("failure: utime [\n" + "utime(&u) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utime [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (utime(TESTFILE, NULL) != 0) { + printf("failure: utime [\n" + "utime(NULL) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st3) != 0) { + printf("failure: utime [\n" + "fstat (3) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define CMP_VAL(a,c,b) do { \ + if (a c b) { \ + printf("failure: utime [\n" \ + "%s: %s(%d) %s %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #c, #b, (int)b); \ + return false; \ + } \ +} while(0) +#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b) +#define GREATER_VAL(a,b) CMP_VAL(a,<=,b) +#define LESSER_VAL(a,b) CMP_VAL(a,>=,b) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + LESSER_VAL(st3.st_atime, st2.st_atime); + GREATER_VAL(st3.st_mtime, st2.st_mtime); + +#undef CMP_VAL +#undef EQUAL_VAL +#undef GREATER_VAL +#undef LESSER_VAL + + unlink(TESTFILE); + printf("success: utime\n"); + return true; +} + +static int test_utimes(void) +{ + struct timeval tv[2]; + struct stat st1, st2; + int fd; + + printf("test: utimes\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utimes [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utimes [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + ZERO_STRUCT(tv); + tv[0].tv_sec = st1.st_atime + 300; + tv[1].tv_sec = st1.st_mtime - 300; + if (utimes(TESTFILE, tv) != 0) { + printf("failure: utimes [\n" + "utimes(tv) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utimes [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define EQUAL_VAL(a,b) do { \ + if (a != b) { \ + printf("failure: utimes [\n" \ + "%s: %s(%d) != %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #b, (int)b); \ + return false; \ + } \ +} while(0) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + +#undef EQUAL_VAL + + unlink(TESTFILE); + printf("success: utimes\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -920,6 +1063,8 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); + ret &= test_utime(); + ret &= test_utimes(); return ret; } -- cgit