2 Unix SMB/CIFS implementation.
6 Copyright (C) Jelmer Vernooij 2006
8 ** NOTE! The following LGPL license applies to the talloc
9 ** library. This does NOT imply that all of Samba is released
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "../replace.h"
35 #include <sys/types.h>
53 #define TESTFILE "testfile.dat"
56 test ftruncate() function
58 static int test_ftruncate(void)
62 const int size = 1234;
63 printf("testing ftruncate\n");
65 fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
67 printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno));
70 if (ftruncate(fd, size) != 0) {
71 printf("ftruncate failed - %s\n", strerror(errno));
74 if (fstat(fd, &st) != 0) {
75 printf("fstat failed - %s\n", strerror(errno));
78 if (st.st_size != size) {
79 printf("ftruncate gave wrong size %d - expected %d\n",
80 (int)st.st_size, size);
87 test strlcpy() function.
88 see http://www.gratisoft.us/todd/papers/strlcpy.html
90 static int test_strlcpy(void)
104 printf("testing strlcpy\n");
105 for (i=0;tests[i].src;i++) {
106 if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
107 printf("strlcpy test %d failed\n", i);
114 static int test_strlcat(void)
120 static int test_mktime(void)
126 static int test_rename(void)
132 static int test_innetgr(void)
138 static int test_initgroups(void)
144 static int test_memmove(void)
150 static int test_strdup(void)
156 static int test_setlinebuf(void)
162 static int test_vsyslog(void)
168 static int test_timegm(void)
174 static int test_setenv(void)
180 static int test_strndup(void)
186 static int test_strnlen(void)
192 static int test_waitpid(void)
198 static int test_seteuid(void)
204 static int test_setegid(void)
210 static int test_asprintf(void)
216 static int test_snprintf(void)
222 static int test_vasprintf(void)
228 static int test_vsnprintf(void)
234 static int test_opendir(void)
240 static int test_readdir(void)
246 static int test_telldir(void)
252 static int test_seekdir(void)
258 static int test_dlopen(void)
260 /* FIXME: test dlopen, dlsym, dlclose, dlerror */
265 static int test_chroot(void)
267 /* FIXME: chroot() */
271 static int test_bzero(void)
277 static int test_strerror(void)
283 static int test_errno(void)
289 static int test_mkdtemp(void)
295 static int test_mkstemp(void)
301 static int test_pread(void)
307 static int test_pwrite(void)
313 static int test_getpass(void)
319 static int test_inet_ntoa(void)
325 static int test_strtoll(void)
331 static int test_strtoull(void)
353 static int test_va_copy(void)
359 static int test_FUNCTION(void)
361 /* FIXME: test __FUNCTION__ macro */
365 static int test_MIN(void)
371 static int test_MAX(void)
377 int torture_local_replace(void *ctx)
380 ret &= test_ftruncate();
381 ret &= test_strlcpy();
382 ret &= test_strlcat();
383 ret &= test_mktime();
384 ret &= test_rename();
385 ret &= test_innetgr();
386 ret &= test_initgroups();
387 ret &= test_memmove();
388 ret &= test_strdup();
389 ret &= test_setlinebuf();
390 ret &= test_vsyslog();
391 ret &= test_timegm();
392 ret &= test_setenv();
393 ret &= test_strndup();
394 ret &= test_strnlen();
395 ret &= test_waitpid();
396 ret &= test_seteuid();
397 ret &= test_setegid();
398 ret &= test_asprintf();
399 ret &= test_snprintf();
400 ret &= test_vasprintf();
401 ret &= test_vsnprintf();
402 ret &= test_opendir();
403 ret &= test_readdir() ;
404 ret &= test_telldir();
405 ret &= test_seekdir();
406 ret &= test_dlopen();
407 ret &= test_chroot();
409 ret &= test_strerror();
411 ret &= test_mkdtemp();
412 ret &= test_mkstemp();
414 ret &= test_pwrite();
415 ret &= test_getpass();
416 ret &= test_inet_ntoa();
417 ret &= test_strtoll();
418 ret &= test_strtoll();
419 ret &= test_strtoull();
420 ret &= test_va_copy();
421 ret &= test_FUNCTION();
428 #if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9))
431 if (!torture_local_replace(NULL)) {
432 printf("ERROR: TESTSUITE FAILED\n");