diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-05-06 13:59:58 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-05-06 13:59:58 +0000 |
commit | f48ac720df06aa62eab2bad1fb857140a75753a9 (patch) | |
tree | 81b2152770871f9d851353965ddc4d8e5a12ed27 | |
parent | d0860f8a023083dee61912761a5515905d4e6550 (diff) | |
download | samba-f48ac720df06aa62eab2bad1fb857140a75753a9.tar.gz samba-f48ac720df06aa62eab2bad1fb857140a75753a9.tar.xz samba-f48ac720df06aa62eab2bad1fb857140a75753a9.zip |
merge from head
-rw-r--r-- | source/tests/fcntl_lock.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/source/tests/fcntl_lock.c b/source/tests/fcntl_lock.c index 32aecb87439..d03efb35b33 100644 --- a/source/tests/fcntl_lock.c +++ b/source/tests/fcntl_lock.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,11 +44,17 @@ int main(int argc, char *argv[]) int fd, ret, status=1; pid_t pid; + alarm(10); + if (!(pid=fork())) { sleep(2); fd = open(DATA, O_RDONLY); - if (fd == -1) exit(1); + if (fd == -1) { + fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", + DATA, (int)errno); + exit(1); + } lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -59,13 +69,21 @@ 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); } else { exit(0); } } - fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600); + unlink(DATA); + fd = open(DATA, O_RDWR|O_CREAT|O_EXCL, 0600); + + if (fd == -1) { + fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", + DATA, (int)errno); + exit(1); + } lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -90,5 +108,10 @@ int main(int argc, char *argv[]) status = (status == 0) ? 0 : 1; #endif /* defined(WIFEXITED) && defined(WEXITSTATUS) */ + if (status) { + fprintf(stderr,"ERROR: lock test failed with status=%d\n", + status); + } + exit(status); } |