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
30 we include all the system/ include files here so that libreplace tests
31 them in the build farm
33 #include "system/capability.h"
34 #include "system/dir.h"
35 #include "system/filesys.h"
36 #include "system/glob.h"
37 #include "system/iconv.h"
38 #include "system/locale.h"
39 #include "system/network.h"
40 #include "system/passwd.h"
41 #include "system/printing.h"
42 #include "system/readline.h"
43 #include "system/select.h"
44 #include "system/shmem.h"
45 #include "system/syslog.h"
46 #include "system/terminal.h"
47 #include "system/time.h"
48 #include "system/wait.h"
50 #define TESTFILE "testfile.dat"
53 test ftruncate() function
55 static int test_ftruncate(void)
59 const int size = 1234;
60 printf("testing ftruncate\n");
62 fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
64 printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno));
67 if (ftruncate(fd, size) != 0) {
68 printf("ftruncate failed - %s\n", strerror(errno));
71 if (fstat(fd, &st) != 0) {
72 printf("fstat failed - %s\n", strerror(errno));
75 if (st.st_size != size) {
76 printf("ftruncate gave wrong size %d - expected %d\n",
77 (int)st.st_size, size);
84 test strlcpy() function.
85 see http://www.gratisoft.us/todd/papers/strlcpy.html
87 static int test_strlcpy(void)
101 printf("testing strlcpy\n");
102 for (i=0;tests[i].src;i++) {
103 if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
104 printf("strlcpy test %d failed\n", i);
111 static int test_strlcat(void)
117 static int test_mktime(void)
123 static int test_innetgr(void)
129 static int test_initgroups(void)
135 static int test_memmove(void)
141 static int test_strdup(void)
147 static int test_setlinebuf(void)
153 static int test_vsyslog(void)
159 static int test_timegm(void)
165 static int test_setenv(void)
171 static int test_strndup(void)
177 static int test_strnlen(void)
183 static int test_waitpid(void)
189 static int test_seteuid(void)
195 static int test_setegid(void)
201 static int test_asprintf(void)
207 static int test_snprintf(void)
213 static int test_vasprintf(void)
219 static int test_vsnprintf(void)
225 static int test_opendir(void)
231 static int test_readdir(void)
237 static int test_telldir(void)
243 static int test_seekdir(void)
249 static int test_dlopen(void)
251 /* FIXME: test dlopen, dlsym, dlclose, dlerror */
256 static int test_chroot(void)
258 /* FIXME: chroot() */
262 static int test_bzero(void)
268 static int test_strerror(void)
274 static int test_errno(void)
280 static int test_mkdtemp(void)
286 static int test_mkstemp(void)
292 static int test_pread(void)
298 static int test_pwrite(void)
304 static int test_getpass(void)
310 static int test_inet_ntoa(void)
316 static int test_strtoll(void)
322 static int test_strtoull(void)
344 static int test_va_copy(void)
350 static int test_FUNCTION(void)
352 /* FIXME: test __FUNCTION__ macro */
356 static int test_MIN(void)
362 static int test_MAX(void)
368 int torture_local_replace(void *ctx)
371 ret &= test_ftruncate();
372 ret &= test_strlcpy();
373 ret &= test_strlcat();
374 ret &= test_mktime();
375 ret &= test_innetgr();
376 ret &= test_initgroups();
377 ret &= test_memmove();
378 ret &= test_strdup();
379 ret &= test_setlinebuf();
380 ret &= test_vsyslog();
381 ret &= test_timegm();
382 ret &= test_setenv();
383 ret &= test_strndup();
384 ret &= test_strnlen();
385 ret &= test_waitpid();
386 ret &= test_seteuid();
387 ret &= test_setegid();
388 ret &= test_asprintf();
389 ret &= test_snprintf();
390 ret &= test_vasprintf();
391 ret &= test_vsnprintf();
392 ret &= test_opendir();
393 ret &= test_readdir() ;
394 ret &= test_telldir();
395 ret &= test_seekdir();
396 ret &= test_dlopen();
397 ret &= test_chroot();
399 ret &= test_strerror();
401 ret &= test_mkdtemp();
402 ret &= test_mkstemp();
404 ret &= test_pwrite();
405 ret &= test_getpass();
406 ret &= test_inet_ntoa();
407 ret &= test_strtoll();
408 ret &= test_strtoll();
409 ret &= test_strtoull();
410 ret &= test_va_copy();
411 ret &= test_FUNCTION();
418 #if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9))
421 if (!torture_local_replace(NULL)) {
422 printf("ERROR: TESTSUITE FAILED\n");