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"
49 #include "system/aio.h"
51 #define TESTFILE "testfile.dat"
54 test ftruncate() function
56 static int test_ftruncate(void)
60 const int size = 1234;
61 printf("test: ftruncate\n");
63 fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
65 printf("failure: ftruncate [\n"
66 "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno));
69 if (ftruncate(fd, size) != 0) {
70 printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
73 if (fstat(fd, &st) != 0) {
74 printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
77 if (st.st_size != size) {
78 printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
79 (int)st.st_size, size);
83 printf("success: ftruncate\n");
88 test strlcpy() function.
89 see http://www.gratisoft.us/todd/papers/strlcpy.html
91 static int test_strlcpy(void)
105 printf("test: strlcpy\n");
106 for (i=0;tests[i].src;i++) {
107 if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
108 printf("failure: strlcpy [\ntest %d failed\n]\n", i);
112 printf("success: strlcpy\n");
116 static int test_strlcat(void)
122 static int test_mktime(void)
128 static int test_innetgr(void)
134 static int test_initgroups(void)
140 static int test_memmove(void)
146 static int test_strdup(void)
152 static int test_setlinebuf(void)
154 printf("test: setlinebuf\n");
156 printf("success: setlinebuf\n");
160 static int test_vsyslog(void)
166 static int test_timegm(void)
172 static int test_setenv(void)
178 static int test_strndup(void)
184 static int test_strnlen(void)
190 static int test_waitpid(void)
196 static int test_seteuid(void)
202 static int test_setegid(void)
208 static int test_asprintf(void)
214 static int test_snprintf(void)
220 static int test_vasprintf(void)
226 static int test_vsnprintf(void)
232 static int test_opendir(void)
238 extern int test_readdir_os2_delete(void);
240 static int test_readdir(void)
242 printf("test: readdir\n");
243 if (test_readdir_os2_delete() != 0) {
246 printf("success: readdir\n");
250 static int test_telldir(void)
256 static int test_seekdir(void)
262 static int test_dlopen(void)
264 /* FIXME: test dlopen, dlsym, dlclose, dlerror */
269 static int test_chroot(void)
271 /* FIXME: chroot() */
275 static int test_bzero(void)
281 static int test_strerror(void)
287 static int test_errno(void)
293 static int test_mkdtemp(void)
299 static int test_mkstemp(void)
305 static int test_pread(void)
311 static int test_pwrite(void)
317 static int test_getpass(void)
323 static int test_inet_ntoa(void)
329 static int test_strtoll(void)
335 static int test_strtoull(void)
357 static int test_va_copy(void)
363 static int test_FUNCTION(void)
365 /* FIXME: test __FUNCTION__ macro */
369 static int test_MIN(void)
375 static int test_MAX(void)
381 static int test_socketpair(void)
386 printf("test: socketpair\n");
388 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
389 printf("failure: socketpair [\n"
390 "socketpair() failed\n"
395 if (write(sock[1], "automatisch", 12) == -1) {
396 printf("failure: socketpair [\n"
397 "write() failed: %s\n"
398 "]\n", strerror(errno));
402 if (read(sock[0], buf, 12) == -1) {
403 printf("failure: socketpair [\n"
404 "read() failed: %s\n"
405 "]\n", strerror(errno));
409 if (strcmp(buf, "automatisch") != 0) {
410 printf("failure: socketpair [\n"
411 "expected: automatisch, got: %s\n"
416 printf("success: socketpair\n");
421 struct torture_context;
422 bool torture_local_replace(struct torture_context *ctx)
425 ret &= test_ftruncate();
426 ret &= test_strlcpy();
427 ret &= test_strlcat();
428 ret &= test_mktime();
429 ret &= test_innetgr();
430 ret &= test_initgroups();
431 ret &= test_memmove();
432 ret &= test_strdup();
433 ret &= test_setlinebuf();
434 ret &= test_vsyslog();
435 ret &= test_timegm();
436 ret &= test_setenv();
437 ret &= test_strndup();
438 ret &= test_strnlen();
439 ret &= test_waitpid();
440 ret &= test_seteuid();
441 ret &= test_setegid();
442 ret &= test_asprintf();
443 ret &= test_snprintf();
444 ret &= test_vasprintf();
445 ret &= test_vsnprintf();
446 ret &= test_opendir();
447 ret &= test_readdir();
448 ret &= test_telldir();
449 ret &= test_seekdir();
450 ret &= test_dlopen();
451 ret &= test_chroot();
453 ret &= test_strerror();
455 ret &= test_mkdtemp();
456 ret &= test_mkstemp();
458 ret &= test_pwrite();
459 ret &= test_getpass();
460 ret &= test_inet_ntoa();
461 ret &= test_strtoll();
462 ret &= test_strtoll();
463 ret &= test_strtoull();
464 ret &= test_va_copy();
465 ret &= test_FUNCTION();
468 ret &= test_socketpair();
476 bool ret = torture_local_replace(NULL);