summaryrefslogtreecommitdiff
path: root/source3/tests
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2007-05-07 03:02:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:21:51 -0500
commit3a9a3ad8f9ead7ec963103f8ee0fe905f3982913 (patch)
tree507297ba3aecd60d0700474e68a4d099e45d97e9 /source3/tests
parent63456681daa853174c42eaaa5a8d330d27c18383 (diff)
downloadsamba-3a9a3ad8f9ead7ec963103f8ee0fe905f3982913.tar.gz
samba-3a9a3ad8f9ead7ec963103f8ee0fe905f3982913.tar.bz2
samba-3a9a3ad8f9ead7ec963103f8ee0fe905f3982913.zip
r22731: - Fix bug #4594.
configure.in determines if -Werror-implicit-function-declaration is available, and if so it enables that flag if --enable-developer is specified. Since the configure tests themselves did not use that flag, it was possible for a configure test to succeed, followed by a failed compilation due to a facility being available but not having a proper declaration in a header file. (This bit me with readahead().) This patch ensures that if implicit function declarations will kill the build, the feature being tested is deselected so the build will succeed. The autoconf manual suggests using return instead of exit in configure tests because the declaration for exit is often missing. We require this now, since we error if prototypes are missing. See section 5.5.1 of http://www.gnu.org/software/autoconf/manual/autoconf.html. This patch makes these changes, because in fact, an external declaration for exit is missing here (and likely elsewhere). I've verified that the features selected (here) with the original configure.in and the new one are the same except for, in my case, readahead. I've also confirmed that the generated Makefile is identical. These changes are not being applied to the 3.0.26 branch because it does not exhibit the initial problem this patch is supposed to solve since it doesn't attempt to use -Werror-implicit-function-declaration. (This used to be commit 4d42720915b8f65842147171f689127e94d1b973)
Diffstat (limited to 'source3/tests')
-rw-r--r--source3/tests/crypttest.c6
-rw-r--r--source3/tests/fcntl_lock.c10
-rw-r--r--source3/tests/fcntl_lock64.c12
-rw-r--r--source3/tests/ftruncate.c4
-rw-r--r--source3/tests/getgroups.c14
-rw-r--r--source3/tests/shared_mmap.c16
-rw-r--r--source3/tests/summary.c1
-rw-r--r--source3/tests/trivial.c1
-rw-r--r--source3/tests/unixsock.c21
9 files changed, 49 insertions, 36 deletions
diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c
index efee2e593d..8bed1c74d1 100644
--- a/source3/tests/crypttest.c
+++ b/source3/tests/crypttest.c
@@ -814,7 +814,7 @@ main()
if((strcmp(c_out1, expected_out) != 0) &&
(strcmp(c_out2, expected_out) == 0))
- exit(1);
+ return 1;
#ifdef HAVE_BIGCRYPT
/*
@@ -843,10 +843,10 @@ main()
if((strcmp(big_c_out1, big_expected_out) != 0) &&
(strcmp(big_c_out2, big_expected_out) == 0))
- exit(1);
+ return 1;
}
#endif
- exit(0);
+ return 0;
}
diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c
index 3dc12a3897..728f94b612 100644
--- a/source3/tests/fcntl_lock.c
+++ b/source3/tests/fcntl_lock.c
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
if (fd == -1) {
fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
DATA, (int)errno);
- exit(1);
+ return 1;
}
lock.l_type = F_WRLCK;
@@ -74,9 +74,9 @@ int main(int argc, char *argv[])
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno);
- exit(1);
+ return 1;
} else {
- exit(0);
+ return 0;
}
}
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
if (fd == -1) {
fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n",
DATA, (int)errno);
- exit(1);
+ return 1;
}
lock.l_type = F_WRLCK;
@@ -117,5 +117,5 @@ int main(int argc, char *argv[])
status);
}
- exit(status);
+ return status;
}
diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c
index e5ecd88fd0..b218fa9282 100644
--- a/source3/tests/fcntl_lock64.c
+++ b/source3/tests/fcntl_lock64.c
@@ -16,6 +16,10 @@
#include <sys/fcntl.h>
#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
#include <errno.h>
static int sys_waitpid(pid_t pid,int *status,int options)
@@ -40,7 +44,7 @@ int main(int argc, char *argv[])
sleep(2);
fd = open64(DATA, O_RDONLY);
- if (fd == -1) exit(1);
+ if (fd == -1) return 1;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
@@ -56,10 +60,10 @@ int main(int argc, char *argv[])
if ((ret == -1) ||
(lock.l_type == F_UNLCK)) {
/* printf("No lock conflict\n"); */
- exit(1);
+ return 1;
} else {
/* printf("lock conflict\n"); */
- exit(0);
+ return 0;
}
}
@@ -92,5 +96,5 @@ int main(int argc, char *argv[])
unlink(DATA);
- exit(status);
+ return status;
}
diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c
index 93282782ee..700d5c8ce5 100644
--- a/source3/tests/ftruncate.c
+++ b/source3/tests/ftruncate.c
@@ -21,7 +21,7 @@ main()
unlink(DATA);
if (lseek(fd, 0, SEEK_END) == LEN) {
- exit(0);
+ return 0;
}
- exit(1);
+ return 1;
}
diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c
index 343fd5a184..c73cd21650 100644
--- a/source3/tests/getgroups.c
+++ b/source3/tests/getgroups.c
@@ -11,6 +11,10 @@
#include <unistd.h>
#endif
+#if defined(HAVE_STDLIB_H)
+#include <stdlib.h>
+#endif
+
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
@@ -26,7 +30,7 @@ main()
if (sizeof(gid_t) == sizeof(int)) {
fprintf(stderr,"gid_t and int are the same size\n");
- exit(1);
+ return 1;
}
if (ngroups <= 0)
@@ -44,7 +48,7 @@ main()
if (ngroups == 0) {
printf("WARNING: can't determine getgroups return type\n");
- exit(1);
+ return 1;
}
cgroups = (char *)igroups;
@@ -52,15 +56,15 @@ main()
if (ngroups == 1 &&
cgroups[2] == 0x42 && cgroups[3] == 0x42) {
fprintf(stderr,"getgroups returns gid_t\n");
- exit(1);
+ return 1;
}
for (i=0;i<ngroups;i++) {
if (igroups[i] == 0x42424242) {
fprintf(stderr,"getgroups returns gid_t\n");
- exit(1);
+ return 1;
}
}
- exit(0);
+ return 0;
}
diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c
index fcef75d0d6..6af9ba0b39 100644
--- a/source3/tests/shared_mmap.c
+++ b/source3/tests/shared_mmap.c
@@ -22,7 +22,7 @@ main()
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
int count=7;
- if (fd == -1) exit(1);
+ if (fd == -1) return 1;
for (i=0;i<10000;i++) {
write(fd,&i,sizeof(i));
@@ -32,7 +32,7 @@ main()
if (fork() == 0) {
fd = open(DATA,O_RDWR);
- if (fd == -1) exit(1);
+ if (fd == -1) return 1;
buf = (int *)mmap(NULL, 10000*sizeof(int),
(PROT_READ | PROT_WRITE),
@@ -41,21 +41,21 @@ main()
while (count-- && buf[9124] != 55732) sleep(1);
- if (count <= 0) exit(1);
+ if (count <= 0) return 1;
buf[1763] = 7268;
- exit(0);
+ return 0;
}
fd = open(DATA,O_RDWR);
- if (fd == -1) exit(1);
+ if (fd == -1) return 1;
buf = (int *)mmap(NULL, 10000*sizeof(int),
(PROT_READ | PROT_WRITE),
MAP_FILE | MAP_SHARED,
fd, 0);
- if (buf == (int *)-1) exit(1);
+ if (buf == (int *)-1) return 1;
buf[9124] = 55732;
@@ -63,6 +63,6 @@ main()
unlink(DATA);
- if (count > 0) exit(0);
- exit(1);
+ if (count > 0) return 0;
+ return 1;
}
diff --git a/source3/tests/summary.c b/source3/tests/summary.c
index 79a530b013..735f93e116 100644
--- a/source3/tests/summary.c
+++ b/source3/tests/summary.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <stdio.h>
main()
diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c
index 2723637a0f..ae368a1398 100644
--- a/source3/tests/trivial.c
+++ b/source3/tests/trivial.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
main()
{
exit(0);
diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c
index f2765d68f6..ba384ae362 100644
--- a/source3/tests/unixsock.c
+++ b/source3/tests/unixsock.c
@@ -1,4 +1,5 @@
-/* -*- c-file-style: "linux" -*-
+/*
+ * -*- c-file-style: "linux" -*-
*
* Try creating a Unix-domain socket, opening it, and reading from it.
* The POSIX name for these is AF_LOCAL/PF_LOCAL.
@@ -8,15 +9,17 @@
* on which they are broken under some conditions, such as RedHat 7.0
* (unpatched). We can't build WinBind there at the moment.
*
- * Coding standard says to always use exit() for this, not return, so
- * we do.
- *
- * Martin Pool <mbp@samba.org>, June 2000. */
+ * Martin Pool <mbp@samba.org>, June 2000.
+ */
/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */
#include <stdio.h>
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
@@ -48,7 +51,7 @@ static int bind_socket(char const *filename)
/* Create the socket. */
if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
perror ("socket(PF_LOCAL, SOCK_STREAM)");
- exit(1);
+ return 1;
}
/* Bind a name to the socket. */
@@ -67,7 +70,7 @@ static int bind_socket(char const *filename)
if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) {
perror ("bind");
- exit(1);
+ return 1;
}
return sock_fd;
@@ -84,10 +87,10 @@ int main(void)
alarm(15); /* secs */
if ((sock_fd = bind_socket(filename)) < 0)
- exit(1);
+ return 1;
/* the socket will be deleted when autoconf cleans up these
files. */
- exit(0);
+ return 0;
}