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)
149 printf("testing setlinebuf\n");
154 static int test_vsyslog(void)
160 static int test_timegm(void)
166 static int test_setenv(void)
172 static int test_strndup(void)
178 static int test_strnlen(void)
184 static int test_waitpid(void)
190 static int test_seteuid(void)
196 static int test_setegid(void)
202 static int test_asprintf(void)
208 static int test_snprintf(void)
214 static int test_vasprintf(void)
220 static int test_vsnprintf(void)
226 static int test_opendir(void)
232 extern int test_readdir_os2_delete(void);
234 static int test_readdir(void)
236 printf("testing readdir\n");
237 if (test_readdir_os2_delete() != 0) {
243 static int test_telldir(void)
249 static int test_seekdir(void)
255 static int test_dlopen(void)
257 /* FIXME: test dlopen, dlsym, dlclose, dlerror */
262 static int test_chroot(void)
264 /* FIXME: chroot() */
268 static int test_bzero(void)
274 static int test_strerror(void)
280 static int test_errno(void)
286 static int test_mkdtemp(void)
292 static int test_mkstemp(void)
298 static int test_pread(void)
304 static int test_pwrite(void)
310 static int test_getpass(void)
316 static int test_inet_ntoa(void)
322 static int test_strtoll(void)
328 static int test_strtoull(void)
350 static int test_va_copy(void)
356 static int test_FUNCTION(void)
358 /* FIXME: test __FUNCTION__ macro */
362 static int test_MIN(void)
368 static int test_MAX(void)
374 struct torture_context;
376 static bool torture_local_replace(struct torture_context *torture)
379 ret &= test_ftruncate();
380 ret &= test_strlcpy();
381 ret &= test_strlcat();
382 ret &= test_mktime();
383 ret &= test_innetgr();
384 ret &= test_initgroups();
385 ret &= test_memmove();
386 ret &= test_strdup();
387 ret &= test_setlinebuf();
388 ret &= test_vsyslog();
389 ret &= test_timegm();
390 ret &= test_setenv();
391 ret &= test_strndup();
392 ret &= test_strnlen();
393 ret &= test_waitpid();
394 ret &= test_seteuid();
395 ret &= test_setegid();
396 ret &= test_asprintf();
397 ret &= test_snprintf();
398 ret &= test_vasprintf();
399 ret &= test_vsnprintf();
400 ret &= test_opendir();
401 ret &= test_readdir();
402 ret &= test_telldir();
403 ret &= test_seekdir();
404 ret &= test_dlopen();
405 ret &= test_chroot();
407 ret &= test_strerror();
409 ret &= test_mkdtemp();
410 ret &= test_mkstemp();
412 ret &= test_pwrite();
413 ret &= test_getpass();
414 ret &= test_inet_ntoa();
415 ret &= test_strtoll();
416 ret &= test_strtoll();
417 ret &= test_strtoull();
418 ret &= test_va_copy();
419 ret &= test_FUNCTION();
429 if (!torture_local_replace(NULL)) {
430 printf("ERROR: TESTSUITE FAILED\n");