]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - fwp/tests/fwp_mngrtest/fwp_mngrtest.c
Bug Fix: mngr_commit: fwp_msg_contracthdr_out( msgb->tail changed to msgb->data
[frescor/fwp.git] / fwp / tests / fwp_mngrtest / fwp_mngrtest.c
1 #include "fwp.h"
2 #include "fwp_contract.h"
3
4 #include <errno.h>
5 #include <stdio.h>
6
7 int main()
8 {
9         int i,rc; 
10         fwp_vres_d_t vres_d1, vres_d2;
11         fwp_contract_d_t cnt1d, cnt2d;
12
13         fwp_contract_t cnt1;
14         fwp_contract_t cnt2;
15         fwp_contract_t cnt3;
16
17         cnt1.budget = 100;
18         cnt1.period_usec = 10000;
19
20         cnt2.budget = 120;
21         cnt2.period_usec = 1000;
22
23         cnt3.budget = 130;
24         cnt3.period_usec = 2000;
25         
26         printf("Start\n");
27         if (fwp_init() != 0) {
28                 printf("fwp_init failed!\n");
29                 return -1;
30         }       
31
32         cnt1d = fwp_contract_create(&cnt1);
33         fwp_contract_negotiate(cnt1d, &vres_d1);
34         if (fwp_contract_is_negotiated(cnt1d)) {
35                 printf("Contract1 negotiated.\n");
36         }else 
37                 printf("Contract1 not negotiated.\n");
38
39         cnt2d = fwp_contract_create(&cnt2);
40         fwp_contract_negotiate(cnt2d, &vres_d2);
41         if (fwp_contract_is_negotiated(cnt2d)) {
42                 printf("Contract2 negotiated.\n");
43         }else 
44                 printf("Contract2 not negotiated.\n");
45 #if 0
46         rc = fwp_contract_negotiate(&cnt1, &vres_d);
47         if (rc == FWP_CONTNEGT_ACCEPTED) {
48                 printf("Contract 1 negotiated\n");
49         } else 
50                 printf("Contract 1 rejected.\n");
51         
52         rc = fwp_contract_negotiate(&cnt2, &vres_d);
53         if (rc == FWP_CONTNEGT_ACCEPTED) {
54                 printf("Contract 2 negotiated\n");
55         } else 
56                 printf("Contract 2  rejected.\n");
57         
58         rc = fwp_contract_negotiate(&cnt3, &vres_d);
59         if (rc == FWP_CONTNEGT_ACCEPTED) {
60                 printf("Contract 3 negotiated\n");
61         } else 
62                 printf("Contract 3 rejected.\n");
63
64 //      printf("Contract negotiated\n");
65
66         printf("Test PASSED!\n");
67
68 //      scanf("Press key%d",&vres_id1); 
69 #endif  
70         return 0;
71 }