svn commit: samba r18041 - in
branches/SAMBA_4_0/source/lib/replace: . test
tridge at samba.org
tridge at samba.org
Mon Sep 4 13:10:59 GMT 2006
Author: tridge
Date: 2006-09-04 13:10:49 +0000 (Mon, 04 Sep 2006)
New Revision: 18041
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18041
Log:
started on the bodies of the testsuite functions for libreplace
Modified:
branches/SAMBA_4_0/source/lib/replace/Makefile.in
branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/Makefile.in
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/Makefile.in 2006-09-04 13:10:14 UTC (rev 18040)
+++ branches/SAMBA_4_0/source/lib/replace/Makefile.in 2006-09-04 13:10:49 UTC (rev 18041)
@@ -13,7 +13,7 @@
OBJS = dlfcn.o getpass.o replace.o snprintf.o
-all: libreplace.a
+all: libreplace.a testsuite
install: all
mkdir -p $(libdir)
Modified: branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-04 13:10:14 UTC (rev 18040)
+++ branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-04 13:10:49 UTC (rev 18041)
@@ -27,9 +27,51 @@
#include "../replace.h"
#include <stdio.h>
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if HAVE_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#include <fcntl.h>
+#include <errno.h>
+
+#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;
}
More information about the samba-cvs
mailing list