From b1ce9a37a837f97897a73160f6bb1187757ccc3a Mon Sep 17 00:00:00 2001 From: Tuka Martin Date: Thu, 28 Apr 2011 00:43:58 +0200 Subject: [PATCH] Added type conversion because of difference in behavior Test had unpredictable behavior with hard estimated dependency (It wasn't able to find some contracts, which was correctly added to scenario.) Called frsh_destroy function for corrected end of the test --- src/fwp/fwp/mngr/test/fwp_adm_test.c | 45 +++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/fwp/fwp/mngr/test/fwp_adm_test.c b/src/fwp/fwp/mngr/test/fwp_adm_test.c index cc0a5cc5..570448ce 100644 --- a/src/fwp/fwp/mngr/test/fwp_adm_test.c +++ b/src/fwp/fwp/mngr/test/fwp_adm_test.c @@ -59,6 +59,7 @@ struct stream_params { int async; int number; int count; + int schedulable_expected; long long mac_address1; long long mac_address2; long long mac_address3; @@ -102,8 +103,6 @@ int fwp_admctrl_utilization_test(struct stream_params *p) WVPASS(frsh_contract_init(&contract2) == 0); WVPASS(frsh_contract_init(&contract3) == 0); - fres_block_register_fwp(); - /* set resource and label of contracts */ WVPASS(frsh_contract_set_resource_and_label( &contract1, @@ -173,12 +172,20 @@ int fwp_admctrl_utilization_test(struct stream_params *p) WVPASS(fres_contract_add_block(contract3, FRES_BLOCK_FWP, fwp_block3) == 0); /* set id of contracts */ - int *id1; WVPASS((id1 = (int*)malloc(sizeof(int))) != NULL); - int *id2; WVPASS((id2 = (int*)malloc(sizeof(int))) != NULL); - int *id3; WVPASS((id3 = (int*)malloc(sizeof(int))) != NULL); - *id1 = 1; - *id2 = 2; - *id3 = 3; + int num_of_contract1 = 1; + int *p_num_of_contract1 = &num_of_contract1; + fres_contract_id_t *id1; WVPASS((id1 = (fres_contract_id_t*)malloc(sizeof(fres_contract_id_t))) != NULL); + *id1 = *p_num_of_contract1; + + int num_of_contract2 = 2; + int *p_num_of_contract2 = &num_of_contract2; + fres_contract_id_t *id2; WVPASS((id2 = (fres_contract_id_t*)malloc(sizeof(fres_contract_id_t))) != NULL); + *id2 = *p_num_of_contract2; + + int num_of_contract3 = 3; + int *p_num_of_contract3 = &num_of_contract3; + fres_contract_id_t *id3; WVPASS((id3 = (fres_contract_id_t*)malloc(sizeof(fres_contract_id_t))) != NULL); + *id3 = *p_num_of_contract3; c1->contract = c1->new = contract1; c1->id = *id1; @@ -207,24 +214,19 @@ int fwp_admctrl_utilization_test(struct stream_params *p) WVPASS(fwp_admctrl_utilization(scenario, &priv, &schedulable) == 0); /* check results */ - //TODO: Why isn't able to find contract with id1? - // - //c1 = fres_sa_scenario_find_contract(scenario, (fres_contract_id_t *)id1); - //if(!c1) PERROR_AND_EXIT(ret, "fres_sa_scenario_find_contract"); - // - //WVPASS((c1 = fres_sa_scenario_find_contract(scenario, (fres_contract_id_t *)id1)) != NULL); - //WVPASS((fwp_sched = fres_contract_get_block(c1->contract, FRES_BLOCK_FWP_SCHED)) != NULL); - //WVPASSEQ(fwp_sched->ac_id, FWP_AC_VO); - - WVPASS((c2 = fres_sa_scenario_find_contract(scenario, (fres_contract_id_t *)id2)) != NULL); + WVPASS((c1 = fres_sa_scenario_find_contract(scenario, id1)) != NULL); + WVPASS((fwp_sched = fres_contract_get_block(c1->contract, FRES_BLOCK_FWP_SCHED)) != NULL); + WVPASSEQ(fwp_sched->ac_id, FWP_AC_VO); + + WVPASS((c2 = fres_sa_scenario_find_contract(scenario, id2)) != NULL); WVPASS((fwp_sched = fres_contract_get_block(c2->contract, FRES_BLOCK_FWP_SCHED)) != NULL); WVPASSEQ(fwp_sched->ac_id, FWP_AC_VO); - WVPASS((c3 = fres_sa_scenario_find_contract(scenario, (fres_contract_id_t *)id3)) != NULL); + WVPASS((c3 = fres_sa_scenario_find_contract(scenario, id3)) != NULL); WVPASS((fwp_sched = fres_contract_get_block(c3->contract, FRES_BLOCK_FWP_SCHED)) != NULL); WVPASSEQ(fwp_sched->ac_id, FWP_AC_VO); - WVPASSEQ(schedulable, 1); + WVPASSEQ(schedulable, p->schedulable_expected); return 0; } @@ -248,6 +250,7 @@ WVTEST_MAIN("fwp_admctrl_utilization_test") .mac_address1 = 1, .mac_address2 = 2, .mac_address3 = 3, + .schedulable_expected = 1, }; struct stream_params *p[100]; @@ -266,5 +269,7 @@ WVTEST_MAIN("fwp_admctrl_utilization_test") WVPASS(fwp_admctrl_utilization_test(p[num]) == 0); } + + frsh_destroy(); } -- 2.39.2