]> rtime.felk.cvut.cz Git - frescor/frsh.git/blobdiff - frsh_api/tests/negotiation.c
frsh: Update negotiation test
[frescor/frsh.git] / frsh_api / tests / negotiation.c
index 5c562f58eb5db84ac77ffc11697d371ef7979179..8d45b9d441974d5f10f1ce4df23150c3490ea571 100644 (file)
@@ -24,7 +24,7 @@ int b[N] = { 10, 20, 30 };
 // }
 
 int ret;
-frsh_contract_t contract[N];
+frsh_contract_t contract[N], c;
 frsh_vres_id_t vres[N];
 frsh_rel_time_t budget, period, deadline;
 int i;
@@ -69,11 +69,12 @@ WVTEST_MAIN("basic negotiation")
                                                           false, &deadline));
                
                ret = WVFRSH(frsh_contract_negotiate(&contract[i], &vres[i]));
+               WVFRSH(frsh_vres_get_contract(vres[i], &c));
+               WVPASS(fres_contract_get_budget(&c, &budget));
+               WVPASS(fosa_rel_time_to_msec(budget) == b[i]);
        }
-}
 
-WVTEST_MAIN("renegotiation")
-{
+       /* Renegotiate the first two contracts */
        for (i=0; i<2; i++) {
                budget = fosa_msec_to_rel_time(2*b[i]);
                period = fosa_msec_to_rel_time(110);
@@ -84,8 +85,12 @@ WVTEST_MAIN("renegotiation")
                                                            FRSH_CT_REGULAR));
 
                ret = WVFRSH(frsh_contract_renegotiate_sync(&contract[i], vres[i]));
+               WVFRSH(frsh_vres_get_contract(vres[i], &c));
+               WVPASS(fres_contract_get_budget(&c, &budget));
+               WVPASS(fosa_rel_time_to_msec(budget) == 2*b[i]);
        }
 
+       /* Try to renegotiate the third contract - it will be rejected */
        budget = fosa_msec_to_rel_time(2*b[2]);
        period = fosa_msec_to_rel_time(110);
        ret = WVFRSH(frsh_contract_set_basic_params(&contract[2],
@@ -95,10 +100,10 @@ WVTEST_MAIN("renegotiation")
                                                    FRSH_CT_REGULAR));
 
        WVPASS(frsh_contract_renegotiate_sync(&contract[2], vres[2]) == FRSH_ERR_CONTRACT_REJECTED);
-}
+       WVFRSH(frsh_vres_get_contract(vres[2], &c));
+       WVPASS(fres_contract_get_budget(&c, &budget));
+       WVPASSEQ(fosa_rel_time_to_msec(budget), b[2]);
 
-WVTEST_MAIN("cancelation")
-{
        /* Cancel N contracts */
        for (i=0; i<N; i++) {
                ret = WVFRSH(frsh_contract_cancel(vres[i]));