complete test program
authorJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Fri, 23 Oct 2009 21:55:31 +0000 (21:55 +0000)
committerJi Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96>
Fri, 23 Oct 2009 21:55:31 +0000 (21:55 +0000)
src/util/test_program.c

index 5c58123b573f2ee957d175d8d555e83703f6b0bd..08997627775d1e93e1ea9cabe712243ebe035038 100644 (file)
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-static int setme;
+static int setme1, setme2;
 
-static struct GNUNET_GETOPT_CommandLineOption options[] = {
-  {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme},
+static struct GNUNET_GETOPT_CommandLineOption options1[] = {
+  {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
   GNUNET_GETOPT_OPTION_END
 };
 
+static struct GNUNET_GETOPT_CommandLineOption options2[] = {
+  {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
+  {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
+};
+
+static struct GNUNET_GETOPT_CommandLineOption options3[] = {
+  {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
+  {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
+
+};
+
+static struct GNUNET_GETOPT_CommandLineOption options4[] = {
+  {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
+  {'n', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
+
+};
+
 /**
  * Main function that will be run.
  */
+
 static void
 runner (void *cls,
         struct GNUNET_SCHEDULER_Handle *sched,
         char *const *args,
-        const char *cfgfile, 
-       const struct GNUNET_CONFIGURATION_Handle *cfg)
+        const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   int *ok = cls;
-  GNUNET_assert (setme == 1);
+  GNUNET_assert (setme1 == 1);
   GNUNET_assert (sched != NULL);
   GNUNET_assert (0 == strcmp (args[0], "extra"));
   GNUNET_assert (args[1] == NULL);
@@ -54,7 +71,6 @@ runner (void *cls,
   *ok = 0;
 }
 
-
 /**
  * Main method, starts scheduler with task1,
  * checks that "ok" is correct at the end.
@@ -73,11 +89,29 @@ check ()
     "extra",
     NULL
   };
+
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_PROGRAM_run (7,
                                      argv,
                                      "test_program",
-                                     "A test", options, &runner, &ok));
+                                     "A test", options1, &runner, &ok));
+
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_PROGRAM_run (7,
+                                     argv,
+                                     "test_program",
+                                     "A test", options2, &runner, &ok));
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_PROGRAM_run (7,
+                                     argv,
+                                     "test_program",
+                                     "A test", options3, &runner, &ok));
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_PROGRAM_run (7,
+                                     argv,
+                                     "test_program",
+                                     "A test", options4, &runner, &ok));
+
   return ok;
 }