From: Martin Quinson Date: Mon, 15 Feb 2016 21:53:48 +0000 (+0100) Subject: cleanups in teshsuite/simdag/platforms, don't ask why X-Git-Tag: v3_13~822 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d42d0c6f54ae825a249799cb1e4e2920de5205c8 cleanups in teshsuite/simdag/platforms, don't ask why --- diff --git a/teshsuite/simdag/platforms/Evaluate_get_route_time.c b/teshsuite/simdag/platforms/Evaluate_get_route_time.c index 89a9ba89a0..c9ef64b7fe 100644 --- a/teshsuite/simdag/platforms/Evaluate_get_route_time.c +++ b/teshsuite/simdag/platforms/Evaluate_get_route_time.c @@ -17,31 +17,25 @@ int main(int argc, char **argv) { - sg_host_t w1, w2; - const sg_host_t *workstations; int i, j; - int list_size; xbt_os_timer_t timer = xbt_os_timer_new(); - /* SD initialization */ SD_init(&argc, argv); - - /* creation of the environment */ SD_create_environment(argv[1]); - workstations = sg_host_list(); - list_size = sg_host_count(); + sg_host_t *workstations = sg_host_list(); + int list_size = sg_host_count(); /* Random number initialization */ srand( (int) (xbt_os_time()*1000) ); - do{ + do { i = rand()%list_size; j = rand()%list_size; - }while(i==j); + } while(i==j); - w1 = workstations[i]; - w2 = workstations[j]; + sg_host_t w1 = workstations[i]; + sg_host_t w2 = workstations[j]; printf("%d\tand\t%d\t\t",i,j); xbt_os_cputimer_start(timer); @@ -50,6 +44,7 @@ int main(int argc, char **argv) printf("%f\n", xbt_os_timer_elapsed(timer) ); + xbt_free(workstations); SD_exit(); return 0; diff --git a/teshsuite/simdag/platforms/Evaluate_parse_time.c b/teshsuite/simdag/platforms/Evaluate_parse_time.c index 4c66b2fe1c..e3c46a11a0 100644 --- a/teshsuite/simdag/platforms/Evaluate_parse_time.c +++ b/teshsuite/simdag/platforms/Evaluate_parse_time.c @@ -15,8 +15,6 @@ int main(int argc, char **argv) { xbt_os_timer_t timer = xbt_os_timer_new(); - - /* initialization of SD */ SD_init(&argc, argv); /* creation of the environment, timed */ @@ -26,8 +24,7 @@ int main(int argc, char **argv) /* Display the result and exit after cleanup */ printf( "%f\n", xbt_os_timer_elapsed(timer) ); - printf("Workstation number: %zu, link number: %d\n", - sg_host_count(), sg_link_count()); + printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count()); if(argv[2]){ printf("Wait for %ss\n",argv[2]); sleep(atoi(argv[2])); diff --git a/teshsuite/simdag/platforms/basic_link_test.c b/teshsuite/simdag/platforms/basic_link_test.c index 71397f5ba5..be8439513f 100644 --- a/teshsuite/simdag/platforms/basic_link_test.c +++ b/teshsuite/simdag/platforms/basic_link_test.c @@ -13,36 +13,27 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test"); static int cmp_link(const void*a, const void*b) { - const char *nameA = sg_link_name(*(SD_link_t*)a); - const char *nameB = sg_link_name(*(SD_link_t*)b); - return strcmp( nameA, nameB ); + return strcmp(sg_link_name(*(SD_link_t*)a) , sg_link_name(*(SD_link_t*)b)); } int main(int argc, char **argv) { - int i; const char *user_data = "some user_data"; - const SD_link_t *links; /* initialization of SD */ SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); - links = sg_link_list(); + const SD_link_t *links = sg_link_list(); int count = sg_link_count(); XBT_INFO("Link count: %d", count); qsort((void *)links, count, sizeof(SD_link_t), cmp_link); - for(i=0; i < count; i++){ - XBT_INFO("%s: latency = %.5f, bandwidth = %f", - sg_link_name(links[i]), - sg_link_latency(links[i]), - sg_link_bandwidth(links[i])); + for (int i=0; i < count; i++){ + XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]), sg_link_latency(links[i]), sg_link_bandwidth(links[i])); sg_link_data_set(links[i], (void*) user_data); - if(strcmp(user_data, (const char*)sg_link_data(links[i]))){ - XBT_ERROR("User data was corrupted."); - } + xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted."); } SD_exit(); diff --git a/teshsuite/simdag/platforms/basic_parsing_test.c b/teshsuite/simdag/platforms/basic_parsing_test.c index 1d53c0d543..d361c39593 100644 --- a/teshsuite/simdag/platforms/basic_parsing_test.c +++ b/teshsuite/simdag/platforms/basic_parsing_test.c @@ -10,76 +10,52 @@ int main(int argc, char **argv) { - /* SD initialization */ - - sg_host_t w1, w2; - sg_host_t *workstations; - SD_link_t *route; - const char *name1; - const char *name2; - int route_size, i, j, k; - int list_size; - SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); - printf("Workstation number: %zu, link number: %d\n", - sg_host_count(), sg_link_count()); + printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count()); - workstations = sg_host_list(); + sg_host_t *workstations = sg_host_list(); if (argc >= 3) { if (!strcmp(argv[2], "ONE_LINK")) { - w1 = workstations[0]; - w2 = workstations[1]; - name1 = sg_host_get_name(w1); - name2 = sg_host_get_name(w2); + sg_host_t w1 = workstations[0]; + sg_host_t w2 = workstations[1]; + const char *name1 = sg_host_get_name(w1); + const char *name2 = sg_host_get_name(w2); printf("Route between %s and %s\n", name1, name2); - route = SD_route_get_list(w1, w2); - route_size = SD_route_get_size(w1, w2); + SD_link_t *route = SD_route_get_list(w1, w2); + int route_size = SD_route_get_size(w1, w2); printf("Route size %d\n", route_size); - for (i = 0; i < route_size; i++) { - printf(" Link %s: latency = %f, bandwidth = %f\n", - sg_link_name(route[i]), - sg_link_latency(route[i]), - sg_link_bandwidth(route[i])); - } - printf("Route latency = %f, route bandwidth = %f\n", - SD_route_get_latency(w1, w2), - SD_route_get_bandwidth(w1, w2)); + for (int i = 0; i < route_size; i++) + printf(" Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]), sg_link_latency(route[i]), sg_link_bandwidth(route[i])); + printf("Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2)); xbt_free(route); } if (!strcmp(argv[2], "FULL_LINK")) { - list_size = sg_host_count(); - for (i = 0; i < list_size; i++) { - w1 = workstations[i]; - name1 = sg_host_get_name(w1); - for (j = 0; j < list_size; j++) { - w2 = workstations[j]; - name2 = sg_host_get_name(w2); - printf("Route between %s and %s\n", name1, name2); - route = SD_route_get_list(w1, w2); - route_size = SD_route_get_size(w1, w2); - printf(" Route size %d\n", route_size); - for (k = 0; k < route_size; k++) { - printf(" Link %s: latency = %f, bandwidth = %f\n", - sg_link_name(route[k]), - sg_link_latency(route[k]), - sg_link_bandwidth(route[k])); + int list_size = sg_host_count(); + for (int i = 0; i < list_size; i++) { + sg_host_t w1 = workstations[i]; + const char *name1 = sg_host_get_name(w1); + for (int j = 0; j < list_size; j++) { + sg_host_t w2 = workstations[j]; + const char *name2 = sg_host_get_name(w2); + printf("Route between %s and %s\n", name1, name2); + SD_link_t *route = SD_route_get_list(w1, w2); + int route_size = SD_route_get_size(w1, w2); + printf(" Route size %d\n", route_size); + for (int k = 0; k < route_size; k++) { + printf(" Link %s: latency = %f, bandwidth = %f\n", + sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k])); + } + printf(" Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2)); + xbt_free(route); } - printf(" Route latency = %f, route bandwidth = %f\n", - SD_route_get_latency(w1, w2), - SD_route_get_bandwidth(w1, w2)); - xbt_free(route); } - } - } - if (!strcmp(argv[2], "PROP")) { - printf("SG_TEST_mem: %s\n", - sg_host_get_property_value(sg_host_by_name("host1"), - "SG_TEST_mem")); } + if (!strcmp(argv[2], "PROP")) + printf("SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem")); } xbt_free(workstations); diff --git a/teshsuite/simdag/platforms/basic_tracing.c b/teshsuite/simdag/platforms/basic_tracing.c index 5b8db615ff..606b219cca 100644 --- a/teshsuite/simdag/platforms/basic_tracing.c +++ b/teshsuite/simdag/platforms/basic_tracing.c @@ -21,18 +21,14 @@ int host(int argc, char *argv[]) int main(int argc, char **argv) { - int res; - xbt_dynar_t all_hosts; - msg_host_t first_host; MSG_init(&argc, argv); MSG_create_environment(argv[1]); MSG_function_register("host", host); - all_hosts = MSG_hosts_as_dynar(); - first_host = xbt_dynar_pop_as(all_hosts,msg_host_t); - MSG_process_create( "host", host, NULL, first_host); + xbt_dynar_t all_hosts = MSG_hosts_as_dynar(); + MSG_process_create( "host", host, NULL, xbt_dynar_pop_as(all_hosts,msg_host_t)); xbt_dynar_free(&all_hosts); - res = MSG_main(); + int res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; diff --git a/teshsuite/simdag/platforms/is_router_test.c b/teshsuite/simdag/platforms/is_router_test.c index 18751cbe09..cb89fab666 100644 --- a/teshsuite/simdag/platforms/is_router_test.c +++ b/teshsuite/simdag/platforms/is_router_test.c @@ -23,18 +23,13 @@ int main(int argc, char **argv) size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib); - printf("Workstation number: %zu, link number: %d, elmts number: %d\n", - sg_host_count(), sg_link_count(), size); - - xbt_dict_foreach(host_list, cursor, key, data) { - printf(" - Seen: \"%s\" is type : %d\n", key, - (int) routing_get_network_element_type(key)); - } - - xbt_lib_foreach(as_router_lib, cursor, key, data) { - printf(" - Seen: \"%s\" is type : %d\n", key, - (int) routing_get_network_element_type(key)); - } + printf("Workstation number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size); + + xbt_dict_foreach(host_list, cursor, key, data) + printf(" - Seen: \"%s\" is type : %d\n", key, (int) routing_get_network_element_type(key)); + + xbt_lib_foreach(as_router_lib, cursor, key, data) + printf(" - Seen: \"%s\" is type : %d\n", key, (int) routing_get_network_element_type(key)); SD_exit(); return 0;