]> rtime.felk.cvut.cz Git - frescor/frsh.git/blob - frsh_api/tests/trans_nego.c
Small fixes
[frescor/frsh.git] / frsh_api / tests / trans_nego.c
1 #include <frsh.h>
2 #include <wvtest.h>
3 #include <res_dummy.h>
4 #include "trans_nego.h"
5
6 WVTEST_MAIN("transaction negotiation")
7 {
8         frsh_contract_t contract[3];
9         const frsh_resource_id_t id[3] = { 0, 1, 255 };
10         frsh_contract_label_t label[3];
11         frsh_rel_time_t budget, period;
12         int i;
13         frsh_transaction_t t;
14         frsh_vres_id_t vres1, vres2;
15         
16         WVFRSH(frsh_init());
17         WVFRSH(fra_dummy_init_and_activate_id(1));
18
19         WVFRSH(frsh_transaction_init(&t, "test"));
20
21         for (i = TEST_CONTRACT_1; i <= TEST_CONTRACT_3; i++) {
22                 WVFRSH(frsh_contract_init(&contract[i]));
23                 sprintf(label[i], "contract%d", i);
24                 WVFRSH(frsh_contract_set_resource_and_label(
25                                &contract[i],
26                                DUMMY_RESOURCE_TYPE, id[i],
27                                label[i]));
28
29                 budget = fosa_msec_to_rel_time(10);
30                 period = fosa_msec_to_rel_time(100);
31                 WVFRSH(frsh_contract_set_basic_params(&contract[i],
32                                                       &budget,
33                                                       &period,
34                                                       FRSH_WT_BOUNDED,
35                                                       FRSH_CT_REGULAR));
36
37                 WVFRSH(frsh_transaction_add_contract(&t, &contract[i], i));
38         }
39 #if 0   
40         WVFRSH(frsh_transaction_negotiate(&t));
41
42         WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_1, &vres1));
43         WVFRSH(frsh_transaction_alloc_vres(&t, TEST_CONTRACT_2, &vres2));
44         /* TEST_CONTRACT_3 is allocated in trans_nego2.c */
45
46         WVPASS(frsh_contract_cancel(vres2) == FRES_ERR_VRES_PART_OF_TRANSACTION);
47 #endif  
48         frsh_destroy();
49 }