]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/frsh/frsh_api/tests/negotiation.c
Get rid of the most of other warnings
[frescor/frsh-forb.git] / src / frsh / frsh_api / tests / negotiation.c
1 #include <frsh.h>
2 #include <error.h>
3 #include <res_dummy.h>
4 #include <getopt.h>
5 #include <ul_logreg.h>
6 #include <wvtest.h>
7
8 WVTEST_MAIN("single negotiation and cancelation")
9 {
10         frsh_contract_t contract, c;
11         frsh_vres_id_t vres;
12         frsh_rel_time_t budget, period, deadline;
13
14         setenv("WVTEST_DIE_FAST", "", 1);
15         WVFRSH(frsh_init());
16
17         /* Negotiate the contract */
18         WVFRSH(frsh_contract_init(&contract));
19         
20         WVFRSH(frsh_contract_set_resource_and_label(
21                              &contract,
22                              DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
23                              NULL));
24         
25         budget = fosa_msec_to_rel_time(10);
26         period = fosa_msec_to_rel_time(100);
27         deadline = fosa_msec_to_rel_time(50);
28         WVFRSH(frsh_contract_set_basic_params(&contract,
29                                                     &budget,
30                                                     &period,
31                                                     FRSH_WT_BOUNDED,
32                                                     FRSH_CT_REGULAR));
33         
34         WVFRSH(frsh_contract_set_timing_reqs(&contract,
35                                                    false, &deadline));
36         
37         WVFRSH(frsh_contract_negotiate(&contract, &vres));
38         WVFRSH(frsh_vres_get_contract(vres, &c));
39         WVPASS(fres_contract_get_budget(&c, &budget));
40         WVPASS(fosa_rel_time_to_msec(budget) == 10);
41
42         /* Cancel the contract */
43         WVFRSH(frsh_contract_cancel(vres));
44
45         frsh_destroy();
46 }