From: Michal Sojka Date: Sun, 20 Jun 2010 13:11:36 +0000 (+0200) Subject: test: Convert spare capacity test to wvtest X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/frsh.git/commitdiff_plain/d1d4b43b5a3a5ac5b1601478a5bd195524be215c?ds=sidebyside test: Convert spare capacity test to wvtest TODO: Add more contracts and check s.c. reallocation. --- diff --git a/frsh_api/tests/Makefile.omk b/frsh_api/tests/Makefile.omk index c0e20ac..de636a8 100644 --- a/frsh_api/tests/Makefile.omk +++ b/frsh_api/tests/Makefile.omk @@ -19,8 +19,10 @@ endif test_PROGRAMS += dummy_renegotiation dummy_renegotiation_SOURCES = dummy_renegotiation.c +wvtest_SCRIPTS += dummy_spare_capacity.sh test_PROGRAMS += dummy_spare_capacity dummy_spare_capacity_SOURCES = dummy_spare_capacity.c +dummy_spare_capacity_LIBS = wvtest test_PROGRAMS += negobench negobench_SOURCES = negobench.c diff --git a/frsh_api/tests/dummy_spare_capacity.c b/frsh_api/tests/dummy_spare_capacity.c index 08872d1..8157f61 100644 --- a/frsh_api/tests/dummy_spare_capacity.c +++ b/frsh_api/tests/dummy_spare_capacity.c @@ -5,25 +5,19 @@ #include #include #include +#include -sem_t finish; +/* static struct option long_opts[] = { */ +/* { "loglevel", 1, 0, 'l' }, */ +/* { 0, 0, 0, 0} */ +/* }; */ -void int_handler(int signal) -{ - sem_post(&finish); -} - -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"); -} +/* static void */ +/* usage(void) */ +/* { */ +/* printf("usage: cpu_spare_capacity [ options ]\n"); */ +/* printf(" -l, --loglevel |=,...\n"); */ +/* } */ #define MSEC(x) { x/1000, (x%1000) * 1000000 } @@ -35,68 +29,54 @@ frsh_utilization_set_t utilization_set = { }, }; -int main(int argc, char *argv[]) +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; - - sem_init(&finish, 0, 0); - - 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); - } - } - - ret = frsh_init(); - if (ret) PERROR_AND_EXIT(ret, "frsh_init"); +/* char opt; */ + +/* 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); */ +/* } */ +/* } */ + + setenv("WVTEST_DIE_FAST", "", 1); + WVFRSH(frsh_init()); - signal(SIGINT, int_handler); - signal(SIGTERM, int_handler); - /* Contract negotiation for CPU */ - ret = frsh_contract_init(&contract); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init"); + ret = WVFRSH(frsh_contract_init(&contract)); - ret = frsh_contract_set_basic_params(&contract, + ret = WVFRSH(frsh_contract_set_basic_params(&contract, &utilization_set.utilizations[0].budget, &utilization_set.utilizations[0].period, FRSH_WT_BOUNDED, - FRSH_CT_REGULAR); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params"); + FRSH_CT_REGULAR)); - ret = frsh_contract_set_resource_and_label(&contract , + ret = WVFRSH(frsh_contract_set_resource_and_label(&contract , DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID, - "spare cap test"); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label"); + "spare cap test")); - ret = frsh_contract_set_reclamation_params(&contract, + ret = WVFRSH(frsh_contract_set_reclamation_params(&contract, &zero, &utilization_set.utilizations[utilization_set.size-1].budget, &utilization_set.utilizations[utilization_set.size-1].period, FRSH_GR_DISCRETE, &utilization_set, 0, - 0); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_reclamation_params"); - - ret = frsh_contract_negotiate(&contract, &vres); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate"); - - sem_wait(&finish); + 0)); - ret = frsh_contract_cancel(vres); - if (ret) PERROR_AND_EXIT(ret, "frsh_contract_cancel"); + ret = WVFRSH(frsh_contract_negotiate(&contract, &vres)); - return 0; + ret = WVFRSH(frsh_contract_cancel(vres)); + frsh_destroy(); } diff --git a/frsh_api/tests/dummy_spare_capacity.sh b/frsh_api/tests/dummy_spare_capacity.sh new file mode 100755 index 0000000..0da7df4 --- /dev/null +++ b/frsh_api/tests/dummy_spare_capacity.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +. $(dirname $0)/wvtest.sh + +setup_dummy +WVPASS dummy_spare_capacity diff --git a/frsh_api/tests/negotiation.sh b/frsh_api/tests/negotiation.sh index 6046f4e..2fbd0c7 100755 --- a/frsh_api/tests/negotiation.sh +++ b/frsh_api/tests/negotiation.sh @@ -2,15 +2,5 @@ . $(dirname $0)/wvtest.sh -WVSTART Setup -WVPASS fcb -dfcb.pid -WVPASS frm_dummy -dfrm.pid -trap ' -WVSTART Kill -WVPASS kill `cat fcb.pid` -WVPASS rm fcb.pid -WVPASS kill `cat frm.pid` -WVPASS rm frm.pid -' 0 +setup_dummy WVPASS negotiation - diff --git a/frsh_api/tests/wvtest.sh b/frsh_api/tests/wvtest.sh deleted file mode 120000 index 1982069..0000000 --- a/frsh_api/tests/wvtest.sh +++ /dev/null @@ -1 +0,0 @@ -../../../wvtest.sh \ No newline at end of file diff --git a/frsh_api/tests/wvtest.sh b/frsh_api/tests/wvtest.sh new file mode 100644 index 0000000..e04d48c --- /dev/null +++ b/frsh_api/tests/wvtest.sh @@ -0,0 +1,14 @@ +. $(dirname $0)/../../../wvtest.sh + +setup_dummy() { + WVSTART Setup + WVPASS fcb -dfcb.pid + WVPASS frm_dummy -dfrm.pid + trap ' +WVSTART Kill +WVPASS kill `cat fcb.pid` +WVPASS rm fcb.pid +WVPASS kill `cat frm.pid` +WVPASS rm frm.pid +' 0 +}