[Pkg-wmaker-commits] [wmbiff] 08/09: ensure that sock_connect works with IP addresses

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:05:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_23
in repository wmbiff.

commit 70762d80adf04023dfac60f6ed67fddef86d6e03
Author: bluehal <bluehal>
Date:   Tue Apr 27 23:31:57 2004 +0000

    ensure that sock_connect works with IP addresses
---
 wmbiff/test_wmbiff.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/wmbiff/test_wmbiff.c b/wmbiff/test_wmbiff.c
index 5c2ef8b..668c416 100644
--- a/wmbiff/test_wmbiff.c
+++ b/wmbiff/test_wmbiff.c
@@ -347,6 +347,38 @@ int test_charutil(void) {
     return 0;
 }
 
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+int test_sock_connect(void) {
+    struct sockaddr_in addr;
+    int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    int addrlen = sizeof(struct sockaddr_in);
+    if( s < 0 ) {
+        perror("socket");
+        return 1;
+    }
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = 0;
+    addr.sin_port = 0;
+    if( bind(s, &addr, sizeof(struct sockaddr_in)) < 0 ) {
+        perror("bind");
+        return 1;
+    }
+    getsockname(s, &addr, &addrlen);
+    if( listen(s,5) < 0 ) {
+        perror("listen");
+        return 1;
+    }
+    if( sock_connect("127.0.0.1", addr.sin_port) < 0) {
+        return 1;
+    }
+    if( sock_connect("localhost", addr.sin_port) < 0) {
+        return 1;
+    }
+    return 0;
+}
+
 
 int print_info(UNUSED(void *state))
 {
@@ -399,6 +431,11 @@ int main(UNUSED(int argc), UNUSED(char *argv[]))
 		exit(EXIT_FAILURE);
 	}
 
+	if (test_sock_connect()) {
+		printf("SOME TESTS FAILED!\n");
+		exit(EXIT_FAILURE);
+	}
+
 	printf("Success! on all tests.\n");
 	exit(EXIT_SUCCESS);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list