2 * test_c_rtep_frsh_fna.c
6 * The goal of this program is to test the RTEP functions defined at frsh_fna.h
7 * which is the public part of frsh_fna.h. The interface of this public part
8 * is dependent of the underlying network protocol. We are not trying here to
9 * make a very intense test but a simple and basic one to check the correct
10 * behaviour of the functions.
14 * First we check the conversions between frsh and rtep addresses and streams.
15 * Then, we check the renegotiation functions for the period of the internal
16 * negotiation messages. And finally, we check the renegotiation functions for
17 * the internal service thread.
21 #include <assert.h> // for assert
22 #include <stdio.h> // for printf
23 #include <stdbool.h> // for bool
25 #include "frsh_core_types.h" // for FRSH_RESOURCE_ID_DEFAULT
26 #include "frsh_distributed_types.h" // frsh_network_address_t, frsh_stream_id_t
28 #include "rtep_fna.h" // for rtep_fna_operations.fna_init
29 #include "rtep.h" // for rtep_station_id_t, rtep_channel_t
31 #include "frsh_fna.h" // for frsh_rtep_*
36 rtep_station_id_t rtep_station = 3;
37 frsh_network_address_t frsh_address;
38 rtep_channel_t in_stream = 7;
39 frsh_stream_id_t out_stream;
40 struct timespec neg_period = {2,0};
41 struct timespec get_period = {0,0};
42 struct timespec rtep_serv_thread_budget = {1,0};
43 struct timespec rtep_serv_thread_period = {5,0};
44 bool serv_thread_renegotiation_accepted = false;
45 struct timespec current_serv_thread_budget = {0,0};
46 struct timespec current_serv_thread_period = {0,0};
48 printf("1.- fna_init\n");
49 err=rtep_fna_operations.fna_init(FRSH_RESOURCE_ID_DEFAULT);
52 printf("2.- frsh_rtep_map_network_address\n");
53 err=frsh_rtep_map_network_address
54 (FRSH_RESOURCE_ID_DEFAULT, rtep_station, &frsh_address);
56 printf("rtep_address:%d -> frsh_address:%d\n", rtep_station, frsh_address);
57 assert(rtep_station == frsh_address);
59 printf("3.- frsh_rtep_map_stream_id\n");
60 err=frsh_rtep_map_stream_id
61 (FRSH_RESOURCE_ID_DEFAULT, in_stream, &out_stream);
63 printf("rtep_channel:%d -> frsh_stream:%d\n", in_stream, out_stream);
64 assert(in_stream == out_stream);
66 printf("4.- frsh_rtep_negotiation_messages_vres_renegotiate period\n");
67 err=frsh_rtep_negotiation_messages_vres_get_period
68 (FRSH_RESOURCE_ID_DEFAULT, &get_period);
70 printf("period before renegotiation: sec=%d nsec=%d\n",
71 get_period.tv_sec, get_period.tv_nsec);
73 err=frsh_rtep_negotiation_messages_vres_renegotiate
74 (FRSH_RESOURCE_ID_DEFAULT, &neg_period);
76 printf("renegotiation accepted (period negotiated: sec=%d nsec=%d)\n",
77 neg_period.tv_sec, neg_period.tv_nsec);
79 printf("renegotiation not accepted\n");
83 err=frsh_rtep_negotiation_messages_vres_get_period
84 (FRSH_RESOURCE_ID_DEFAULT, &get_period);
86 printf("period after renegotiation: sec=%d nsec=%d\n",
87 get_period.tv_sec, get_period.tv_nsec);
89 // TODO: uncomment step 5 when internal thread has a frescor contract
90 // printf("5.- frsh_rtep_service_thread_vres_renegotiate\n");
92 // err=frsh_rtep_service_thread_vres_get_budget_and_period
93 // (FRSH_RESOURCE_ID_DEFAULT,
94 // ¤t_serv_thread_budget,
95 // ¤t_serv_thread_period);
97 // printf("service thread budget (before renegotiation): sec=%d nsec=%d\n",
98 // current_serv_thread_budget.tv_sec,
99 // current_serv_thread_budget.tv_nsec);
100 // printf("service thread period (before renegotiation): sec=%d nsec=%d\n",
101 // current_serv_thread_period.tv_sec,
102 // current_serv_thread_period.tv_nsec);
104 // err=frsh_rtep_service_thread_vres_renegotiate
105 // (FRSH_RESOURCE_ID_DEFAULT,
106 // &rtep_serv_thread_budget,
107 // &rtep_serv_thread_period,
108 // &serv_thread_renegotiation_accepted);
111 // if (serv_thread_renegotiation_accepted) {
112 // printf("service_thread renegotiation accepted\n");
114 // printf("service_thread renegotiation not accepted\n");
116 // assert (err == 0);
118 // err=frsh_rtep_service_thread_vres_get_budget_and_period
119 // (FRSH_RESOURCE_ID_DEFAULT,
120 // ¤t_serv_thread_budget,
121 // ¤t_serv_thread_period);
123 // printf("service thread budget (after renegotiation): sec=%d nsec=%d\n",
124 // current_serv_thread_budget.tv_sec,
125 // current_serv_thread_budget.tv_nsec);
126 // printf("service thread period (after renegotiation): sec=%d nsec=%d\n",
127 // current_serv_thread_period.tv_sec,
128 // current_serv_thread_period.tv_nsec);
130 printf("\nEND of the TEST\n");