2 * \file fwp_vrestest1.c
4 * This a test application that:
5 * - creates vres without negotiation
6 * - creates send and receive endpoint
7 * - binds that endpoint to vres
8 * - in cycle (NUM loops) sends messages and prints send time
13 #define CONFIGURE_FWP_MNGT 0
14 #include "fwp_confdefs.h"
19 #include <arpa/inet.h>
21 #define WVTEST_CONFIGURED
27 WVTEST_MAIN("FWP VRES single thread")
29 // struct sockaddr_in local_addr, rem_addr, from;
31 fwp_vres_t *vres1, *vres2;
32 struct fwp_vres_params vparam1;
35 struct fwp_endpoint *sepoint, *repoint;
37 struct timespec sendtime;
38 fwp_endpoint_attr_t attr;
41 fwp_endpoint_attr_init(&attr);
43 memset(&vparam1, 0, sizeof(vparam1));
44 vparam1.ac_id = FWP_AC_VO;
46 vparam1.period.tv_sec = 2;
47 vparam1.period.tv_nsec = 111111;
49 if (WVFAIL(fwp_init() != 0)) {
50 printf("fwp_init failed!\n");
54 if (WVFAIL(fwp_vres_create(&vparam1, &vres1) < 0)) {
55 printf("Unable to create vres1\n");
59 if (WVFAIL(fwp_vres_create(&vparam1, &vres2) < 0)) {
60 printf("Unable to create vres2\n");
64 /* local_addr should be handled when creating socket */
65 if (WVFAIL(fwp_receive_endpoint_create(7777, &attr, &repoint) < 0)) {
69 if (WVFAIL(fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr,
74 WVPASS(fwp_send_endpoint_bind(sepoint, vres1) == 0);
76 for (count = 0; count < NUM; count++) {
77 sprintf(msg1,"msg%d",count);
78 WVPASSEQ(fwp_send_sync(sepoint, msg1, sizeof(msg1)), sizeof(msg1));
80 clock_gettime(CLOCK_MONOTONIC, &sendtime);
81 printf("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
84 if (WVFAIL((len = fwp_recv(repoint, buffer, sizeof(buffer), &from, 0)) < 0)) {
85 perror("Error while receiving data");
88 else printf("Received - %s\n", buffer);
89 WVPASSEQSTR(msg1, buffer);
92 if (WVFAIL(fwp_vres_destroy(vres1) < 0)) {
93 perror("Unable to destroy vres1\n");
96 if (WVFAIL(fwp_vres_destroy(vres2) < 0)) {
97 perror("Unable to destroy vres1\n");
100 WVPASSEQ(fwp_endpoint_destroy(sepoint), 0);
101 WVPASSEQ(fwp_endpoint_destroy(repoint), 0);
102 printf("Vres1 detroyed\n");
103 printf("Test PASSED!\n");