-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (testing_cfg, "nse-profiler",
- "WAIT_TIME", &wait_time))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option nse-profiler:wait_time is required!\n");
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (testing_cfg, "nse",
- "INTERVAL", &interval))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option nse:interval is required!\n");
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler",
- "connection_limit",
- &connection_limit))
- {
- connection_limit = 0;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler",
- "topology_output_file",
- &topology_file))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option nse-profiler:topology_output_file is required!\n");
- return;
- }
-
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler",
- "data_output_file",
- &data_filename))
- {
- data_file =
- GNUNET_DISK_file_open (data_filename,
- GNUNET_DISK_OPEN_READWRITE |
- GNUNET_DISK_OPEN_TRUNCATE |
- GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (data_file == NULL)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
- data_filename);
- GNUNET_free (data_filename);
- }
-
- if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "nse-profiler", "output_file",
- &temp_str))
- {
- output_file =
- GNUNET_DISK_file_open (temp_str,
- GNUNET_DISK_OPEN_READWRITE |
- GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (output_file == NULL)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
- temp_str);
- }
- GNUNET_free_non_null (temp_str);
-
- hosts = GNUNET_TESTING_hosts_load (testing_cfg);
-
- pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT,
- &connect_cb, &my_cb, NULL, hosts);
- GNUNET_assert (pg != NULL);
- shutdown_handle =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
+ for (tok = strtok (num_peer_spec, ","); NULL != tok; tok = strtok (NULL, ","))
+ {
+ if (1 != sscanf (tok, "%u", &num))
+ {
+ fprintf (stderr, "You need to specify numbers, not `%s'\n", tok);
+ return;
+ }
+ if (0 == num)
+ {
+ fprintf (stderr, "Refusing to run a round with 0 peers\n");
+ return;
+ }
+ GNUNET_array_append (num_peers_in_round, num_rounds, num);
+ num_peers = GNUNET_MAX (num_peers, num);
+ }
+ if (0 == num_peers)
+ {
+ fprintf (stderr, "Refusing to run a testbed with no rounds\n");
+ return;
+ }
+ if ( (NULL != data_filename) &&
+ (NULL == (data_file =
+ GNUNET_DISK_file_open (data_filename,
+ GNUNET_DISK_OPEN_READWRITE |
+ GNUNET_DISK_OPEN_TRUNCATE |
+ GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE))) )
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "open",
+ data_filename);
+
+ if ( (NULL != output_filename) &&
+ (NULL == (output_file =
+ GNUNET_DISK_file_open (output_filename,
+ GNUNET_DISK_OPEN_READWRITE |
+ GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE))) )
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
+ output_filename);
+ event_mask = 0LL;
+ event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
+ event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
+ event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
+ event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
+ GNUNET_TESTBED_run (hosts_file,
+ cfg,
+ num_peers,
+ event_mask,
+ master_controller_cb,
+ NULL, /* master_controller_cb cls */
+ &test_master,
+ NULL); /* test_master cls */
+ shutdown_task_id =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,