test_testing_topology.c 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2009 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file testing/test_testing_topology.c
  19. * @brief base testcase for testing all the topologies provided
  20. */
  21. #include "platform.h"
  22. #include "gnunet_testing_lib.h"
  23. #include "gnunet_core_service.h"
  24. #include "gnunet_os_lib.h"
  25. #define VERBOSE GNUNET_NO
  26. #define PROGRESS_BARS GNUNET_YES
  27. #define DELAY_FOR_LOGGING GNUNET_NO
  28. /**
  29. * How long until we fail the whole testcase?
  30. */
  31. #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 240)
  32. /**
  33. * How long until we give up on starting the peers?
  34. */
  35. #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 500)
  36. #define SECONDS_PER_PEER_START 120
  37. #define DEFAULT_NUM_PEERS 4
  38. #define MAX_OUTSTANDING_CONNECTIONS 100
  39. static float fail_percentage = 0.05;
  40. static int ok;
  41. static unsigned long long num_peers;
  42. struct GNUNET_TIME_Relative connect_timeout;
  43. static unsigned long long connect_attempts;
  44. static unsigned int topology_connections;
  45. static unsigned int total_connections;
  46. static unsigned int failed_connections;
  47. static unsigned int total_server_connections;
  48. static unsigned int total_messages_received;
  49. static unsigned int expected_messages;
  50. static unsigned int expected_connections;
  51. static unsigned long long peers_left;
  52. static struct GNUNET_TESTING_PeerGroup *pg;
  53. const struct GNUNET_CONFIGURATION_Handle *main_cfg;
  54. GNUNET_SCHEDULER_TaskIdentifier die_task;
  55. static char *dotOutFileName;
  56. static struct GNUNET_TIME_Relative settle_time;
  57. static FILE *dotOutFile;
  58. static char *topology_string;
  59. static char *blacklist_transports;
  60. static int transmit_ready_scheduled;
  61. static int transmit_ready_failed;
  62. static int transmit_ready_called;
  63. static unsigned int modnum;
  64. static unsigned int dotnum;
  65. static enum GNUNET_TESTING_Topology topology;
  66. static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */
  67. static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */
  68. static enum GNUNET_TESTING_TopologyOption connect_topology_option =
  69. GNUNET_TESTING_TOPOLOGY_OPTION_ALL;
  70. static double connect_topology_option_modifier = 0.0;
  71. static char *test_directory;
  72. #define MTYPE 12345
  73. struct GNUNET_TestMessage
  74. {
  75. /**
  76. * Header of the message
  77. */
  78. struct GNUNET_MessageHeader header;
  79. /**
  80. * Unique identifier for this message.
  81. */
  82. uint32_t uid;
  83. };
  84. struct TestMessageContext
  85. {
  86. /* This is a linked list */
  87. struct TestMessageContext *next;
  88. /* Handle to the sending peer core */
  89. struct GNUNET_CORE_Handle *peer1handle;
  90. /* Handle to the receiving peer core */
  91. struct GNUNET_CORE_Handle *peer2handle;
  92. /* Handle to the sending peer daemon */
  93. struct GNUNET_TESTING_Daemon *peer1;
  94. /* Handle to the receiving peer daemon */
  95. struct GNUNET_TESTING_Daemon *peer2;
  96. /* Identifier for this message, so we don't disconnect other peers! */
  97. uint32_t uid;
  98. /* Has peer1 been notified already of a connection to peer2? */
  99. int peer1notified;
  100. /* Has the core of peer2 been connected already? */
  101. int peer2connected;
  102. /* Task for disconnecting cores, allow task to be cancelled on shutdown */
  103. GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
  104. };
  105. static struct TestMessageContext *test_messages;
  106. /**
  107. * Check whether peers successfully shut down.
  108. */
  109. void
  110. shutdown_callback (void *cls, const char *emsg)
  111. {
  112. if (emsg != NULL)
  113. {
  114. #if VERBOSE
  115. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n");
  116. #endif
  117. if (ok == 0)
  118. ok = 666;
  119. }
  120. else
  121. {
  122. #if VERBOSE
  123. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  124. "All peers successfully shut down!\n");
  125. #endif
  126. }
  127. }
  128. #if DELAY_FOR_LOGGING
  129. static void
  130. gather_log_data ()
  131. {
  132. char *peer_number;
  133. char *connect_number;
  134. struct GNUNET_OS_Process *mem_process;
  135. GNUNET_asprintf (&peer_number, "%llu", num_peers);
  136. GNUNET_asprintf (&connect_number, "%llu", expected_connections);
  137. mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl",
  138. "memsize.pl", "totals.txt",
  139. peer_number, connect_number, NULL);
  140. GNUNET_OS_process_wait (mem_process);
  141. GNUNET_OS_process_close (mem_process);
  142. mem_process = NULL;
  143. }
  144. #endif
  145. static void
  146. finish_testing ()
  147. {
  148. GNUNET_assert (pg != NULL);
  149. struct TestMessageContext *pos;
  150. struct TestMessageContext *free_pos;
  151. #if VERBOSE
  152. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  153. "Called finish testing, stopping daemons.\n");
  154. #endif
  155. pos = test_messages;
  156. while (pos != NULL)
  157. {
  158. if (pos->peer1handle != NULL)
  159. {
  160. GNUNET_CORE_disconnect (pos->peer1handle);
  161. pos->peer1handle = NULL;
  162. }
  163. if (pos->peer2handle != NULL)
  164. {
  165. GNUNET_CORE_disconnect (pos->peer2handle);
  166. pos->peer2handle = NULL;
  167. }
  168. free_pos = pos;
  169. pos = pos->next;
  170. if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
  171. {
  172. GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
  173. }
  174. GNUNET_free (free_pos);
  175. }
  176. #if VERBOSE
  177. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  178. "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
  179. transmit_ready_scheduled, transmit_ready_failed,
  180. transmit_ready_called);
  181. #endif
  182. #if VERBOSE
  183. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n");
  184. #endif
  185. GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
  186. if (dotOutFile != NULL)
  187. {
  188. fprintf (dotOutFile, "}");
  189. fclose (dotOutFile);
  190. }
  191. ok = 0;
  192. }
  193. static void
  194. disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  195. {
  196. struct TestMessageContext *pos = cls;
  197. /* Disconnect from the respective cores */
  198. #if VERBOSE > 1
  199. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  200. "Disconnecting from peer 1 `%4s'\n",
  201. GNUNET_i2s (&pos->peer1->id));
  202. #endif
  203. if (pos->peer1handle != NULL)
  204. GNUNET_CORE_disconnect (pos->peer1handle);
  205. #if VERBOSE > 1
  206. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  207. "Disconnecting from peer 2 `%4s'\n",
  208. GNUNET_i2s (&pos->peer2->id));
  209. #endif
  210. if (pos->peer2handle != NULL)
  211. GNUNET_CORE_disconnect (pos->peer2handle);
  212. /* Set handles to NULL so test case can be ended properly */
  213. pos->peer1handle = NULL;
  214. pos->peer2handle = NULL;
  215. pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
  216. /* Decrement total connections so new can be established */
  217. total_server_connections -= 2;
  218. }
  219. #if DO_STATS
  220. static void
  221. stats_finished (void *cls, int result)
  222. {
  223. GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
  224. }
  225. /**
  226. * Callback function to process statistic values.
  227. *
  228. * @param cls closure
  229. * @param peer the peer the statistics belong to
  230. * @param subsystem name of subsystem that created the statistic
  231. * @param name the name of the datum
  232. * @param value the current value
  233. * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
  234. * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
  235. */
  236. static int
  237. stats_print (void *cls,
  238. const struct GNUNET_PeerIdentity *peer,
  239. const char *subsystem,
  240. const char *name, uint64_t value, int is_persistent)
  241. {
  242. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n",
  243. GNUNET_i2s (peer), subsystem, name, value);
  244. return GNUNET_OK;
  245. }
  246. #endif
  247. static void
  248. topology_cb (void *cls,
  249. const struct GNUNET_PeerIdentity *first,
  250. const struct GNUNET_PeerIdentity *second, const char *emsg)
  251. {
  252. FILE *outfile = cls;
  253. if (first != NULL)
  254. {
  255. if (outfile != NULL)
  256. {
  257. fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first));
  258. fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second));
  259. }
  260. topology_connections++;
  261. }
  262. else
  263. {
  264. fprintf (stderr,
  265. "Finished iterating over topology, %d total connections!\n",
  266. topology_connections);
  267. if (outfile != NULL)
  268. {
  269. fprintf (outfile, "}\n");
  270. fclose (outfile);
  271. #if DO_STATS
  272. GNUNET_TESTING_get_statistics (pg, &stats_finished, &stats_print,
  273. NULL);
  274. #endif
  275. GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
  276. }
  277. }
  278. }
  279. static int
  280. process_mtype (void *cls,
  281. const struct GNUNET_PeerIdentity *peer,
  282. const struct GNUNET_MessageHeader *message,
  283. const struct GNUNET_TRANSPORT_ATS_Information *atsi)
  284. {
  285. char *dotOutFileNameFinished;
  286. FILE *dotOutFileFinished;
  287. struct TestMessageContext *pos = cls;
  288. struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message;
  289. if (pos->uid != ntohl (msg->uid))
  290. return GNUNET_OK;
  291. #if PROGRESS_BARS
  292. if ((total_messages_received) % modnum == 0)
  293. {
  294. if (total_messages_received == 0)
  295. fprintf (stdout, "0%%");
  296. else
  297. fprintf (stdout, "%d%%",
  298. (int) (((float) total_messages_received /
  299. expected_messages) * 100));
  300. }
  301. else if (total_messages_received % dotnum == 0)
  302. {
  303. fprintf (stdout, ".");
  304. }
  305. fflush (stdout);
  306. #endif
  307. total_messages_received++;
  308. #if VERBOSE > 1
  309. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  310. "Received message from `%4s', type %d.\n", GNUNET_i2s (peer),
  311. ntohs (message->type));
  312. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  313. "Total messages received %d, expected %d.\n",
  314. total_messages_received, expected_messages);
  315. #endif
  316. if (total_messages_received == expected_messages)
  317. {
  318. #if PROGRESS_BARS
  319. fprintf (stdout, "100%%]\n");
  320. #endif
  321. GNUNET_SCHEDULER_cancel (die_task);
  322. GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology");
  323. dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
  324. GNUNET_free (dotOutFileNameFinished);
  325. if (dotOutFileFinished != NULL)
  326. {
  327. fprintf (dotOutFileFinished, "strict graph G {\n");
  328. }
  329. topology_connections = 0;
  330. GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished);
  331. //GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
  332. }
  333. else
  334. {
  335. pos->disconnect_task =
  336. GNUNET_SCHEDULER_add_now (&disconnect_cores, pos);
  337. }
  338. return GNUNET_OK;
  339. }
  340. static void
  341. end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  342. {
  343. char *msg = cls;
  344. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  345. "End badly was called (%s)... stopping daemons.\n", msg);
  346. struct TestMessageContext *pos;
  347. struct TestMessageContext *free_pos;
  348. pos = test_messages;
  349. while (pos != NULL)
  350. {
  351. if (pos->peer1handle != NULL)
  352. {
  353. GNUNET_CORE_disconnect (pos->peer1handle);
  354. pos->peer1handle = NULL;
  355. }
  356. if (pos->peer2handle != NULL)
  357. {
  358. GNUNET_CORE_disconnect (pos->peer2handle);
  359. pos->peer2handle = NULL;
  360. }
  361. free_pos = pos;
  362. pos = pos->next;
  363. GNUNET_free (free_pos);
  364. }
  365. #if VERBOSE
  366. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  367. "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
  368. transmit_ready_scheduled, transmit_ready_failed,
  369. transmit_ready_called);
  370. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  371. "Total messages received %d, expected %d.\n",
  372. total_messages_received, expected_messages);
  373. #endif
  374. if (pg != NULL)
  375. {
  376. GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
  377. ok = 7331; /* Opposite of leet */
  378. }
  379. else
  380. ok = 401; /* Never got peers started */
  381. if (dotOutFile != NULL)
  382. {
  383. fprintf (dotOutFile, "}");
  384. fclose (dotOutFile);
  385. }
  386. }
  387. static size_t
  388. transmit_ready (void *cls, size_t size, void *buf)
  389. {
  390. struct GNUNET_TestMessage *m;
  391. struct TestMessageContext *pos = cls;
  392. GNUNET_assert (buf != NULL);
  393. m = (struct GNUNET_TestMessage *) buf;
  394. m->header.type = htons (MTYPE);
  395. m->header.size = htons (sizeof (struct GNUNET_TestMessage));
  396. m->uid = htonl (pos->uid);
  397. transmit_ready_called++;
  398. #if VERBOSE > 1
  399. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  400. "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n",
  401. GNUNET_i2s (&pos->peer1->id), transmit_ready_scheduled,
  402. transmit_ready_called);
  403. #endif
  404. return sizeof (struct GNUNET_TestMessage);
  405. }
  406. static struct GNUNET_CORE_MessageHandler no_handlers[] = {
  407. {NULL, 0, 0}
  408. };
  409. static struct GNUNET_CORE_MessageHandler handlers[] = {
  410. {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)},
  411. {NULL, 0, 0}
  412. };
  413. static void
  414. init_notify_peer2 (void *cls,
  415. struct GNUNET_CORE_Handle *server,
  416. const struct GNUNET_PeerIdentity *my_identity,
  417. const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
  418. *publicKey)
  419. {
  420. struct TestMessageContext *pos = cls;
  421. total_server_connections++;
  422. pos->peer2connected = GNUNET_YES;
  423. if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */
  424. {
  425. #if VERBOSE > 1
  426. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  427. "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
  428. GNUNET_i2s (my_identity), GNUNET_h2s(&pos->peer1->id.hashPubKey));
  429. #endif
  430. if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
  431. GNUNET_YES,
  432. 0,
  433. TIMEOUT,
  434. &pos->peer2->id,
  435. sizeof (struct
  436. GNUNET_TestMessage),
  437. &transmit_ready, pos))
  438. {
  439. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  440. "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
  441. GNUNET_i2s (&pos->peer2->id));
  442. transmit_ready_failed++;
  443. }
  444. else
  445. {
  446. transmit_ready_scheduled++;
  447. }
  448. }
  449. }
  450. /**
  451. * Method called whenever a given peer connects.
  452. *
  453. * @param cls closure
  454. * @param peer peer identity this notification is about
  455. * @param atsi performance data for the connection
  456. */
  457. static void connect_notify_peers (void *cls,
  458. const struct
  459. GNUNET_PeerIdentity *peer,
  460. const struct GNUNET_TRANSPORT_ATS_Information *atsi)
  461. {
  462. struct TestMessageContext *pos = cls;
  463. if (0 == memcmp(peer, &pos->peer2->id, sizeof(struct GNUNET_PeerIdentity)))
  464. {
  465. pos->peer1notified = GNUNET_YES;
  466. #if VERBOSE > 1
  467. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  468. "Peer `%s' notified of connection to peer `%s'\n",
  469. GNUNET_i2s (&pos->peer1->id), GNUNET_h2s(&peer->hashPubKey));
  470. #endif
  471. }
  472. else
  473. return;
  474. if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */
  475. {
  476. #if VERBOSE > 1
  477. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  478. "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
  479. GNUNET_i2s (&pos->peer2->id), GNUNET_h2s(&pos->peer1->id.hashPubKey));
  480. #endif
  481. if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
  482. GNUNET_YES,
  483. 0,
  484. TIMEOUT,
  485. &pos->peer2->id,
  486. sizeof (struct
  487. GNUNET_TestMessage),
  488. &transmit_ready, pos))
  489. {
  490. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  491. "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
  492. GNUNET_i2s (&pos->peer2->id));
  493. transmit_ready_failed++;
  494. }
  495. else
  496. {
  497. transmit_ready_scheduled++;
  498. }
  499. }
  500. }
  501. static void
  502. init_notify_peer1 (void *cls,
  503. struct GNUNET_CORE_Handle *server,
  504. const struct GNUNET_PeerIdentity *my_identity,
  505. const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
  506. *publicKey)
  507. {
  508. struct TestMessageContext *pos = cls;
  509. total_server_connections++;
  510. #if VERBOSE > 1
  511. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  512. "Core connection to `%4s' established, setting up handles\n",
  513. GNUNET_i2s (my_identity));
  514. #endif
  515. /*
  516. * Connect to the receiving peer
  517. */
  518. pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
  519. 1,
  520. pos,
  521. &init_notify_peer2,
  522. NULL,
  523. NULL,
  524. NULL, NULL,
  525. GNUNET_YES, NULL, GNUNET_YES,
  526. handlers);
  527. }
  528. static void
  529. send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  530. {
  531. struct TestMessageContext *pos = cls;
  532. if ((pos == test_messages) && (settle_time.rel_value > 0))
  533. {
  534. topology_connections = 0;
  535. GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);
  536. }
  537. if (( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)|| (cls == NULL))
  538. return;
  539. if (die_task == GNUNET_SCHEDULER_NO_TASK)
  540. {
  541. die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
  542. &end_badly,
  543. "from send test messages (timeout)");
  544. }
  545. if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
  546. {
  547. GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  548. (GNUNET_TIME_UNIT_SECONDS, 1),
  549. &send_test_messages, pos);
  550. return; /* Otherwise we'll double schedule messages here! */
  551. }
  552. /*
  553. * Connect to the sending peer
  554. */
  555. pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg,
  556. 1,
  557. pos,
  558. &init_notify_peer1,
  559. &connect_notify_peers, NULL,
  560. NULL,
  561. NULL,
  562. GNUNET_NO, NULL, GNUNET_NO,
  563. no_handlers);
  564. GNUNET_assert (pos->peer1handle != NULL);
  565. if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
  566. {
  567. GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);
  568. }
  569. else
  570. {
  571. GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  572. (GNUNET_TIME_UNIT_SECONDS, 1),
  573. &send_test_messages, pos->next);
  574. }
  575. }
  576. void
  577. topology_callback (void *cls,
  578. const struct GNUNET_PeerIdentity *first,
  579. const struct GNUNET_PeerIdentity *second,
  580. uint32_t distance,
  581. const struct GNUNET_CONFIGURATION_Handle *first_cfg,
  582. const struct GNUNET_CONFIGURATION_Handle *second_cfg,
  583. struct GNUNET_TESTING_Daemon *first_daemon,
  584. struct GNUNET_TESTING_Daemon *second_daemon,
  585. const char *emsg)
  586. {
  587. struct TestMessageContext *temp_context;
  588. if (emsg == NULL)
  589. {
  590. #if PROGRESS_BARS
  591. if ((total_connections) % modnum == 0)
  592. {
  593. if (total_connections == 0)
  594. fprintf (stdout, "0%%");
  595. else
  596. fprintf (stdout, "%d%%",
  597. (int) (((float) total_connections /
  598. expected_connections) * 100));
  599. }
  600. else if (total_connections % dotnum == 0)
  601. {
  602. fprintf (stdout, ".");
  603. }
  604. fflush (stdout);
  605. #endif
  606. total_connections++;
  607. #if VERBOSE > 1
  608. GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n",
  609. first_daemon->shortname, second_daemon->shortname);
  610. #endif
  611. temp_context = GNUNET_malloc (sizeof (struct TestMessageContext));
  612. temp_context->peer1 = first_daemon;
  613. temp_context->peer2 = second_daemon;
  614. temp_context->next = test_messages;
  615. temp_context->uid = total_connections;
  616. temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
  617. test_messages = temp_context;
  618. expected_messages++;
  619. if (dotOutFile != NULL)
  620. fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname,
  621. second_daemon->shortname);
  622. }
  623. #if VERBOSE
  624. else
  625. {
  626. failed_connections++;
  627. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  628. "Failed to connect peer %s to peer %s with error :\n%s\n",
  629. first_daemon->shortname, second_daemon->shortname, emsg);
  630. }
  631. #endif
  632. if (total_connections == expected_connections)
  633. {
  634. #if PROGRESS_BARS
  635. fprintf (stdout, "100%%]\n");
  636. #endif
  637. #if VERBOSE
  638. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  639. "Created %d total connections, which is our target number! Calling send messages.\n",
  640. total_connections);
  641. #endif
  642. modnum = expected_messages / 4;
  643. dotnum = (expected_messages / 50) + 1;
  644. if (modnum == 0)
  645. modnum = 1;
  646. if (dotnum == 0)
  647. dotnum = 1;
  648. GNUNET_SCHEDULER_cancel (die_task);
  649. die_task = GNUNET_SCHEDULER_NO_TASK;
  650. #if DELAY_FOR_LOGGING
  651. fprintf (stdout, "Sending test messages in 10 seconds.\n");
  652. GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  653. (GNUNET_TIME_UNIT_SECONDS, 10),
  654. &send_test_messages, test_messages);
  655. gather_log_data ();
  656. #else
  657. if (settle_time.rel_value > 0)
  658. {
  659. GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);
  660. }
  661. GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages,
  662. test_messages);
  663. #endif
  664. #if PROGRESS_BARS
  665. fprintf (stdout, "Test message progress: [");
  666. #endif
  667. }
  668. else if (total_connections + failed_connections == expected_connections)
  669. {
  670. if (failed_connections <
  671. (unsigned int) (fail_percentage * total_connections))
  672. {
  673. GNUNET_SCHEDULER_cancel (die_task);
  674. die_task = GNUNET_SCHEDULER_NO_TASK;
  675. GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
  676. }
  677. else
  678. {
  679. GNUNET_SCHEDULER_cancel (die_task);
  680. die_task =
  681. GNUNET_SCHEDULER_add_now (&end_badly,
  682. "from topology_callback (too many failed connections)");
  683. }
  684. }
  685. else
  686. {
  687. #if VERBOSE > 1
  688. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  689. "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
  690. total_connections, failed_connections, expected_connections,
  691. expected_connections -
  692. (unsigned int) (fail_percentage * expected_connections));
  693. #endif
  694. }
  695. }
  696. static void
  697. topology_creation_finished (void *cls, const char *emsg)
  698. {
  699. #if VERBOSE
  700. if (emsg == NULL)
  701. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  702. "All topology connections created successfully!\n");
  703. #endif
  704. }
  705. static void
  706. connect_topology ()
  707. {
  708. expected_connections = -1;
  709. if ((pg != NULL) && (peers_left == 0))
  710. {
  711. expected_connections =
  712. GNUNET_TESTING_connect_topology (pg, connection_topology,
  713. connect_topology_option,
  714. connect_topology_option_modifier,
  715. connect_timeout,
  716. connect_attempts,
  717. &topology_creation_finished, NULL);
  718. #if PROGRESS_BARS
  719. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  720. "Have %d expected connections\n", expected_connections);
  721. #endif
  722. }
  723. GNUNET_SCHEDULER_cancel (die_task);
  724. if (expected_connections < 1)
  725. {
  726. die_task =
  727. GNUNET_SCHEDULER_add_now (&end_badly,
  728. "from connect topology (bad return)");
  729. return;
  730. }
  731. die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  732. (GNUNET_TIME_UNIT_SECONDS,
  733. SECONDS_PER_PEER_START * num_peers),
  734. &end_badly,
  735. "from connect topology (timeout)");
  736. modnum = expected_connections / 4;
  737. dotnum = (expected_connections / 50) + 1;
  738. if (modnum == 0)
  739. modnum = 1;
  740. if (dotnum == 0)
  741. dotnum = 1;
  742. #if PROGRESS_BARS
  743. fprintf (stdout, "Peer connection progress: [");
  744. #endif
  745. }
  746. static void
  747. create_topology ()
  748. {
  749. peers_left = num_peers; /* Reset counter */
  750. if (GNUNET_TESTING_create_topology
  751. (pg, topology, blacklist_topology,
  752. blacklist_transports) != GNUNET_SYSERR)
  753. {
  754. #if PROGRESS_BARS
  755. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  756. "Topology set up, now starting peers!\n");
  757. fprintf (stdout, "Daemon start progress [");
  758. #endif
  759. GNUNET_TESTING_daemons_continue_startup (pg);
  760. }
  761. else
  762. {
  763. GNUNET_SCHEDULER_cancel (die_task);
  764. die_task =
  765. GNUNET_SCHEDULER_add_now (&end_badly,
  766. "from create topology (bad return)");
  767. }
  768. GNUNET_SCHEDULER_cancel (die_task);
  769. die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  770. (GNUNET_TIME_UNIT_SECONDS,
  771. SECONDS_PER_PEER_START * num_peers),
  772. &end_badly,
  773. "from continue startup (timeout)");
  774. }
  775. static void
  776. peers_started_callback (void *cls,
  777. const struct GNUNET_PeerIdentity *id,
  778. const struct GNUNET_CONFIGURATION_Handle *cfg,
  779. struct GNUNET_TESTING_Daemon *d, const char *emsg)
  780. {
  781. if (emsg != NULL)
  782. {
  783. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  784. "Failed to start daemon with error: `%s'\n", emsg);
  785. return;
  786. }
  787. GNUNET_assert (id != NULL);
  788. #if VERBOSE > 1
  789. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
  790. (num_peers - peers_left) + 1, num_peers);
  791. #endif
  792. #if PROGRESS_BARS
  793. if ((num_peers - peers_left) % modnum == 0)
  794. {
  795. if (num_peers - peers_left == 0)
  796. fprintf (stdout, "0%%");
  797. else
  798. fprintf (stdout, "%d%%",
  799. (int) (((float) (num_peers - peers_left) /
  800. num_peers) * 100));
  801. }
  802. else if ((num_peers - peers_left) % dotnum == 0)
  803. {
  804. fprintf (stdout, ".");
  805. }
  806. fflush (stdout);
  807. #endif
  808. peers_left--;
  809. if (peers_left == 0)
  810. {
  811. #if PROGRESS_BARS
  812. fprintf (stdout, "100%%]\n");
  813. #endif
  814. #if VERBOSE
  815. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  816. "All %d daemons started, now connecting peers!\n",
  817. num_peers);
  818. #endif
  819. GNUNET_SCHEDULER_cancel (die_task);
  820. /* Set up task in case topology creation doesn't finish
  821. * within a reasonable amount of time */
  822. die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  823. (GNUNET_TIME_UNIT_MINUTES, 8),
  824. &end_badly,
  825. "from peers_started_callback");
  826. #if DELAY_FOR_LOGGING
  827. fprintf (stdout, "Connecting topology in 10 seconds\n");
  828. gather_log_data ();
  829. GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  830. (GNUNET_TIME_UNIT_SECONDS, 10),
  831. &connect_topology, NULL);
  832. #else
  833. connect_topology ();
  834. #endif
  835. ok = 0;
  836. }
  837. }
  838. /**
  839. * Callback indicating that the hostkey was created for a peer.
  840. *
  841. * @param cls NULL
  842. * @param id the peer identity
  843. * @param d the daemon handle (pretty useless at this point, remove?)
  844. * @param emsg non-null on failure
  845. */
  846. void
  847. hostkey_callback (void *cls,
  848. const struct GNUNET_PeerIdentity *id,
  849. struct GNUNET_TESTING_Daemon *d, const char *emsg)
  850. {
  851. if (emsg != NULL)
  852. {
  853. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  854. "Hostkey callback received error: %s\n", emsg);
  855. }
  856. #if VERBOSE > 1
  857. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  858. "Hostkey (%d/%d) created for peer `%s'\n",
  859. num_peers - peers_left, num_peers, GNUNET_i2s (id));
  860. #endif
  861. #if PROGRESS_BARS
  862. if ((num_peers - peers_left) % modnum == 0)
  863. {
  864. if (num_peers - peers_left == 0)
  865. fprintf (stdout, "0%%");
  866. else
  867. fprintf (stdout, "%d%%",
  868. (int) (((float) (num_peers - peers_left) /
  869. num_peers) * 100));
  870. }
  871. else if ((num_peers - peers_left) % dotnum == 0)
  872. {
  873. fprintf (stdout, ".");
  874. }
  875. fflush (stdout);
  876. #endif
  877. peers_left--;
  878. if (peers_left == 0)
  879. {
  880. #if PROGRESS_BARS
  881. fprintf (stdout, "100%%]\n");
  882. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  883. "All %d hostkeys created, now creating topology!\n",
  884. num_peers);
  885. #endif
  886. GNUNET_SCHEDULER_cancel (die_task);
  887. /* Set up task in case topology creation doesn't finish
  888. * within a reasonable amount of time */
  889. die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
  890. &end_badly,
  891. "from create_topology");
  892. GNUNET_SCHEDULER_add_now (&create_topology, NULL);
  893. ok = 0;
  894. }
  895. }
  896. static void
  897. run (void *cls,
  898. char *const *args,
  899. const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
  900. {
  901. char *topology_str;
  902. char *connect_topology_str;
  903. char *blacklist_topology_str;
  904. char *connect_topology_option_str;
  905. char *connect_topology_option_modifier_string;
  906. unsigned long long temp_settle;
  907. unsigned long long max_outstanding_connections;
  908. ok = 1;
  909. dotOutFile = fopen (dotOutFileName, "w");
  910. if (dotOutFile != NULL)
  911. {
  912. fprintf (dotOutFile, "strict graph G {\n");
  913. }
  914. #if VERBOSE
  915. GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
  916. "Starting daemons based on config file %s\n", cfgfile);
  917. #endif
  918. if (GNUNET_YES !=
  919. GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
  920. &test_directory))
  921. {
  922. ok = 404;
  923. return;
  924. }
  925. if ((GNUNET_YES ==
  926. GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
  927. &topology_str))
  928. && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str)))
  929. {
  930. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  931. "Invalid topology `%s' given for section %s option %s\n",
  932. topology_str, "TESTING", "TOPOLOGY");
  933. topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
  934. }
  935. if ((GNUNET_YES ==
  936. GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
  937. "connect_topology",
  938. &connect_topology_str))
  939. && (GNUNET_NO ==
  940. GNUNET_TESTING_topology_get (&connection_topology,
  941. connect_topology_str)))
  942. {
  943. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  944. "Invalid connect topology `%s' given for section %s option %s\n",
  945. connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
  946. }
  947. GNUNET_free_non_null (connect_topology_str);
  948. if ((GNUNET_YES ==
  949. GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
  950. "connect_topology_option",
  951. &connect_topology_option_str))
  952. && (GNUNET_NO ==
  953. GNUNET_TESTING_topology_option_get (&connect_topology_option,
  954. connect_topology_option_str)))
  955. {
  956. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  957. "Invalid connect topology option `%s' given for section %s option %s\n",
  958. connect_topology_option_str, "TESTING",
  959. "CONNECT_TOPOLOGY_OPTION");
  960. connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
  961. }
  962. GNUNET_free_non_null (connect_topology_option_str);
  963. if (GNUNET_YES ==
  964. GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
  965. "connect_topology_option_modifier",
  966. &connect_topology_option_modifier_string))
  967. {
  968. if (sscanf
  969. (connect_topology_option_modifier_string, "%lf",
  970. &connect_topology_option_modifier) != 1)
  971. {
  972. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  973. _
  974. ("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
  975. connect_topology_option_modifier_string,
  976. "connect_topology_option_modifier", "TESTING");
  977. }
  978. GNUNET_free (connect_topology_option_modifier_string);
  979. }
  980. if (GNUNET_YES !=
  981. GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
  982. "blacklist_transports",
  983. &blacklist_transports))
  984. blacklist_transports = NULL;
  985. if ((GNUNET_YES ==
  986. GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
  987. "blacklist_topology",
  988. &blacklist_topology_str))
  989. && (GNUNET_NO ==
  990. GNUNET_TESTING_topology_get (&blacklist_topology,
  991. blacklist_topology_str)))
  992. {
  993. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  994. "Invalid topology `%s' given for section %s option %s\n",
  995. topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
  996. }
  997. GNUNET_free_non_null (topology_str);
  998. GNUNET_free_non_null (blacklist_topology_str);
  999. if (GNUNET_OK ==
  1000. GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time",
  1001. &temp_settle))
  1002. settle_time =
  1003. GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
  1004. if (GNUNET_OK ==
  1005. GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
  1006. &temp_settle))
  1007. connect_timeout =
  1008. GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
  1009. else
  1010. {
  1011. GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
  1012. return;
  1013. }
  1014. if (GNUNET_OK !=
  1015. GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
  1016. &connect_attempts))
  1017. {
  1018. GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
  1019. return;
  1020. }
  1021. if (GNUNET_OK !=
  1022. GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "max_outstanding_connections",
  1023. &max_outstanding_connections))
  1024. {
  1025. GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections");
  1026. return;
  1027. }
  1028. if (GNUNET_SYSERR ==
  1029. GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
  1030. &num_peers))
  1031. num_peers = DEFAULT_NUM_PEERS;
  1032. main_cfg = cfg;
  1033. peers_left = num_peers;
  1034. modnum = num_peers / 4;
  1035. dotnum = (num_peers / 50) + 1;
  1036. if (modnum == 0)
  1037. modnum = 1;
  1038. if (dotnum == 0)
  1039. dotnum = 1;
  1040. #if PROGRESS_BARS
  1041. fprintf (stdout, "Hostkey generation progress: [");
  1042. #endif
  1043. /* Set up a task to end testing if peer start fails */
  1044. die_task =
  1045. GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
  1046. (GNUNET_TIME_UNIT_SECONDS,
  1047. SECONDS_PER_PEER_START * num_peers),
  1048. &end_badly,
  1049. "didn't generate all hostkeys within a reasonable amount of time!!!");
  1050. GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
  1051. pg = GNUNET_TESTING_daemons_start (cfg,
  1052. peers_left,
  1053. max_outstanding_connections,
  1054. peers_left,
  1055. GNUNET_TIME_relative_multiply
  1056. (GNUNET_TIME_UNIT_SECONDS,
  1057. SECONDS_PER_PEER_START * num_peers),
  1058. &hostkey_callback, NULL,
  1059. &peers_started_callback, NULL,
  1060. &topology_callback, NULL, NULL);
  1061. }
  1062. static int
  1063. check ()
  1064. {
  1065. char *binary_name;
  1066. char *config_file_name;
  1067. GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string);
  1068. GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf",
  1069. topology_string);
  1070. int ret;
  1071. char *const argv[] = { binary_name,
  1072. "-c",
  1073. config_file_name,
  1074. #if VERBOSE
  1075. "-L", "DEBUG",
  1076. #endif
  1077. NULL
  1078. };
  1079. struct GNUNET_GETOPT_CommandLineOption options[] = {
  1080. GNUNET_GETOPT_OPTION_END
  1081. };
  1082. ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
  1083. argv, binary_name, "nohelp", options, &run, &ok);
  1084. if (ret != GNUNET_OK)
  1085. {
  1086. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  1087. "`test-testing-topology-%s': Failed with error code %d\n",
  1088. topology_string, ret);
  1089. }
  1090. GNUNET_free (binary_name);
  1091. GNUNET_free (config_file_name);
  1092. return ok;
  1093. }
  1094. int
  1095. main (int argc, char *argv[])
  1096. {
  1097. int ret;
  1098. char *binary_start_pos;
  1099. char *our_binary_name;
  1100. binary_start_pos = strchr (argv[0], '/');
  1101. GNUNET_assert (binary_start_pos != NULL);
  1102. topology_string = strstr (binary_start_pos, "_topology");
  1103. GNUNET_assert (topology_string != NULL);
  1104. topology_string++;
  1105. topology_string = strstr (topology_string, "_");
  1106. GNUNET_assert (topology_string != NULL);
  1107. topology_string++;
  1108. GNUNET_asprintf (&our_binary_name, "test-testing-topology_%s",
  1109. topology_string);
  1110. GNUNET_asprintf (&dotOutFileName, "topology_%s.dot", topology_string);
  1111. GNUNET_log_setup (our_binary_name,
  1112. #if VERBOSE
  1113. "DEBUG",
  1114. #else
  1115. "WARNING",
  1116. #endif
  1117. NULL);
  1118. ret = check ();
  1119. /**
  1120. * Need to remove base directory, subdirectories taken care
  1121. * of by the testing framework.
  1122. */
  1123. if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
  1124. {
  1125. GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
  1126. "Failed to remove testing directory %s\n", test_directory);
  1127. }
  1128. GNUNET_free (our_binary_name);
  1129. return ret;
  1130. }
  1131. /* end of test_testing_topology.c */