]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
fwp_vrestest added
authorMartin Molnar <molnar@sum.(none)>
Wed, 20 Feb 2008 10:31:53 +0000 (11:31 +0100)
committerMartin Molnar <molnar@sum.(none)>
Wed, 20 Feb 2008 10:31:53 +0000 (11:31 +0100)
fwp/tests/fwp_vrestest/Makefile [new file with mode: 0644]
fwp/tests/fwp_vrestest/Makefile.omk [new file with mode: 0644]
fwp/tests/fwp_vrestest/fwp_vrestest.c [new file with mode: 0644]

diff --git a/fwp/tests/fwp_vrestest/Makefile b/fwp/tests/fwp_vrestest/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/fwp/tests/fwp_vrestest/Makefile.omk b/fwp/tests/fwp_vrestest/Makefile.omk
new file mode 100644 (file)
index 0000000..df9284b
--- /dev/null
@@ -0,0 +1,3 @@
+test_PROGRAMS = fwp_vrestest
+fwp_vrestest_SOURCES+= fwp_vrestest.c
+lib_LOADLIBES += fwp pthread rt 
diff --git a/fwp/tests/fwp_vrestest/fwp_vrestest.c b/fwp/tests/fwp_vrestest/fwp_vrestest.c
new file mode 100644 (file)
index 0000000..8779283
--- /dev/null
@@ -0,0 +1,66 @@
+#include "fwp_vres.h"
+#include "fwp_proto.h"
+#include "fwp_msgb.h"
+#include "fwp_endpoint.h"
+
+#include <errno.h>
+#include <stdio.h>
+
+int main()
+{
+//     struct sockaddr_in local_addr, rem_addr, from;
+        ssize_t len;
+       int vres_id1;
+       struct fwp_vres_params vparam1;
+       char msg1[] = "Hello1";
+       char buffer[30];
+       int sepoint_id1, repoint_id;
+       int count;
+
+       vparam1.ac_id = FWP_AC_VO; 
+       vparam1.budget = 100;
+       vparam1.period_usec = 200000; 
+
+       printf("Start\n");
+       fwp_init();
+       
+       printf("Create vres1\n");
+       if ((vres_id1 = fwp_vres_open(&vparam1) < 0)) {
+               printf("fw_vres_open - Unable to open vres1\n");
+               return -1;
+       }
+       printf("Vres1 created with vresid1= %d \n",vres_id1);
+       
+       /* local_addr should be handled when creating socket */
+       if ((repoint_id = fwp_receive_endpoint_create(7777)) < 0){
+               return -1;
+       }
+       printf("Receive endpoint created\n");
+       
+       sepoint_id1 = fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777);
+       if (sepoint_id1 < 0){
+               return -1;
+       }
+       printf("Send endpoint 1 created\n");
+       fwp_send_endpoint_bind(sepoint_id1, vres_id1);
+       
+       count = 0;
+       while (1) {     
+               fwp_send(sepoint_id1, msg1, sizeof(msg1));
+               printf("count= %d\n", count++);
+               if ((len = fwp_recv(repoint_id, buffer, sizeof(buffer))) < 0) {
+                       perror("Error while receiving data");
+                       return -1;
+               } 
+                       else printf("Received - %s\n", buffer);
+       }
+
+       if ((vres_id1 = fwp_vres_close(vres_id1) < 0)) {
+               perror("fw_vres_close - Unable to close vres1\n");
+               return -1;
+       }
+       printf("Vres1 closed\n");
+
+       printf("Test PASSED!\n");
+       return 0;
+}