svn commit: samba r20818 - in branches/SAMBA_3_0_24/source/lib/replace: . system test

metze at samba.org metze at samba.org
Mon Jan 15 19:20:34 GMT 2007


Author: metze
Date: 2007-01-15 19:20:34 +0000 (Mon, 15 Jan 2007)
New Revision: 20818

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20818

Log:
sync lib/replace with samba4

metze
Added:
   branches/SAMBA_3_0_24/source/lib/replace/.checker_innocent
   branches/SAMBA_3_0_24/source/lib/replace/system/aio.h
Modified:
   branches/SAMBA_3_0_24/source/lib/replace/README
   branches/SAMBA_3_0_24/source/lib/replace/libreplace.m4
   branches/SAMBA_3_0_24/source/lib/replace/libreplace_cc.m4
   branches/SAMBA_3_0_24/source/lib/replace/replace.c
   branches/SAMBA_3_0_24/source/lib/replace/replace.h
   branches/SAMBA_3_0_24/source/lib/replace/snprintf.c
   branches/SAMBA_3_0_24/source/lib/replace/system/kerberos.h
   branches/SAMBA_3_0_24/source/lib/replace/system/wait.h
   branches/SAMBA_3_0_24/source/lib/replace/test/os2_delete.c
   branches/SAMBA_3_0_24/source/lib/replace/test/testsuite.c


Changeset:
Added: branches/SAMBA_3_0_24/source/lib/replace/.checker_innocent
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/.checker_innocent	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/.checker_innocent	2007-01-15 19:20:34 UTC (rev 20818)
@@ -0,0 +1,4 @@
+>>>MISTAKE21_create_files_6a9e68ada99a97cb
+>>>MISTAKE21_os2_delete_9b2bfa7f38711d09
+>>>MISTAKE21_os2_delete_2fcc29aaa99a97cb
+>>>SECURITY2_os2_delete_9b2bfa7f1c9396ca

Modified: branches/SAMBA_3_0_24/source/lib/replace/README
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/README	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/README	2007-01-15 19:20:34 UTC (rev 20818)
@@ -52,6 +52,7 @@
 inet_ntoa
 strtoll
 strtoull
+socketpair
 
 Types:
 bool

Modified: branches/SAMBA_3_0_24/source/lib/replace/libreplace.m4
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/libreplace.m4	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/libreplace.m4	2007-01-15 19:20:34 UTC (rev 20818)
@@ -62,6 +62,7 @@
 AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
 
 AC_CHECK_HEADERS(stdbool.h sys/select.h)
+AC_CHECK_HEADERS(setjmp.h)
 
 AC_CHECK_TYPE(bool, 
 [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
@@ -147,7 +148,7 @@
 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
 AC_HAVE_DECL(errno, [#include <errno.h>])

Modified: branches/SAMBA_3_0_24/source/lib/replace/libreplace_cc.m4
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/libreplace_cc.m4	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/libreplace_cc.m4	2007-01-15 19:20:34 UTC (rev 20818)
@@ -140,23 +140,27 @@
 
 ############################################
 # check if the compiler can do immediate structures
-AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
-    AC_TRY_COMPILE([
-#include <stdio.h>],
-[
-   typedef struct {unsigned x;} FOOBAR;
-   #define X_FOOBAR(x) ((FOOBAR) { x })
-   #define FOO_ONE X_FOOBAR(1)
-   FOOBAR f = FOO_ONE;   
-   static const struct {
-	FOOBAR y; 
-	} f2[] = {
-		{FOO_ONE}
-	};   
-],
-	samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
-if test x"$samba_cv_immediate_structures" = x"yes"; then
-   AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
+AC_SUBST(libreplace_cv_immediate_structures)
+AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
+	AC_TRY_COMPILE([
+		#include <stdio.h>
+	],[
+		typedef struct {unsigned x;} FOOBAR;
+		#define X_FOOBAR(x) ((FOOBAR) { x })
+		#define FOO_ONE X_FOOBAR(1)
+		FOOBAR f = FOO_ONE;   
+		static const struct {
+			FOOBAR y; 
+		} f2[] = {
+			{FOO_ONE}
+		};   
+	],
+	libreplace_cv_immediate_structures=yes,
+	libreplace_cv_immediate_structures=no,
+	libreplace_cv_immediate_structures=cross)
+])
+if test x"$libreplace_cv_immediate_structures" = x"yes"; then
+	AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
 fi
 
 AC__LIBREPLACE_ONLY_CC_CHECKS_END

Modified: branches/SAMBA_3_0_24/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/replace.c	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/replace.c	2007-01-15 19:20:34 UTC (rev 20818)
@@ -590,3 +590,24 @@
 }
 #endif
 
+#ifndef HAVE_SOCKETPAIR
+int rep_socketpair(int d, int type, int protocol, int sv[2])
+{
+	if (d != AF_UNIX) {
+		errno = EAFNOSUPPORT;
+		return -1;
+	}
+
+	if (protocol != 0) {
+		errno = EPROTONOSUPPORT;
+		return -1;
+	}
+
+	if (type != SOCK_STREAM) {
+		errno = EOPNOTSUPP;
+		return -1;
+	}
+
+	return pipe(sv);
+}
+#endif

Modified: branches/SAMBA_3_0_24/source/lib/replace/replace.h
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/replace.h	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/replace.h	2007-01-15 19:20:34 UTC (rev 20818)
@@ -209,6 +209,10 @@
 int rep_dlclose(void *handle);
 #endif
 
+#ifndef HAVE_SOCKETPAIR
+#define socketpair rep_socketpair
+int rep_socketpair(int d, int type, int protocol, int sv[2]);
+#endif
 
 #ifndef PRINTF_ATTRIBUTE
 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )

Modified: branches/SAMBA_3_0_24/source/lib/replace/snprintf.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/snprintf.c	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/snprintf.c	2007-01-15 19:20:34 UTC (rev 20818)
@@ -540,7 +540,7 @@
 			printf("parameter at position %d not used\n", pnum+1);
 #endif
 			/* eat the parameter */
-			(void)va_arg (args, int);
+			va_arg (args, int);
 			continue;
 		}
 		for (i = 1; i < clist[pnum].num; i++) {

Added: branches/SAMBA_3_0_24/source/lib/replace/system/aio.h
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/system/aio.h	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/system/aio.h	2007-01-15 19:20:34 UTC (rev 20818)
@@ -0,0 +1,29 @@
+#ifndef _system_aio_h
+#define _system_aio_h
+/* 
+   Unix SMB/CIFS implementation.
+
+   AIO system include wrappers
+
+   Copyright (C) Andrew Tridgell 2006
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#if HAVE_LIBAIO_H
+#include <libaio.h>
+#endif
+
+#endif

Modified: branches/SAMBA_3_0_24/source/lib/replace/system/kerberos.h
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/system/kerberos.h	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/system/kerberos.h	2007-01-15 19:20:34 UTC (rev 20818)
@@ -126,7 +126,6 @@
 #define KRB5_PRINC_REALM_RETURNS_REALM 1
 
 #include "heimdal/lib/krb5/krb5.h"
-#include "heimdal/lib/gssapi/gssapi.h"
 #include "heimdal/lib/com_err/com_err.h"
 #endif
 

Modified: branches/SAMBA_3_0_24/source/lib/replace/system/wait.h
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/system/wait.h	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/system/wait.h	2007-01-15 19:20:34 UTC (rev 20818)
@@ -36,4 +36,8 @@
 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
 #endif
 
+#ifdef HAVE_SETJMP_H
+#include <setjmp.h>
 #endif
+
+#endif

Modified: branches/SAMBA_3_0_24/source/lib/replace/test/os2_delete.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/test/os2_delete.c	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/test/os2_delete.c	2007-01-15 19:20:34 UTC (rev 20818)
@@ -20,9 +20,8 @@
 #define TESTDIR "test.dir"
 
 static int test_readdir_os2_delete_ret;
-int test_readdir_os2_delete(void);
 
-#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
+#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
 
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
@@ -108,7 +107,7 @@
 	}
 	closedir(d);
 
-	printf("Deleted %d files of %d\n", total_deleted, NUM_FILES);
+	fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES);
 
 	rmdir(TESTDIR) == 0 || FAILED("rmdir");
 

Modified: branches/SAMBA_3_0_24/source/lib/replace/test/testsuite.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/replace/test/testsuite.c	2007-01-15 19:10:54 UTC (rev 20817)
+++ branches/SAMBA_3_0_24/source/lib/replace/test/testsuite.c	2007-01-15 19:20:34 UTC (rev 20818)
@@ -57,26 +57,29 @@
 	struct stat st;
 	int fd;
 	const int size = 1234;
-	printf("testing ftruncate\n");
+	printf("test: ftruncate\n");
 	unlink(TESTFILE);
 	fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
 	if (fd == -1) {
-		printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno));
+		printf("failure: ftruncate [\n"
+			   "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno));
 		return false;
 	}
 	if (ftruncate(fd, size) != 0) {
-		printf("ftruncate failed - %s\n", strerror(errno));
+		printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
 		return false;
 	}
 	if (fstat(fd, &st) != 0) {
-		printf("fstat failed - %s\n", strerror(errno));
+		printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
 		return false;
 	}
 	if (st.st_size != size) {
-		printf("ftruncate gave wrong size %d - expected %d\n",
+		printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
 		       (int)st.st_size, size);
 		return false;
 	}
+	unlink(TESTFILE);
+	printf("success: ftruncate\n");
 	return true;
 }
 
@@ -98,13 +101,14 @@
 		{ NULL, 0 }
 	};
 	int i;
-	printf("testing strlcpy\n");
+	printf("test: strlcpy\n");
 	for (i=0;tests[i].src;i++) {
 		if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
-			printf("strlcpy test %d failed\n", i);
+			printf("failure: strlcpy [\ntest %d failed\n]\n", i);
 			return false;
 		}
 	}
+	printf("success: strlcpy\n");
 	return true;
 }
 
@@ -146,8 +150,9 @@
 
 static int test_setlinebuf(void)
 {
-	printf("testing setlinebuf\n");
+	printf("test: setlinebuf\n");
 	setlinebuf(stdout);
+	printf("success: setlinebuf\n");
 	return true;
 }
 
@@ -233,10 +238,11 @@
 
 static int test_readdir(void)
 {
-	printf("testing readdir\n");
+	printf("test: readdir\n");
 	if (test_readdir_os2_delete() != 0) {
 		return false;
 	}
+	printf("success: readdir\n");
 	return true;
 }
 
@@ -371,9 +377,48 @@
 	return true;
 }
 
+static int test_socketpair(void)
+{
+	int sock[2];
+	char buf[20];
+
+	printf("test: socketpair\n");
+
+	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
+		printf("failure: socketpair [\n"
+			   "socketpair() failed\n"
+			   "]\n");
+		return false;
+	}
+
+	if (write(sock[1], "automatisch", 12) == -1) {
+		printf("failure: socketpair [\n"
+			   "write() failed: %s\n"
+			   "]\n", strerror(errno));
+		return false;
+	}
+
+	if (read(sock[0], buf, 12) == -1) {
+		printf("failure: socketpair [\n"
+			   "read() failed: %s\n"
+			   "]\n", strerror(errno));
+		return false;
+	}
+
+	if (strcmp(buf, "automatisch") != 0) {
+		printf("failure: socketpair [\n"
+			   "expected: automatisch, got: %s\n"
+			   "]\n", buf);
+		return false;
+	}
+
+	printf("success: socketpair\n");
+
+	return true;
+}
+
 struct torture_context;
-
-static bool torture_local_replace(struct torture_context *torture)
+bool torture_local_replace(struct torture_context *ctx)
 {
 	bool ret = true;
 	ret &= test_ftruncate();
@@ -419,17 +464,17 @@
 	ret &= test_FUNCTION();
 	ret &= test_MIN();
 	ret &= test_MAX();
+	ret &= test_socketpair();
 
 	return ret;
 }
 
 #if _SAMBA_BUILD_<4
-int main(void)
+int main()
 {
-	if (!torture_local_replace(NULL)) {
-		printf("ERROR: TESTSUITE FAILED\n");
-		return -1;
-	}
-	return 0;
+	bool ret = torture_local_replace(NULL);
+	if (ret) 
+		return 0;
+	return -1;
 }
 #endif



More information about the samba-cvs mailing list