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);
48 /* ul_log_domain_arg2levels(optarg); */
50 setenv("WVTEST_DIE_FAST", "", 1);
53 /* Contract negotiation for CPU */
54 WVFRSH(frsh_contract_init(&contract));
56 WVFRSH(frsh_contract_set_basic_params(&contract,
57 &utilization_set.utilizations[0].budget,
58 &utilization_set.utilizations[0].period,
62 WVFRSH(frsh_contract_set_resource_and_label(&contract ,
63 DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
66 WVFRSH(frsh_contract_set_reclamation_params(&contract,
68 &utilization_set.utilizations[utilization_set.size-1].budget,
69 &utilization_set.utilizations[utilization_set.size-1].period,
75 WVFRSH(frsh_contract_negotiate(&contract, &vres[0]));
76 get_min_max_budget(1, &min, &max);
77 WVPASS(min == 50 && max == 50);
79 WVFRSH(frsh_contract_negotiate(&contract, &vres[1]));
80 get_min_max_budget(2, &min, &max);
81 WVPASS(min == 20 && max == 50);
83 WVFRSH(frsh_contract_negotiate(&contract, &vres[2]));
84 get_min_max_budget(3, &min, &max);
85 WVPASS(min == 20 && max == 50);
87 WVFRSH(frsh_contract_negotiate(&contract, &vres[3]));
88 get_min_max_budget(4, &min, &max);
89 WVPASS(min == 20 && max == 20);
92 WVFRSH(frsh_contract_cancel(vres[0]));
93 WVFRSH(frsh_contract_cancel(vres[1]));
94 WVFRSH(frsh_contract_cancel(vres[2]));
95 WVFRSH(frsh_contract_cancel(vres[3]));