Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change argument testing method (100% coverage)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 22 Jan 2016 12:11:00 +0000 (13:11 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 22 Jan 2016 12:11:40 +0000 (13:11 +0100)
examples/simdag/dax/dax_test.c
examples/simdag/properties/sd_prop.c
examples/simdag/properties/test_prop.tesh
examples/simdag/scheduling/minmin_test.c
examples/simdag/sd_comm_throttling.c
examples/simdag/sd_test.c
examples/simdag/sd_test2.c
examples/simdag/sd_typed_tasks_test.c
examples/simdag/simdag_trace.c

index 92b035d..934d812 100644 (file)
@@ -35,25 +35,17 @@ int main(int argc, char **argv)
   SD_init(&argc, argv);
 
   /* Check our arguments */
   SD_init(&argc, argv);
 
   /* Check our arguments */
-  if (argc < 3) {
-    XBT_INFO("Usage: %s platform_file dax_file [trace_file]", argv[0]);
-    XBT_INFO
-        ("example: %s ../sd_platform.xml Montage_50.xml Montage_50.mytrace",
-         argv[0]);
-    exit(1);
-  }
-  char *tracefilename;
-  if (argc == 3) {
-    char *last = strrchr(argv[2], '.');
-
-    tracefilename =
-        bprintf("%.*s.trace",
-                (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),
-                argv[2]);
-  } else {
+  xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n"
+            "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", 
+            argv[0], argv[0]);
+
+  char *last = strrchr(argv[2], '.');
+  char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? 
+                                                  strlen(argv[2]) : 
+                                                  last - argv[2]), argv[2]);  
+  if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
     tracefilename = xbt_strdup(argv[3]);
-  }
-
   /* creation of the environment */
   SD_create_environment(argv[1]);
 
   /* creation of the environment */
   SD_create_environment(argv[1]);
 
index f11a837..a015ef9 100644 (file)
@@ -29,11 +29,10 @@ int main(int argc, char **argv)
 
   /* SD initialization */
   SD_init(&argc, argv);
 
   /* SD initialization */
   SD_init(&argc, argv);
-  if (argc < 2) {
-    XBT_INFO("Usage: %s platform_file", argv[0]);
-    XBT_INFO("example: %s sd_platform.xml", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 1,
+            "Usage: %s platform_file\n\tExample: %s ../two_hosts.xml", 
+            argv[0], argv[0]);
+
   SD_create_environment(argv[1]);
 
   /* init of platform elements */
   SD_create_environment(argv[1]);
 
   /* init of platform elements */
@@ -61,10 +60,7 @@ int main(int argc, char **argv)
   /* Try to get a property that does not exist */
 
   value = SD_workstation_get_property_value(w1, noexist);
   /* Try to get a property that does not exist */
 
   value = SD_workstation_get_property_value(w1, noexist);
-  if (value == NULL)
-    XBT_INFO("\tProperty: %s is undefined", noexist);
-  else
-    XBT_INFO("\tProperty: %s has value: %s", noexist, value);
+  XBT_INFO("\tProperty: %s has value: %s", noexist, value?value:"Undefined (NULL)");
 
 
   XBT_INFO("Property list for workstation %s", name2);
 
 
   XBT_INFO("Property list for workstation %s", name2);
@@ -90,10 +86,7 @@ int main(int argc, char **argv)
 
   /* Test if we have changed the value */
   value = SD_workstation_get_property_value(w2, exist);
 
   /* Test if we have changed the value */
   value = SD_workstation_get_property_value(w2, exist);
-  if (value == NULL)
-    XBT_INFO("\tProperty: %s is undefined", exist);
-  else
-    XBT_INFO("\tProperty: %s new value: %s", exist, value);
+  XBT_INFO("\tProperty: %s new value: %s", exist, value?value:"Undefined (NULL)");
 
   /* Test if properties are displayed by SD_workstation_dump */
   SD_workstation_dump(w2);
 
   /* Test if properties are displayed by SD_workstation_dump */
   SD_workstation_dump(w2);
index 5e3323e..0748d8d 100755 (executable)
@@ -8,7 +8,7 @@ $ $SG_TEST_EXENV properties/sd_prop ${srcdir:=.}/../platforms/prop.xml
 > [0.000000] [test/INFO]       Property: mem has value: 4
 > [0.000000] [test/INFO]       Property: NewProp has value: newValue
 > [0.000000] [test/INFO]       Property: Hdd has value: 180
 > [0.000000] [test/INFO]       Property: mem has value: 4
 > [0.000000] [test/INFO]       Property: NewProp has value: newValue
 > [0.000000] [test/INFO]       Property: Hdd has value: 180
-> [0.000000] [test/INFO]       Property: NoProp is undefined
+> [0.000000] [test/INFO]       Property: NoProp has value: Undefined (NULL)
 > [0.000000] [test/INFO] Property list for workstation host2
 > [0.000000] [test/INFO]       Property: Hdd on host: 120
 > [0.000000] [test/INFO] Modify an existing property
 > [0.000000] [test/INFO] Property list for workstation host2
 > [0.000000] [test/INFO]       Property: Hdd on host: 120
 > [0.000000] [test/INFO] Modify an existing property
index 2d60522..130baf2 100644 (file)
@@ -107,10 +107,10 @@ static double finish_on_at(SD_task_t task, SD_workstation_t workstation)
       if (SD_task_get_kind(parent) == SD_TASK_COMM_E2E) {
         grand_parents = SD_task_get_parents(parent);
 
       if (SD_task_get_kind(parent) == SD_TASK_COMM_E2E) {
         grand_parents = SD_task_get_parents(parent);
 
-        if (xbt_dynar_length(grand_parents) > 1) {
-          XBT_ERROR("Warning: transfer %s has 2 parents",
-                 SD_task_get_name(parent));
-        }
+        xbt_assert(xbt_dynar_length(grand_parents) <2, 
+                  "Error: transfer %s has 2 parents", 
+                  SD_task_get_name(parent));
+        
         xbt_dynar_get_cpy(grand_parents, 0, &grand_parent);
 
         grand_parent_workstation_list =
         xbt_dynar_get_cpy(grand_parents, 0, &grand_parent);
 
         grand_parent_workstation_list =
@@ -261,24 +261,16 @@ int main(int argc, char **argv)
   SD_init(&argc, argv);
 
   /* Check our arguments */
   SD_init(&argc, argv);
 
   /* Check our arguments */
-  if (argc < 3) {
-    XBT_INFO("Usage: %s platform_file dax_file [jedule_file]", argv[0]);
-    XBT_INFO
-        ("example: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed",
-         argv[0]);
-    exit(1);
-  }
-  char *tracefilename;
-  if (argc == 3) {
-    char *last = strrchr(argv[2], '.');
-
-    tracefilename = bprintf("%.*s.jed",
-                            (int) (last ==
-                                   NULL ? strlen(argv[2]) : last -
-                                   argv[2]), argv[2]);
-  } else {
+  xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n"
+            "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", 
+            argv[0], argv[0]);
+
+  char *last = strrchr(argv[2], '.');
+  char * tracefilename = bprintf("%.*s.jed",(int) (last == NULL ? 
+                                                  strlen(argv[2]) : 
+                                                  last - argv[2]), argv[2]);  
+  if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
     tracefilename = xbt_strdup(argv[3]);
-  }
 
   /* creation of the environment */
   SD_create_environment(argv[1]);
 
   /* creation of the environment */
   SD_create_environment(argv[1]);
index 2b63063..260ef34 100644 (file)
@@ -26,11 +26,8 @@ int main(int argc, char **argv)
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
-  if (argc < 2) {
-    XBT_INFO("Usage: %s platform_file", argv[0]);
-    XBT_INFO("example: %s sd_platform.xml", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 1, "Usage: %s platform_file\n"
+            "\nExample: %s two_clusters.xml", argv[0], argv[0]);
 
   /* creation of the environment */
   platform_file = argv[1];
 
   /* creation of the environment */
   platform_file = argv[1];
index b56fe8b..291ae49 100644 (file)
@@ -42,11 +42,8 @@ int main(int argc, char **argv)
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
-  if (argc < 2) {
-    XBT_INFO("Usage: %s platform_file", argv[0]);
-    XBT_INFO("example: %s sd_platform.xml", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 1, "Usage: %s platform_file\n"
+            "\nExample: %s two_clusters.xml", argv[0], argv[0]);
 
   /* creation of the environment */
   platform_file = argv[1];
 
   /* creation of the environment */
   platform_file = argv[1];
index 0a9bf56..fa3e413 100644 (file)
@@ -60,11 +60,10 @@ int main(int argc, char **argv)
   SD_init(&argc, argv);
 
   /* creation of the environment */
   SD_init(&argc, argv);
 
   /* creation of the environment */
-  if (strstr(argv[1],".xml"))
-    SD_create_environment(argv[1]);
-  else
-    xbt_die("Unsupported platform description style (not XML): %s",
-            argv[1]);
+  xbt_assert(strstr(argv[1],".xml"), 
+            "Unsupported platform description style (not XML): %s",
+            argv[1]);
+  SD_create_environment(argv[1]);
 
   /* getting platform infos */
   n_hosts = SD_workstation_get_count();
 
   /* getting platform infos */
   n_hosts = SD_workstation_get_count();
index 32f3e59..e8fe7b4 100644 (file)
@@ -32,11 +32,8 @@ int main(int argc, char **argv)
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
-  if (argc < 2) {
-    XBT_INFO("Usage: %s platform_file", argv[0]);
-    XBT_INFO("example: %s sd_platform.xml", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 1, "Usage: %s platform_file\n"
+            "\nExample: %s two_clusters.xml", argv[0], argv[0]);
 
   /* creation of the environment */
   platform_file = argv[1];
 
   /* creation of the environment */
   platform_file = argv[1];
index 9786b1f..59953f5 100644 (file)
@@ -29,11 +29,8 @@ int main(int argc, char **argv)
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
 
   /*  xbt_log_control_set("sd.thres=debug"); */
 
-  if (argc < 2) {
-    XBT_INFO("Usage: %s platform_file", argv[0]);
-    XBT_INFO("example: %s sd_platform.xml", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 1, "Usage: %s platform_file\n"
+            "\nExample: %s two_clusters.xml", argv[0], argv[0]);
 
   /* creation of the environment */
   platform_file = argv[1];
 
   /* creation of the environment */
   platform_file = argv[1];