#include <ul_logreg.h>
#include <res_dummy.h>
#include <semaphore.h>
+#include <wvtest.h>
-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 <number>|<domain>=<number>,...\n");
-}
+/* static void */
+/* usage(void) */
+/* { */
+/* printf("usage: cpu_spare_capacity [ options ]\n"); */
+/* printf(" -l, --loglevel <number>|<domain>=<number>,...\n"); */
+/* } */
#define MSEC(x) { x/1000, (x%1000) * 1000000 }
},
};
-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();
}