7 frsh_contract_t contract;
8 frsh_rel_time_t budget, period;
9 frsh_rel_time_t current, duration, expiration;
10 unsigned long duration_msec, duration_step;
14 PXW(frsh_contract_init(&contract));
16 duration_msec = duration_step = 1000UL * 60UL * 10UL;
18 budget = fosa_msec_to_rel_time(10);
19 period = fosa_msec_to_rel_time(100);
20 PXW(frsh_contract_set_basic_params(&contract,
26 PXW(frsh_contract_set_resource_and_label(&contract, FRSH_RT_PROCESSOR, 0,"TEST_VRES"));
28 PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_HIGH, &budget));
30 PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_MEDIUM, &budget));
32 PXW(frsh_contract_set_min_budget_pow(&contract, FRSH_PLT_LOW, &budget));
34 terror = frsh_battery_get_expiration(&expiration);
36 PERROR_AND_EXIT(terror, "frsh_battery_get_expiration: system running on AC");
38 PERROR_AND_EXIT(terror, "frsh_battery_get_expiration");
40 fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t);
41 printf("System battery wil expire in %lu seconds\n",
42 fosa_rel_time_to_msec(fosa_abs_time_decr(expiration, current)) / 1000UL);
44 printf("Starting with minumum diration = %lu seconds\n"
45 " ans stepping by %lu seconds.\n",
46 duration_msec / 1000UL,
47 duration_step / 1000UL);
49 duration = fosa_msec_to_rel_time(duration_msec);
50 PXW(frsh_contract_set_min_expiration(&contract, duration));
52 PXW(frsh_contract_get_min_expiration(&contract, &duration));
54 PXW(frsh_contract_negotiate(&contract, &vres));
55 printf("Aqcpu vres negotiated, vres-ID: %d\n", (int) vres);
58 duration_msec += duration_step;
59 duration = fosa_msec_to_rel_time(duration_msec);
61 fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t);
62 printf(" Renegotiating the contract with minimum expiration %lu sec.\n"
63 " System expiration time: %lu seconds\n",
64 fosa_rel_time_to_msec(duration) / 1000UL,
65 fosa_rel_time_to_msec(fosa_abs_time_decr(expiration, current)) / 1000UL);
67 PXW(frsh_contract_set_min_expiration(&contract, duration));
69 PXW(frsh_battery_get_expiration(&expiration));
70 terror = frsh_contract_renegotiate_sync(&contract, vres);
71 if (terror == FRSH_ERR_CONTRACT_REJECTED) {
72 PERROR_FRESCOR(terror, "frsh_contract_renegotiate_sync");
75 if (terror) PERROR_AND_EXIT(terror, "frsh_contract_renegotiate_sync");
81 PXW(frsh_contract_cancel(vres));
83 printf("Test PASSED!\n");