aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-12-02 15:38:14 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-12-02 15:38:14 +0900
commitda4625d243cae07a42e543f7e9456a4bd49f1fe3 (patch)
tree74b97feaf764405c22955cd78ed1b2293ac6b04c /src/testing
parent535186257e36201f948cf742d529e6864d264f1c (diff)
downloadgnunet-da4625d243cae07a42e543f7e9456a4bd49f1fe3.tar.gz
gnunet-da4625d243cae07a42e543f7e9456a4bd49f1fe3.zip
-cleanup testing a bit
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.c193
1 files changed, 109 insertions, 84 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index d18197860..968499b22 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -128,7 +128,7 @@ struct GNUNET_TESTING_System
128 */ 128 */
129 struct GNUNET_DISK_MapHandle *map; 129 struct GNUNET_DISK_MapHandle *map;
130 130
131 struct SharedService **shared_services; 131 struct SharedService *shared_services;
132 132
133 unsigned int n_shared_services; 133 unsigned int n_shared_services;
134 134
@@ -380,7 +380,7 @@ GNUNET_TESTING_system_create_with_portrange (
380{ 380{
381 struct GNUNET_TESTING_System *system; 381 struct GNUNET_TESTING_System *system;
382 struct GNUNET_TESTING_SharedService tss; 382 struct GNUNET_TESTING_SharedService tss;
383 struct SharedService *ss; 383 struct SharedService ss;
384 unsigned int cnt; 384 unsigned int cnt;
385 385
386 GNUNET_assert (NULL != testdir); 386 GNUNET_assert (NULL != testdir);
@@ -410,22 +410,22 @@ GNUNET_TESTING_system_create_with_portrange (
410 for (cnt = 0; NULL != shared_services[cnt].service; cnt++) 410 for (cnt = 0; NULL != shared_services[cnt].service; cnt++)
411 { 411 {
412 tss = shared_services[cnt]; 412 tss = shared_services[cnt];
413 ss = GNUNET_new (struct SharedService); 413 memset (&ss, 0, sizeof (ss));
414 ss->sname = GNUNET_strdup (tss.service); 414 ss.sname = GNUNET_strdup (tss.service);
415 ss->cfg = GNUNET_CONFIGURATION_create (); 415 ss.cfg = GNUNET_CONFIGURATION_create ();
416 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 416 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
417 ss->sname, 417 ss.sname,
418 &cfg_copy_iterator, 418 &cfg_copy_iterator,
419 ss->cfg); 419 ss.cfg);
420 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 420 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
421 "TESTING", 421 "TESTING",
422 &cfg_copy_iterator, 422 &cfg_copy_iterator,
423 ss->cfg); 423 ss.cfg);
424 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 424 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
425 "PATHS", 425 "PATHS",
426 &cfg_copy_iterator, 426 &cfg_copy_iterator,
427 ss->cfg); 427 ss.cfg);
428 ss->share = tss.share; 428 ss.share = tss.share;
429 GNUNET_array_append (system->shared_services, 429 GNUNET_array_append (system->shared_services,
430 system->n_shared_services, 430 system->n_shared_services,
431 ss); 431 ss);
@@ -547,7 +547,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
547 hostkeys_unload (system); 547 hostkeys_unload (system);
548 for (ss_cnt = 0; ss_cnt < system->n_shared_services; ss_cnt++) 548 for (ss_cnt = 0; ss_cnt < system->n_shared_services; ss_cnt++)
549 { 549 {
550 ss = system->shared_services[ss_cnt]; 550 ss = &system->shared_services[ss_cnt];
551 for (i_cnt = 0; i_cnt < ss->n_instances; i_cnt++) 551 for (i_cnt = 0; i_cnt < ss->n_instances; i_cnt++)
552 { 552 {
553 i = ss->instances[i_cnt]; 553 i = ss->instances[i_cnt];
@@ -558,7 +558,6 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
558 GNUNET_free (ss->instances); 558 GNUNET_free (ss->instances);
559 GNUNET_CONFIGURATION_destroy (ss->cfg); 559 GNUNET_CONFIGURATION_destroy (ss->cfg);
560 GNUNET_free (ss->sname); 560 GNUNET_free (ss->sname);
561 GNUNET_free (ss);
562 } 561 }
563 GNUNET_free (system->shared_services); 562 GNUNET_free (system->shared_services);
564 if (GNUNET_YES == remove_paths) 563 if (GNUNET_YES == remove_paths)
@@ -1221,7 +1220,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1221 /* Remove sections for shared services */ 1220 /* Remove sections for shared services */
1222 for (cnt = 0; cnt < system->n_shared_services; cnt++) 1221 for (cnt = 0; cnt < system->n_shared_services; cnt++)
1223 { 1222 {
1224 ss = system->shared_services[cnt]; 1223 ss = &system->shared_services[cnt];
1225 GNUNET_CONFIGURATION_remove_section (cfg, ss->sname); 1224 GNUNET_CONFIGURATION_remove_section (cfg, ss->sname);
1226 } 1225 }
1227 if (GNUNET_OK != 1226 if (GNUNET_OK !=
@@ -1269,7 +1268,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1269 * system->n_shared_services); 1268 * system->n_shared_services);
1270 for (cnt = 0; cnt < system->n_shared_services; cnt++) 1269 for (cnt = 0; cnt < system->n_shared_services; cnt++)
1271 { 1270 {
1272 ss = system->shared_services[cnt]; 1271 ss = &system->shared_services[cnt];
1273 ss_instances[cnt] = associate_shared_service (system, ss, cfg); 1272 ss_instances[cnt] = associate_shared_service (system, ss, cfg);
1274 if (NULL == ss_instances[cnt]) 1273 if (NULL == ss_instances[cnt])
1275 { 1274 {
@@ -1736,8 +1735,12 @@ GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
1736} 1735}
1737 1736
1738 1737
1738/**
1739 * FIXME: I'm just janitoring around here. I have no idea what this function
1740 * is supposed todo. Needs documentation.
1741 */
1739static unsigned int 1742static unsigned int
1740get_first_value (char *line) 1743get_first_value (const char *line)
1741{ 1744{
1742 char *copy; 1745 char *copy;
1743 size_t slen; 1746 size_t slen;
@@ -1756,8 +1759,12 @@ get_first_value (char *line)
1756} 1759}
1757 1760
1758 1761
1762/**
1763 * FIXME: I'm just janitoring around here. I have no idea what this function
1764 * is supposed todo. Needs documentation.
1765 */
1759static char * 1766static char *
1760get_key (char *line) 1767get_key (const char *line)
1761{ 1768{
1762 char *copy; 1769 char *copy;
1763 size_t slen; 1770 size_t slen;
@@ -1778,8 +1785,12 @@ get_key (char *line)
1778} 1785}
1779 1786
1780 1787
1788/**
1789 * FIXME: I'm just janitoring around here. I have no idea what this function
1790 * is supposed todo. Needs documentation.
1791 */
1781static char * 1792static char *
1782get_first_string_value (char *line) 1793get_first_string_value (const char *line)
1783{ 1794{
1784 char *copy; 1795 char *copy;
1785 size_t slen, slen_token; 1796 size_t slen, slen_token;
@@ -1803,61 +1814,71 @@ get_first_string_value (char *line)
1803} 1814}
1804 1815
1805 1816
1817/**
1818 * FIXME: I'm just janitoring around here. I have no idea what this function
1819 * is supposed todo. Needs documentation.
1820 */
1806static unsigned int 1821static unsigned int
1807get_second_value (char *line) 1822get_second_value (const char *line)
1808{ 1823{
1809 char *copy; 1824 char *copy;
1810 size_t slen;
1811 char *token; 1825 char *token;
1812 unsigned int ret; 1826 unsigned int ret;
1813 char *rest = NULL; 1827 char *rest = NULL;
1814 1828
1815 slen = strlen (line) + 1; 1829 copy = GNUNET_strdup (line);
1816 copy = malloc (slen);
1817 memcpy (copy, line, slen);
1818 token = strtok_r (copy, ":", &rest); 1830 token = strtok_r (copy, ":", &rest);
1819 token = strtok_r (NULL, ":", &rest); 1831 token = strtok_r (NULL, ":", &rest);
1820 token = strtok_r (NULL, ":", &rest); 1832 token = strtok_r (NULL, ":", &rest);
1833 /* FIXME: ASSERT??? Are we not parsing "user" input here? */
1821 GNUNET_assert (1 == sscanf (token, "%u", &ret)); 1834 GNUNET_assert (1 == sscanf (token, "%u", &ret));
1822 GNUNET_free (copy); 1835 GNUNET_free (copy);
1823 return ret; 1836 return ret;
1824} 1837}
1825 1838
1826 1839
1840/**
1841 * FIXME: I'm just janitoring around here. I have no idea what this function
1842 * is supposed todo. Needs documentation.
1843 */
1827static char * 1844static char *
1828get_value (char *key, char *line) 1845get_value (const char *key, const char *line)
1829{ 1846{
1830 char *copy; 1847 char copy[strlen (line) + 1];
1831 size_t slen, slen_token; 1848 size_t slen;
1832 char *token; 1849 char *token;
1833 char *token2; 1850 char *token2;
1834 char *temp; 1851 char *temp;
1835 char *rest = NULL; 1852 char *rest = NULL;
1836 char *ret;
1837 1853
1838 slen = strlen (line) + 1; 1854 slen = strlen (line) + 1;
1839 copy = malloc (slen);
1840 memcpy (copy, line, slen); 1855 memcpy (copy, line, slen);
1841 temp = strstr (copy, key); 1856 temp = strstr (copy, key);
1842 if (NULL == temp) 1857 if (NULL == temp)
1843 return NULL; 1858 return NULL;
1844 token = strtok_r (temp, ":", &rest); 1859 token = strtok_r (temp, ":", &rest);
1860 if (NULL == token)
1861 return NULL;
1845 token = strtok_r (NULL, ":", &rest); 1862 token = strtok_r (NULL, ":", &rest);
1863 if (NULL == token)
1864 return NULL;
1846 token2 = strtok_r (token, "}", &rest); 1865 token2 = strtok_r (token, "}", &rest);
1847 slen_token = strlen (token2); 1866 if (NULL == token2)
1848 ret = malloc (slen_token + 1); 1867 return NULL;
1849 memcpy (ret, token2, slen_token + 1); 1868 return GNUNET_strdup (token2);
1850 GNUNET_free (copy);
1851 return ret;
1852} 1869}
1853 1870
1854 1871
1872/**
1873 * FIXME: I'm just janitoring around here. I have no idea what this function
1874 * is supposed todo. Needs documentation.
1875 */
1855static struct GNUNET_TESTING_NodeConnection * 1876static struct GNUNET_TESTING_NodeConnection *
1856get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) 1877get_connect_value (const char *line,
1878 struct GNUNET_TESTING_NetjailNode *node)
1857{ 1879{
1858 struct GNUNET_TESTING_NodeConnection *node_connection; 1880 struct GNUNET_TESTING_NodeConnection *node_connection;
1859 char *copy; 1881 char *copy;
1860 size_t slen;
1861 char *token; 1882 char *token;
1862 char *token2; 1883 char *token2;
1863 unsigned int node_n; 1884 unsigned int node_n;
@@ -1870,9 +1891,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1870 node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection); 1891 node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection);
1871 node_connection->node = node; 1892 node_connection->node = node;
1872 1893
1873 slen = strlen (line) + 1; 1894 copy = GNUNET_strdup (line);
1874 copy = malloc (slen);
1875 memcpy (copy, line, slen);
1876 token = strtok_r (copy, ":", &rest); 1895 token = strtok_r (copy, ":", &rest);
1877 if (0 == strcmp ("{K", token)) 1896 if (0 == strcmp ("{K", token))
1878 { 1897 {
@@ -1915,7 +1934,10 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1915 } 1934 }
1916 else 1935 else
1917 { 1936 {
1937 GNUNET_break (0);
1918 GNUNET_free (node_connection); 1938 GNUNET_free (node_connection);
1939 GNUNET_free (copy);
1940 return NULL;
1919 } 1941 }
1920 1942
1921 while (NULL != (token = strtok_r (NULL, ":", &rest))) 1943 while (NULL != (token = strtok_r (NULL, ":", &rest)))
@@ -1923,17 +1945,9 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1923 prefix = GNUNET_new (struct GNUNET_TESTING_AddressPrefix); 1945 prefix = GNUNET_new (struct GNUNET_TESTING_AddressPrefix);
1924 token2 = strtok_r (token, "}", &rest2); 1946 token2 = strtok_r (token, "}", &rest2);
1925 if (NULL != token2) 1947 if (NULL != token2)
1926 { 1948 prefix->address_prefix = GNUNET_strdup (token2);
1927 slen = strlen (token2) + 1;
1928 prefix->address_prefix = malloc (slen);
1929 memcpy (prefix->address_prefix, token2, slen);
1930 }
1931 else 1949 else
1932 { 1950 prefix->address_prefix = GNUNET_strdup (token);
1933 slen = strlen (token) + 1;
1934 prefix->address_prefix = malloc (slen);
1935 memcpy (prefix->address_prefix, token, slen);
1936 }
1937 1951
1938 LOG (GNUNET_ERROR_TYPE_DEBUG, 1952 LOG (GNUNET_ERROR_TYPE_DEBUG,
1939 "address_prefix %s\n", 1953 "address_prefix %s\n",
@@ -1952,13 +1966,16 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1952} 1966}
1953 1967
1954 1968
1969/**
1970 * FIXME: I'm just janitoring around here. I have no idea what this function
1971 * is supposed todo. Needs documentation.
1972 */
1955static void 1973static void
1956node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node) 1974node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node)
1957{ 1975{
1958 char *value, *value2; 1976 char *value, *value2;
1959 char *temp; 1977 char *temp;
1960 char *copy; 1978 char *copy;
1961 size_t slen;
1962 char *rest = NULL; 1979 char *rest = NULL;
1963 char *rest2 = NULL; 1980 char *rest2 = NULL;
1964 struct GNUNET_TESTING_NodeConnection *node_connection; 1981 struct GNUNET_TESTING_NodeConnection *node_connection;
@@ -1967,9 +1984,7 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1967 temp = strstr (line, "connect"); 1984 temp = strstr (line, "connect");
1968 if (NULL != temp) 1985 if (NULL != temp)
1969 { 1986 {
1970 slen = strlen (temp) + 1; 1987 copy = GNUNET_strdup (temp);
1971 copy = GNUNET_malloc (slen);
1972 memcpy (copy, temp, slen);
1973 strtok_r (copy, ":", &rest); 1988 strtok_r (copy, ":", &rest);
1974 value = strtok_r (rest, "|", &rest2); 1989 value = strtok_r (rest, "|", &rest2);
1975 1990
@@ -1979,6 +1994,8 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1979 "node_connections value %s\n", 1994 "node_connections value %s\n",
1980 value); 1995 value);
1981 node_connection = get_connect_value (value, node); 1996 node_connection = get_connect_value (value, node);
1997 if (NULL == node_connection)
1998 break; /* FIXME: continue? */
1982 GNUNET_CONTAINER_DLL_insert (node->node_connections_head, 1999 GNUNET_CONTAINER_DLL_insert (node->node_connections_head,
1983 node->node_connections_tail, 2000 node->node_connections_tail,
1984 node_connection); 2001 node_connection);
@@ -1993,6 +2010,10 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1993} 2010}
1994 2011
1995 2012
2013/**
2014 * FIXME: I'm just janitoring around here. I have no idea what this function
2015 * is supposed todo. Needs documentation.
2016 */
1996static int 2017static int
1997log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) 2018log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
1998{ 2019{
@@ -2041,7 +2062,7 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2041 2062
2042 2063
2043static int 2064static int
2044log_topo (struct GNUNET_TESTING_NetjailTopology *topology) 2065log_topo (const struct GNUNET_TESTING_NetjailTopology *topology)
2045{ 2066{
2046 LOG (GNUNET_ERROR_TYPE_DEBUG, 2067 LOG (GNUNET_ERROR_TYPE_DEBUG,
2047 "plugin: %s spaces: %u nodes: %u known: %u\n", 2068 "plugin: %s spaces: %u nodes: %u known: %u\n",
@@ -2057,15 +2078,18 @@ log_topo (struct GNUNET_TESTING_NetjailTopology *topology)
2057 return GNUNET_YES; 2078 return GNUNET_YES;
2058} 2079}
2059 2080
2060void 2081/**
2082 * FIXME: I'm just janitoring around here. I have no idea what this function
2083 * is supposed todo. Needs documentation.
2084 */
2085static void
2061get_node_info (unsigned int num, 2086get_node_info (unsigned int num,
2062 struct GNUNET_TESTING_NetjailTopology *topology, 2087 const struct GNUNET_TESTING_NetjailTopology *topology,
2063 struct GNUNET_TESTING_NetjailNode **node_ex, 2088 struct GNUNET_TESTING_NetjailNode **node_ex,
2064 struct GNUNET_TESTING_NetjailNamespace **namespace_ex, 2089 struct GNUNET_TESTING_NetjailNamespace **namespace_ex,
2065 struct GNUNET_TESTING_NodeConnection **node_connections_ex) 2090 struct GNUNET_TESTING_NodeConnection **node_connections_ex)
2066{ 2091{
2067 struct GNUNET_ShortHashCode *hkey; 2092 struct GNUNET_ShortHashCode hkey;
2068 struct GNUNET_ShortHashCode *hkey_node;
2069 struct GNUNET_HashCode hc; 2093 struct GNUNET_HashCode hc;
2070 unsigned int namespace_n; 2094 unsigned int namespace_n;
2071 unsigned int node_m; 2095 unsigned int node_m;
@@ -2074,7 +2098,6 @@ get_node_info (unsigned int num,
2074 struct GNUNET_TESTING_NodeConnection *node_connections = NULL; 2098 struct GNUNET_TESTING_NodeConnection *node_connections = NULL;
2075 2099
2076 log_topo (topology); 2100 log_topo (topology);
2077 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2078 LOG (GNUNET_ERROR_TYPE_DEBUG, 2101 LOG (GNUNET_ERROR_TYPE_DEBUG,
2079 "num: %u \n", 2102 "num: %u \n",
2080 num); 2103 num);
@@ -2082,11 +2105,11 @@ get_node_info (unsigned int num,
2082 { 2105 {
2083 2106
2084 GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); 2107 GNUNET_CRYPTO_hash (&num, sizeof(num), &hc);
2085 memcpy (hkey, 2108 memcpy (&hkey,
2086 &hc, 2109 &hc,
2087 sizeof (*hkey)); 2110 sizeof (hkey));
2088 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, 2111 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
2089 hkey); 2112 &hkey);
2090 if (NULL != node) 2113 if (NULL != node)
2091 { 2114 {
2092 *node_ex = node; 2115 *node_ex = node;
@@ -2104,21 +2127,20 @@ get_node_info (unsigned int num,
2104 topology->nodes_m, 2127 topology->nodes_m,
2105 namespace_n); 2128 namespace_n);
2106 GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); 2129 GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc);
2107 memcpy (hkey, 2130 memcpy (&hkey,
2108 &hc, 2131 &hc,
2109 sizeof (*hkey)); 2132 sizeof (hkey));
2110 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, 2133 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
2111 hkey); 2134 &hkey);
2112 if (NULL != namespace) 2135 if (NULL != namespace)
2113 { 2136 {
2114 node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); 2137 node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1);
2115 hkey_node = GNUNET_new (struct GNUNET_ShortHashCode);
2116 GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); 2138 GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc);
2117 memcpy (hkey, 2139 memcpy (&hkey,
2118 &hc, 2140 &hc,
2119 sizeof (*hkey)); 2141 sizeof (hkey));
2120 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, 2142 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
2121 hkey); 2143 &hkey);
2122 if (NULL != node) 2144 if (NULL != node)
2123 { 2145 {
2124 LOG (GNUNET_ERROR_TYPE_DEBUG, 2146 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2130,10 +2152,8 @@ get_node_info (unsigned int num,
2130 *node_ex = node; 2152 *node_ex = node;
2131 *namespace_ex = namespace; 2153 *namespace_ex = namespace;
2132 *node_connections_ex = node_connections; 2154 *node_connections_ex = node_connections;
2133 GNUNET_free (hkey_node);
2134 } 2155 }
2135 } 2156 }
2136 GNUNET_free (hkey);
2137} 2157}
2138 2158
2139 2159
@@ -2146,7 +2166,7 @@ get_node_info (unsigned int num,
2146 */ 2166 */
2147struct GNUNET_TESTING_NodeConnection * 2167struct GNUNET_TESTING_NodeConnection *
2148GNUNET_TESTING_get_connections (unsigned int num, 2168GNUNET_TESTING_get_connections (unsigned int num,
2149 struct GNUNET_TESTING_NetjailTopology *topology) 2169 const struct GNUNET_TESTING_NetjailTopology *topology)
2150{ 2170{
2151 struct GNUNET_TESTING_NetjailNode *node; 2171 struct GNUNET_TESTING_NetjailNode *node;
2152 struct GNUNET_TESTING_NetjailNamespace *namespace; 2172 struct GNUNET_TESTING_NetjailNamespace *namespace;
@@ -2161,13 +2181,14 @@ GNUNET_TESTING_get_connections (unsigned int num,
2161} 2181}
2162 2182
2163 2183
2184/**
2185 * FIXME: Function named incorrectly IMO
2186 */
2164struct GNUNET_PeerIdentity * 2187struct GNUNET_PeerIdentity *
2165GNUNET_TESTING_get_pub_key (unsigned int num, 2188GNUNET_TESTING_get_pub_key (unsigned int num,
2166 const struct GNUNET_TESTING_System *tl_system) 2189 const struct GNUNET_TESTING_System *tl_system)
2167{ 2190{
2168 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); 2191 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
2169 struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
2170 GNUNET_CRYPTO_EddsaPublicKey);
2171 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key; 2192 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key;
2172 2193
2173 priv_key = GNUNET_TESTING_hostkey_get (tl_system, 2194 priv_key = GNUNET_TESTING_hostkey_get (tl_system,
@@ -2175,10 +2196,8 @@ GNUNET_TESTING_get_pub_key (unsigned int num,
2175 peer); 2196 peer);
2176 2197
2177 GNUNET_CRYPTO_eddsa_key_get_public (priv_key, 2198 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
2178 pub_key); 2199 &peer->public_key);
2179 peer->public_key = *pub_key;
2180 GNUNET_free (priv_key); 2200 GNUNET_free (priv_key);
2181 GNUNET_free (pub_key);
2182 return peer; 2201 return peer;
2183} 2202}
2184 2203
@@ -2278,7 +2297,7 @@ GNUNET_TESTING_calculate_num (
2278 */ 2297 */
2279char * 2298char *
2280GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, 2299GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
2281 char *prefix) 2300 const char *prefix)
2282{ 2301{
2283 struct GNUNET_TESTING_NetjailNode *node; 2302 struct GNUNET_TESTING_NetjailNode *node;
2284 char *addr; 2303 char *addr;
@@ -2353,6 +2372,12 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
2353 2372
2354 get_node_info (num, topology, &node, &namespace, &node_connections); 2373 get_node_info (num, topology, &node, &namespace, &node_connections);
2355 2374
2375 if (NULL == node)
2376 {
2377 LOG (GNUNET_ERROR_TYPE_WARNING,
2378 "No info found for node %d\n", num);
2379 return 0;
2380 }
2356 LOG (GNUNET_ERROR_TYPE_DEBUG, 2381 LOG (GNUNET_ERROR_TYPE_DEBUG,
2357 "node additional_connects for node %p\n", 2382 "node additional_connects for node %p\n",
2358 node); 2383 node);
@@ -2380,7 +2405,7 @@ GNUNET_TESTING_send_local_test_finished_msg ()
2380 2405
2381 2406
2382static void 2407static void
2383parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) 2408parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token)
2384{ 2409{
2385 char *ac_value; 2410 char *ac_value;
2386 int ret; 2411 int ret;
@@ -2417,7 +2442,7 @@ parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token)
2417 * @return The GNUNET_TESTING_NetjailTopology 2442 * @return The GNUNET_TESTING_NetjailTopology
2418 */ 2443 */
2419struct GNUNET_TESTING_NetjailTopology * 2444struct GNUNET_TESTING_NetjailTopology *
2420GNUNET_TESTING_get_topo_from_string (char *data) 2445GNUNET_TESTING_get_topo_from_string (const char *input)
2421{ 2446{
2422 char *token; 2447 char *token;
2423 char *key = NULL; 2448 char *key = NULL;
@@ -2425,12 +2450,14 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2425 char *rest = NULL; 2450 char *rest = NULL;
2426 char *value = NULL; 2451 char *value = NULL;
2427 char *value2; 2452 char *value2;
2453 char *data;
2428 int ret; 2454 int ret;
2429 struct GNUNET_TESTING_NetjailTopology *topo; 2455 struct GNUNET_TESTING_NetjailTopology *topo;
2430 struct GNUNET_TESTING_NetjailRouter *router; 2456 struct GNUNET_TESTING_NetjailRouter *router;
2431 struct GNUNET_TESTING_NetjailNamespace *namespace; 2457 struct GNUNET_TESTING_NetjailNamespace *namespace;
2432 struct GNUNET_HashCode hc; 2458 struct GNUNET_HashCode hc;
2433 2459
2460 data = GNUNET_strdup (input);
2434 token = strtok_r (data, "\n", &rest); 2461 token = strtok_r (data, "\n", &rest);
2435 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); 2462 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
2436 topo->map_namespaces = 2463 topo->map_namespaces =
@@ -2441,7 +2468,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2441 while (NULL != token) 2468 while (NULL != token)
2442 { 2469 {
2443 if (NULL != key) 2470 if (NULL != key)
2444 free (key); 2471 GNUNET_free (key);
2445 key = get_key (token); 2472 key = get_key (token);
2446 LOG (GNUNET_ERROR_TYPE_DEBUG, 2473 LOG (GNUNET_ERROR_TYPE_DEBUG,
2447 "In the loop with token: %s beginning with %s\n", 2474 "In the loop with token: %s beginning with %s\n",
@@ -2656,10 +2683,8 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2656 LOG (GNUNET_ERROR_TYPE_DEBUG, 2683 LOG (GNUNET_ERROR_TYPE_DEBUG,
2657 "plugin: %s\n", 2684 "plugin: %s\n",
2658 value); 2685 value);
2659 p_node->plugin = GNUNET_malloc (sizeof(*value)); 2686 p_node->plugin = value;
2660 memcpy (p_node->plugin, value, sizeof (*value));
2661 } 2687 }
2662 GNUNET_free (value);
2663 p_node->node_n = out; 2688 p_node->node_n = out;
2664 p_node->namespace_n = namespace->namespace_n; 2689 p_node->namespace_n = namespace->namespace_n;
2665 } 2690 }
@@ -2676,7 +2701,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2676 } 2701 }
2677 if (NULL != key) 2702 if (NULL != key)
2678 GNUNET_free (key); 2703 GNUNET_free (key);
2679 2704 GNUNET_free (data);
2680 return topo; 2705 return topo;
2681} 2706}
2682 2707