From 7272cec4938c6ec4ce34fe7425cfc74698399d8c Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 20 Jun 2010 17:05:24 +0200 Subject: [PATCH 1/1] Finish testing of spare capacity --- frsh_api/tests/dummy_spare_capacity.c | 73 +++++++++++++++++---------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/frsh_api/tests/dummy_spare_capacity.c b/frsh_api/tests/dummy_spare_capacity.c index 8157f61..aef6385 100644 --- a/frsh_api/tests/dummy_spare_capacity.c +++ b/frsh_api/tests/dummy_spare_capacity.c @@ -7,19 +7,6 @@ #include #include -/* static struct option long_opts[] = { */ -/* { "loglevel", 1, 0, 'l' }, */ -/* { 0, 0, 0, 0} */ -/* }; */ - -/* static void */ -/* usage(void) */ -/* { */ -/* printf("usage: cpu_spare_capacity [ options ]\n"); */ -/* printf(" -l, --loglevel |=,...\n"); */ -/* } */ - - #define MSEC(x) { x/1000, (x%1000) * 1000000 } frsh_utilization_set_t utilization_set = { .size = 2, @@ -29,25 +16,37 @@ frsh_utilization_set_t utilization_set = { }, }; +frsh_vres_id_t vres[5]; + +void +get_min_max_budget(int count, int *min, int*max) +{ + frsh_contract_t c; + fosa_rel_time_t budget; + int i, b; + + *max = 0; + *min = 10000; + + for (i=0; i *max) + *max = b; + } +} + WVTEST_MAIN("spare capacity") { - frsh_vres_id_t vres; frsh_contract_t contract; frsh_rel_time_t zero = fosa_msec_to_rel_time(0); int ret; -/* char opt; */ + int min, max; -/* while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) { */ -/* switch (opt) { */ -/* case 'l': */ -/* ul_log_domain_arg2levels(optarg); */ -/* break; */ -/* case 'h': */ -/* /\*default:*\/ */ -/* usage(); */ -/* exit(opt == 'h' ? 0 : 1); */ -/* } */ -/* } */ +/* ul_log_domain_arg2levels(optarg); */ setenv("WVTEST_DIE_FAST", "", 1); WVFRSH(frsh_init()); @@ -74,9 +73,27 @@ WVTEST_MAIN("spare capacity") 0, 0)); - ret = WVFRSH(frsh_contract_negotiate(&contract, &vres)); + WVFRSH(frsh_contract_negotiate(&contract, &vres[0])); + get_min_max_budget(1, &min, &max); + WVPASS(min == 50 && max == 50); + + WVFRSH(frsh_contract_negotiate(&contract, &vres[1])); + get_min_max_budget(2, &min, &max); + WVPASS(min == 20 && max == 50); + + WVFRSH(frsh_contract_negotiate(&contract, &vres[2])); + get_min_max_budget(3, &min, &max); + WVPASS(min == 20 && max == 50); + + WVFRSH(frsh_contract_negotiate(&contract, &vres[3])); + get_min_max_budget(4, &min, &max); + WVPASS(min == 20 && max == 20); + - ret = WVFRSH(frsh_contract_cancel(vres)); + ret = WVFRSH(frsh_contract_cancel(vres[0])); + ret = WVFRSH(frsh_contract_cancel(vres[1])); + ret = WVFRSH(frsh_contract_cancel(vres[2])); + ret = WVFRSH(frsh_contract_cancel(vres[3])); frsh_destroy(); } -- 2.39.2