10 int b[N] = { 10, 20, 30 };
12 // TODO: Allow specifying loglevel in evironment
14 // static struct option long_opts[] = {
15 // { "loglevel", 1, 0, 'l' },
22 // printf("usage: negotiation [ options ]\n");
23 // printf(" -l, --loglevel <number>|<domain>=<number>,...\n");
27 frsh_contract_t contract[N], c;
28 frsh_vres_id_t vres[N];
29 frsh_rel_time_t budget, period, deadline;
32 WVTEST_MAIN("basic negotiation")
36 // while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
43 // exit(opt == 'h' ? 0 : 1);
47 setenv("WVTEST_DIE_FAST", "", 1);
48 ret = WVFRSH(frsh_init());
50 /* Negotiate N contracts */
52 ret = WVFRSH(frsh_contract_init(&contract[i]));
54 ret = WVFRSH(frsh_contract_set_resource_and_label(
56 DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
59 budget = fosa_msec_to_rel_time(b[i]);
60 period = fosa_msec_to_rel_time(100);
61 deadline = fosa_msec_to_rel_time(50);
62 ret = WVFRSH(frsh_contract_set_basic_params(&contract[i],
68 ret = WVFRSH(frsh_contract_set_timing_reqs(&contract[i],
71 ret = WVFRSH(frsh_contract_negotiate(&contract[i], &vres[i]));
72 WVFRSH(frsh_vres_get_contract(vres[i], &c));
73 WVPASS(fres_contract_get_budget(&c, &budget));
74 WVPASS(fosa_rel_time_to_msec(budget) == b[i]);
78 WVTEST_MAIN("renegotiation")
81 budget = fosa_msec_to_rel_time(2*b[i]);
82 period = fosa_msec_to_rel_time(110);
83 ret = WVFRSH(frsh_contract_set_basic_params(&contract[i],
89 ret = WVFRSH(frsh_contract_renegotiate_sync(&contract[i], vres[i]));
90 WVFRSH(frsh_vres_get_contract(vres[i], &c));
91 WVPASS(fres_contract_get_budget(&c, &budget));
92 WVPASS(fosa_rel_time_to_msec(budget) == 2*b[i]);
95 budget = fosa_msec_to_rel_time(2*b[2]);
96 period = fosa_msec_to_rel_time(110);
97 ret = WVFRSH(frsh_contract_set_basic_params(&contract[2],
103 WVPASS(frsh_contract_renegotiate_sync(&contract[2], vres[2]) == FRSH_ERR_CONTRACT_REJECTED);
104 WVFRSH(frsh_vres_get_contract(vres[i], &c));
105 WVPASS(fres_contract_get_budget(&c, &budget));
106 WVPASS(fosa_rel_time_to_msec(budget) == b[i]);
109 WVTEST_MAIN("cancelation")
111 /* Cancel N contracts */
112 for (i=0; i<N; i++) {
113 ret = WVFRSH(frsh_contract_cancel(vres[i]));