]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_rtep/tests/test_c_rtep_frsh_fna.c
fna tests
[frescor/fna.git] / src_rtep / tests / test_c_rtep_frsh_fna.c
1 #include <misc/assert.h> // for assert
2 #include <stdio.h> // for printf
3
4 #include "frsh_core_types.h" // for FRSH_RESOURCE_ID_DEFAULT
5 #include "frsh_distributed_types.h" // for frsh_network_address_t, frsh_stream_id_t
6 #include "fna.h" // for fna_init
7 #include "frsh_fna.h" // for frsh_rtep_*
8 #include "rtep.h" // for rtep_station_id_t, rtep_channel_t
9
10 int main ()
11 {
12    int err;
13    rtep_station_id_t rtep_station = 3;
14    frsh_network_address_t frsh_address;
15    rtep_channel_t in_stream = 7;
16    frsh_stream_id_t out_stream;
17    struct timespec neg_period = {2,0};
18    struct timespec get_period = {0,0};
19
20    printf("1.- fna_init\n");
21    printf("--------------------------------------------------\n");
22    err=fna_init(FRSH_RESOURCE_ID_DEFAULT);
23    assert(err == 0);
24
25    printf("2.- frsh_rtep_map_network_address\n");
26    printf("--------------------------------------------------\n");
27    err=frsh_rtep_map_network_address
28          (FRSH_RESOURCE_ID_DEFAULT, rtep_station, &frsh_address);
29    assert(err == 0);
30    printf("rtep_address: %d, frsh_address: %d\n", rtep_station, frsh_address);
31    assert(rtep_station == frsh_address);
32
33    printf("3.- frsh_rtep_map_stream_id\n");
34    printf("--------------------------------------------------\n");
35    err=frsh_rtep_map_stream_id
36          (FRSH_RESOURCE_ID_DEFAULT, in_stream, &out_stream);
37    assert(err == 0);
38    printf("rtep_channel: %d, frsh_stream: %d\n", in_stream, out_stream);
39    assert(in_stream == out_stream);
40
41    printf("4.- frsh_rtep_negotiation_messages_vres_renegotiate period\n");
42    printf("--------------------------------------------------\n");
43    err=frsh_rtep_negotiation_messages_vres_get_period
44          (FRSH_RESOURCE_ID_DEFAULT, &get_period);
45    assert(err == 0);
46    printf("get_period sec=%d nsec=%d\n", get_period.tv_sec, get_period.tv_nsec);
47
48    err=frsh_rtep_negotiation_messages_vres_renegotiate
49          (FRSH_RESOURCE_ID_DEFAULT, &neg_period);
50    printf("renegotiation accepted: %d\n", !err);
51    assert(err == 0);
52
53    err=frsh_rtep_negotiation_messages_vres_get_period
54          (FRSH_RESOURCE_ID_DEFAULT, &get_period);
55    assert(err == 0);
56    printf("get_period sec=%d nsec=%d\n", get_period.tv_sec, get_period.tv_nsec);
57
58    return 0;
59 }