aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 3756d08e3..a43bed31f 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -124,7 +124,7 @@ struct GNUNET_TESTING_System
124 char *hostkeys_data; 124 char *hostkeys_data;
125 125
126 /** 126 /**
127 * memory map for 'hostkeys_data'. 127 * memory map for @e hostkeys_data.
128 */ 128 */
129 struct GNUNET_DISK_MapHandle *map; 129 struct GNUNET_DISK_MapHandle *map;
130 130
@@ -256,7 +256,7 @@ struct GNUNET_TESTING_Peer
256 * startup. This function loads such keys into memory from a file. 256 * startup. This function loads such keys into memory from a file.
257 * 257 *
258 * @param system the testing system handle 258 * @param system the testing system handle
259 * @return GNUNET_OK on success; GNUNET_SYSERR on error 259 * @return #GNUNET_OK on success; #GNUNET_SYSERR on error
260 */ 260 */
261static int 261static int
262hostkeys_load (struct GNUNET_TESTING_System *system) 262hostkeys_load (struct GNUNET_TESTING_System *system)
@@ -465,6 +465,7 @@ GNUNET_TESTING_system_create (const char *testdir,
465 HIGH_PORT); 465 HIGH_PORT);
466} 466}
467 467
468
468static void 469static void
469cleanup_shared_service_instance (struct SharedServiceInstance *i) 470cleanup_shared_service_instance (struct SharedServiceInstance *i)
470{ 471{
@@ -480,6 +481,7 @@ cleanup_shared_service_instance (struct SharedServiceInstance *i)
480 GNUNET_free (i); 481 GNUNET_free (i);
481} 482}
482 483
484
483static int 485static int
484start_shared_service_instance (struct SharedServiceInstance *i) 486start_shared_service_instance (struct SharedServiceInstance *i)
485{ 487{
@@ -660,7 +662,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
660 662
661/** 663/**
662 * Release reservation of a TCP or UDP port for a peer 664 * Release reservation of a TCP or UDP port for a peer
663 * (used during GNUNET_TESTING_peer_destroy). 665 * (used during #GNUNET_TESTING_peer_destroy()).
664 * 666 *
665 * @param system system to use for reservation tracking 667 * @param system system to use for reservation tracking
666 * @param port reserved port to release 668 * @param port reserved port to release
@@ -700,7 +702,7 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
700 * @param system the testing system handle 702 * @param system the testing system handle
701 * @param key_number desired pre-created hostkey to obtain 703 * @param key_number desired pre-created hostkey to obtain
702 * @param id set to the peer's identity (hash of the public 704 * @param id set to the peer's identity (hash of the public
703 * key; if NULL, GNUNET_SYSERR is returned immediately 705 * key; if NULL, NULL is returned immediately
704 * @return NULL on error (not enough keys) 706 * @return NULL on error (not enough keys)
705 */ 707 */
706struct GNUNET_CRYPTO_EddsaPrivateKey * 708struct GNUNET_CRYPTO_EddsaPrivateKey *
@@ -715,7 +717,8 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
715 if (key_number >= system->total_hostkeys) 717 if (key_number >= system->total_hostkeys)
716 { 718 {
717 LOG (GNUNET_ERROR_TYPE_ERROR, 719 LOG (GNUNET_ERROR_TYPE_ERROR,
718 _("Key number %u does not exist\n"), key_number); 720 _("Key number %u does not exist\n"),
721 key_number);
719 return NULL; 722 return NULL;
720 } 723 }
721 private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey); 724 private_key = GNUNET_new (struct GNUNET_CRYPTO_EddsaPrivateKey);
@@ -724,7 +727,7 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
724 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 727 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
725 GNUNET_TESTING_HOSTKEYFILESIZE); 728 GNUNET_TESTING_HOSTKEYFILESIZE);
726 GNUNET_CRYPTO_eddsa_key_get_public (private_key, 729 GNUNET_CRYPTO_eddsa_key_get_public (private_key,
727 &id->public_key); 730 &id->public_key);
728 return private_key; 731 return private_key;
729} 732}
730 733
@@ -780,7 +783,9 @@ struct UpdateContext
780 * @param value value of the option 783 * @param value value of the option
781 */ 784 */
782static void 785static void
783update_config (void *cls, const char *section, const char *option, 786update_config (void *cls,
787 const char *section,
788 const char *option,
784 const char *value) 789 const char *value)
785{ 790{
786 struct UpdateContext *uc = cls; 791 struct UpdateContext *uc = cls;
@@ -964,6 +969,7 @@ update_config_sections (void *cls,
964 GNUNET_free (allowed_hosts); 969 GNUNET_free (allowed_hosts);
965} 970}
966 971
972
967static struct SharedServiceInstance * 973static struct SharedServiceInstance *
968associate_shared_service (struct GNUNET_TESTING_System *system, 974associate_shared_service (struct GNUNET_TESTING_System *system,
969 struct SharedService *ss, 975 struct SharedService *ss,
@@ -1095,14 +1101,14 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
1095 * system. The default configuration will be available in PATHS section under 1101 * system. The default configuration will be available in PATHS section under
1096 * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS 1102 * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS
1097 * section to the temporary directory specific to this configuration. If we run 1103 * section to the temporary directory specific to this configuration. If we run
1098 * out of "*port" numbers, return SYSERR. 1104 * out of "*port" numbers, return #GNUNET_SYSERR.
1099 * 1105 *
1100 * This is primarily a helper function used internally 1106 * This is primarily a helper function used internally
1101 * by 'GNUNET_TESTING_peer_configure'. 1107 * by #GNUNET_TESTING_peer_configure().
1102 * 1108 *
1103 * @param system system to use to coordinate resource usage 1109 * @param system system to use to coordinate resource usage
1104 * @param cfg template configuration to update 1110 * @param cfg template configuration to update
1105 * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will 1111 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration will
1106 * be incomplete and should not be used there upon 1112 * be incomplete and should not be used there upon
1107 */ 1113 */
1108int 1114int
@@ -1305,7 +1311,7 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
1305 * Start the peer. 1311 * Start the peer.
1306 * 1312 *
1307 * @param peer peer to start 1313 * @param peer peer to start
1308 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) 1314 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (i.e. peer already running)
1309 */ 1315 */
1310int 1316int
1311GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer) 1317GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
@@ -1357,8 +1363,8 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
1357 * the service 1363 * the service
1358 * @param cont the callback to call with result and status from ARM API 1364 * @param cont the callback to call with result and status from ARM API
1359 * @param cont_cls the closure for the above callback 1365 * @param cont_cls the closure for the above callback
1360 * @return GNUNET_OK upon successfully queuing the service start request; 1366 * @return #GNUNET_OK upon successfully queuing the service start request;
1361 * GNUNET_SYSERR upon error 1367 * #GNUNET_SYSERR upon error
1362 */ 1368 */
1363int 1369int
1364GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer, 1370GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer,
@@ -1387,8 +1393,8 @@ GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer,
1387 * the service 1393 * the service
1388 * @param cont the callback to call with result and status from ARM API 1394 * @param cont the callback to call with result and status from ARM API
1389 * @param cont_cls the closure for the above callback 1395 * @param cont_cls the closure for the above callback
1390 * @return GNUNET_OK upon successfully queuing the service stop request; 1396 * @return #GNUNET_OK upon successfully queuing the service stop request;
1391 * GNUNET_SYSERR upon error 1397 * #GNUNET_SYSERR upon error
1392 */ 1398 */
1393int 1399int
1394GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer, 1400GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
@@ -1411,7 +1417,7 @@ GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
1411 * Sends SIGTERM to the peer's main process 1417 * Sends SIGTERM to the peer's main process
1412 * 1418 *
1413 * @param peer the handle to the peer 1419 * @param peer the handle to the peer
1414 * @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NULL 1420 * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL
1415 * or upon any error while sending SIGTERM 1421 * or upon any error while sending SIGTERM
1416 */ 1422 */
1417int 1423int
@@ -1443,7 +1449,7 @@ GNUNET_TESTING_peer_kill (struct GNUNET_TESTING_Peer *peer)
1443 * Waits for a peer to terminate. The peer's main process will also be destroyed. 1449 * Waits for a peer to terminate. The peer's main process will also be destroyed.
1444 * 1450 *
1445 * @param peer the handle to the peer 1451 * @param peer the handle to the peer
1446 * @return GNUNET_OK if successful; GNUNET_SYSERR if the main process is NULL 1452 * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL
1447 * or upon any error while waiting 1453 * or upon any error while waiting
1448 */ 1454 */
1449int 1455int
@@ -1467,7 +1473,7 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer)
1467 * Stop the peer. 1473 * Stop the peer.
1468 * 1474 *
1469 * @param peer peer to stop 1475 * @param peer peer to stop
1470 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1476 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1471 */ 1477 */
1472int 1478int
1473GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer) 1479GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer)
@@ -1484,8 +1490,8 @@ GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer)
1484 * Function called whenever we connect to or disconnect from ARM. 1490 * Function called whenever we connect to or disconnect from ARM.
1485 * 1491 *
1486 * @param cls closure 1492 * @param cls closure
1487 * @param connected GNUNET_YES if connected, GNUNET_NO if disconnected, 1493 * @param connected #GNUNET_YES if connected, #GNUNET_NO if disconnected,
1488 * GNUNET_SYSERR on error. 1494 * #GNUNET_SYSERR on error.
1489 */ 1495 */
1490static void 1496static void
1491disconn_status (void *cls, 1497disconn_status (void *cls,
@@ -1517,8 +1523,8 @@ disconn_status (void *cls,
1517 * @param peer the peer to stop 1523 * @param peer the peer to stop
1518 * @param cb the callback to signal peer shutdown 1524 * @param cb the callback to signal peer shutdown
1519 * @param cb_cls closure for the above callback 1525 * @param cb_cls closure for the above callback
1520 * @return GNUNET_OK upon successfully giving the request to the ARM API (this 1526 * @return #GNUNET_OK upon successfully giving the request to the ARM API (this
1521 * does not mean that the peer is successfully stopped); GNUNET_SYSERR 1527 * does not mean that the peer is successfully stopped); #GNUNET_SYSERR
1522 * upon any error. 1528 * upon any error.
1523 */ 1529 */
1524int 1530int
@@ -1595,7 +1601,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
1595 * Starts a peer using the given configuration and then invokes the 1601 * Starts a peer using the given configuration and then invokes the
1596 * given callback. This function ALSO initializes the scheduler loop 1602 * given callback. This function ALSO initializes the scheduler loop
1597 * and should thus be called directly from "main". The testcase 1603 * and should thus be called directly from "main". The testcase
1598 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. 1604 * should self-terminate by invoking #GNUNET_SCHEDULER_shutdown().
1599 * 1605 *
1600 * @param testdir only the directory name without any path. This is used for 1606 * @param testdir only the directory name without any path. This is used for
1601 * all service homes; the directory will be created in a temporary 1607 * all service homes; the directory will be created in a temporary
@@ -1603,7 +1609,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
1603 * @param cfgfilename name of the configuration file to use; 1609 * @param cfgfilename name of the configuration file to use;
1604 * use NULL to only run with defaults 1610 * use NULL to only run with defaults
1605 * @param tm main function of the testcase 1611 * @param tm main function of the testcase
1606 * @param tm_cls closure for 'tm' 1612 * @param tm_cls closure for @a tm
1607 * @return 0 on success, 1 on error 1613 * @return 0 on success, 1 on error
1608 */ 1614 */
1609int 1615int
@@ -1666,7 +1672,7 @@ service_run_main (void *cls,
1666 * Starts a service using the given configuration and then invokes the 1672 * Starts a service using the given configuration and then invokes the
1667 * given callback. This function ALSO initializes the scheduler loop 1673 * given callback. This function ALSO initializes the scheduler loop
1668 * and should thus be called directly from "main". The testcase 1674 * and should thus be called directly from "main". The testcase
1669 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. 1675 * should self-terminate by invoking #GNUNET_SCHEDULER_shutdown().
1670 * 1676 *
1671 * This function is useful if the testcase is for a single service 1677 * This function is useful if the testcase is for a single service
1672 * and if that service doesn't itself depend on other services. 1678 * and if that service doesn't itself depend on other services.
@@ -1678,7 +1684,7 @@ service_run_main (void *cls,
1678 * @param cfgfilename name of the configuration file to use; 1684 * @param cfgfilename name of the configuration file to use;
1679 * use NULL to only run with defaults 1685 * use NULL to only run with defaults
1680 * @param tm main function of the testcase 1686 * @param tm main function of the testcase
1681 * @param tm_cls closure for 'tm' 1687 * @param tm_cls closure for @a tm
1682 * @return 0 on success, 1 on error 1688 * @return 0 on success, 1 on error
1683 */ 1689 */
1684int 1690int