[klee-commits] [1503] Added test case for local side socket creation.
cristic at stanford.edu
cristic at stanford.edu
Mon Mar 16 21:35:20 PDT 2009
Revision: 1503
http://keeda.stanford.edu/viewvc/viewvc.cgi?view=rev&revision=1503
Author: cristic
Date: 2009-03-16 21:35:19 -0700 (Mon, 16 Mar 2009)
Log Message:
-----------
Added test case for local side socket creation.
Added Paths:
-----------
test/SimpleModel/SocketLocal.c
Added: test/SimpleModel/SocketLocal.c
===================================================================
--- test/SimpleModel/SocketLocal.c (rev 0)
+++ test/SimpleModel/SocketLocal.c 2009-03-17 04:35:19 UTC (rev 1503)
@@ -0,0 +1,58 @@
+// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc
+// RUN: %klee --with-file-model=release %t1.bc > %t.log
+// RUN: grep -q "Success" %t.log
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <linux/net.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main(int argc, char **argv) {
+ struct sockaddr_in server_addr, client_addr;
+
+ int socket_fd = socket(AF_INET, SOCK_STREAM, 0);
+ //fprintf(stderr, "socket_fd = %d\n", socket_fd);
+
+ if (socket_fd < 0) {
+ perror("socket() returned error\n");
+ exit(1);
+ }
+
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_addr.s_addr = INADDR_ANY;
+ server_addr.sin_port = 80;
+
+ int r = bind(socket_fd, (struct sockaddr *) &server_addr,
+ sizeof(server_addr));
+ if (r < 0) {
+ perror("bind() returned error\n");
+ exit(1);
+ }
+
+ r = listen(socket_fd, 1);
+ if (r < 0) {
+ perror("listen() returned error\n");
+ exit(1);
+ }
+
+ r = close(socket_fd);
+ if (r < 0) {
+ perror("close() returned error\n");
+ exit(1);
+ }
+
+ printf("Success\n");
+
+ return 0;
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://keeda.Stanford.EDU/pipermail/klee-commits/attachments/20090316/01a3248c/attachment-0001.html
More information about the klee-commits
mailing list