Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in teshsuite/simdag/platforms, don't ask why
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 15 Feb 2016 21:53:48 +0000 (22:53 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 15 Feb 2016 21:53:48 +0000 (22:53 +0100)
teshsuite/simdag/platforms/Evaluate_get_route_time.c
teshsuite/simdag/platforms/Evaluate_parse_time.c
teshsuite/simdag/platforms/basic_link_test.c
teshsuite/simdag/platforms/basic_parsing_test.c
teshsuite/simdag/platforms/basic_tracing.c
teshsuite/simdag/platforms/is_router_test.c

index 89a9ba8..c9ef64b 100644 (file)
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
-  sg_host_t w1, w2;
-  const sg_host_t *workstations;
   int i, j;
   int i, j;
-  int list_size;
   xbt_os_timer_t timer = xbt_os_timer_new();
 
   xbt_os_timer_t timer = xbt_os_timer_new();
 
-  /* SD initialization */
   SD_init(&argc, argv);
   SD_init(&argc, argv);
-
-  /* creation of the environment */
   SD_create_environment(argv[1]);
 
   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) );
 
 
   /* Random number initialization */
   srand( (int) (xbt_os_time()*1000) );
 
-  do{
+  do {
     i = rand()%list_size;
     j = rand()%list_size;
     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);
   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) );
 
 
   printf("%f\n", xbt_os_timer_elapsed(timer) );
 
+  xbt_free(workstations);
   SD_exit();
 
   return 0;
   SD_exit();
 
   return 0;
index 4c66b2f..e3c46a1 100644 (file)
@@ -15,8 +15,6 @@
 int main(int argc, char **argv)
 {
   xbt_os_timer_t timer = xbt_os_timer_new();
 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 */
   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) );
 
   /* 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]));
   if(argv[2]){
     printf("Wait for %ss\n",argv[2]);
     sleep(atoi(argv[2]));
index 71397f5..be84395 100644 (file)
@@ -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) {
                                 "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 main(int argc, char **argv)
 {
-  int i;
   const char *user_data = "some user_data";
   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]);
 
   /* 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);
    
   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);
     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();
   }
 
   SD_exit();
index 1d53c0d..d361c39 100644 (file)
 
 int main(int argc, char **argv)
 {
 
 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]);
   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")) {
   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);
 
       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);
       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")) {
       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);
 
   }
   xbt_free(workstations);
 
index 5b8db61..606b219 100644 (file)
@@ -21,18 +21,14 @@ int host(int argc, char *argv[])
 
 int main(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);
   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);
 
   xbt_dynar_free(&all_hosts);
 
-  res = MSG_main();
+  int res = MSG_main();
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   return res != MSG_OK;
index 18751cb..cb89fab 100644 (file)
@@ -23,18 +23,13 @@ int main(int argc, char **argv)
 
   size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib);
 
 
   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;
 
   SD_exit();
   return 0;