diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-10-18 16:08:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:21:24 -0500 |
commit | f9a0ada725b012261ec9460185105f57206c70c3 (patch) | |
tree | a636a077c0ae4d64e27044c0750a669583985fb3 /source4/lib/replace/test | |
parent | a39f239cb28e4ac6be207d4179bacffce97f1b3e (diff) | |
download | samba-f9a0ada725b012261ec9460185105f57206c70c3.tar.gz samba-f9a0ada725b012261ec9460185105f57206c70c3.tar.bz2 samba-f9a0ada725b012261ec9460185105f57206c70c3.zip |
r19393: Add replacement function for socketpair()
(This used to be commit 448a3ecc0184bfa063db1eb3ae6dc16b8b792792)
Diffstat (limited to 'source4/lib/replace/test')
-rw-r--r-- | source4/lib/replace/test/testsuite.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 3e20e22e45..e921a7fc97 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -376,6 +376,46 @@ static int test_MAX(void) return true; } +static bool 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[0], "automatisch", 12) == -1) { + printf("failure: socketpair [\n" + "write() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (read(sock[1], 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; int main() @@ -424,6 +464,7 @@ int main() ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); + ret &= test_socketpair(); if (ret) return 0; |