10 #define MSEC(x) { x/1000, (x%1000) * 1000000 }
11 frsh_utilization_set_t utilization_set = {
14 { .budget = MSEC(20), .period = MSEC(100), .deadline = MSEC(100) },
15 { .budget = MSEC(50), .period = MSEC(100), .deadline = MSEC(100) },
19 frsh_vres_id_t vres[5];
22 get_min_max_budget(int count, int *min, int*max)
25 fosa_rel_time_t budget;
31 for (i=0; i<count; i++) {
32 WVFRSH(frsh_vres_get_contract(vres[i], &c));
33 WVPASS(fres_contract_get_budget(&c, &budget));
34 b = fosa_rel_time_to_msec(budget);
42 WVTEST_MAIN("spare capacity")
44 frsh_contract_t contract;
45 frsh_rel_time_t zero = fosa_msec_to_rel_time(0);
49 /* ul_log_domain_arg2levels(optarg); */
51 setenv("WVTEST_DIE_FAST", "", 1);
54 /* Contract negotiation for CPU */
55 ret = WVFRSH(frsh_contract_init(&contract));
57 ret = WVFRSH(frsh_contract_set_basic_params(&contract,
58 &utilization_set.utilizations[0].budget,
59 &utilization_set.utilizations[0].period,
63 ret = WVFRSH(frsh_contract_set_resource_and_label(&contract ,
64 DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
67 ret = WVFRSH(frsh_contract_set_reclamation_params(&contract,
69 &utilization_set.utilizations[utilization_set.size-1].budget,
70 &utilization_set.utilizations[utilization_set.size-1].period,
76 WVFRSH(frsh_contract_negotiate(&contract, &vres[0]));
77 get_min_max_budget(1, &min, &max);
78 WVPASS(min == 50 && max == 50);
80 WVFRSH(frsh_contract_negotiate(&contract, &vres[1]));
81 get_min_max_budget(2, &min, &max);
82 WVPASS(min == 20 && max == 50);
84 WVFRSH(frsh_contract_negotiate(&contract, &vres[2]));
85 get_min_max_budget(3, &min, &max);
86 WVPASS(min == 20 && max == 50);
88 WVFRSH(frsh_contract_negotiate(&contract, &vres[3]));
89 get_min_max_budget(4, &min, &max);
90 WVPASS(min == 20 && max == 20);
93 ret = WVFRSH(frsh_contract_cancel(vres[0]));
94 ret = WVFRSH(frsh_contract_cancel(vres[1]));
95 ret = WVFRSH(frsh_contract_cancel(vres[2]));
96 ret = WVFRSH(frsh_contract_cancel(vres[3]));