aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------contrib/gana0
m---------contrib/sphinx0
-rw-r--r--src/datacache/perf_datacache.c2
-rw-r--r--src/datacache/test_datacache.c2
-rw-r--r--src/datacache/test_datacache_quota.c2
-rw-r--r--src/datastore/perf_datastore_api.c2
-rw-r--r--src/datastore/perf_plugin_datastore.c2
-rw-r--r--src/datastore/test_datastore_api.c2
-rw-r--r--src/datastore/test_datastore_api_management.c2
-rw-r--r--src/datastore/test_plugin_datastore.c2
-rw-r--r--src/include/gnunet_strings_lib.h21
-rw-r--r--src/include/gnunet_testing_lib.h17
-rw-r--r--src/namecache/test_plugin_namecache.c2
-rw-r--r--src/namestore/test_common.c4
-rw-r--r--src/namestore/test_plugin_namestore.c2
-rw-r--r--src/peerstore/test_plugin_peerstore.c2
-rw-r--r--src/testing/testing.c37
-rw-r--r--src/transport/test_communicator_basic.c2
-rw-r--r--src/util/strings.c47
19 files changed, 78 insertions, 72 deletions
diff --git a/contrib/gana b/contrib/gana
Subproject 917f93ec912881e7e24d433a5b8fea05d140cd6 Subproject c1dc2dc975742c929a523c22d91f7d4f8278723
diff --git a/contrib/sphinx b/contrib/sphinx
Subproject c70e3876678be75d0d3c481aeeac42870d266da Subproject 9c5b9d9040d21542eff792e26624cf9669b127a
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 84bc4a852..adbb958cc 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -160,7 +160,7 @@ main (int argc, char *argv[])
160 GNUNET_log_setup ("perf-datacache", 160 GNUNET_log_setup ("perf-datacache",
161 "WARNING", 161 "WARNING",
162 NULL); 162 NULL);
163 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 163 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
164 GNUNET_snprintf (cfg_name, sizeof(cfg_name), "perf_datacache_data_%s.conf", 164 GNUNET_snprintf (cfg_name, sizeof(cfg_name), "perf_datacache_data_%s.conf",
165 plugin_name); 165 plugin_name);
166 GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv, 166 GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv,
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index 5392f6b17..a97a3f33c 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -182,7 +182,7 @@ main (int argc, char *argv[])
182 GNUNET_log_setup ("test-datacache", 182 GNUNET_log_setup ("test-datacache",
183 "WARNING", 183 "WARNING",
184 NULL); 184 NULL);
185 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 185 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
186 GNUNET_snprintf (cfg_name, 186 GNUNET_snprintf (cfg_name,
187 sizeof(cfg_name), 187 sizeof(cfg_name),
188 "test_datacache_data_%s.conf", 188 "test_datacache_data_%s.conf",
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c
index 0ad7fb8a4..2cdff8083 100644
--- a/src/datacache/test_datacache_quota.c
+++ b/src/datacache/test_datacache_quota.c
@@ -170,7 +170,7 @@ main (int argc,
170 "WARNING", 170 "WARNING",
171 NULL); 171 NULL);
172 172
173 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 173 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
174 GNUNET_snprintf (cfg_name, 174 GNUNET_snprintf (cfg_name,
175 sizeof(cfg_name), 175 sizeof(cfg_name),
176 "test_datacache_data_%s.conf", 176 "test_datacache_data_%s.conf",
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index fef38891e..f7d9fa544 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -610,7 +610,7 @@ main (int argc,
610{ 610{
611 char cfg_name[PATH_MAX]; 611 char cfg_name[PATH_MAX];
612 612
613 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 613 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
614 GNUNET_snprintf (cfg_name, 614 GNUNET_snprintf (cfg_name,
615 sizeof(cfg_name), 615 sizeof(cfg_name),
616 "test_datastore_api_data_%s.conf", 616 "test_datastore_api_data_%s.conf",
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index d7488d4e7..8e63b08e6 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -550,7 +550,7 @@ main (int argc, char *argv[])
550 GNUNET_GETOPT_OPTION_END 550 GNUNET_GETOPT_OPTION_END
551 }; 551 };
552 552
553 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 553 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
554 GNUNET_snprintf (dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s", 554 GNUNET_snprintf (dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s",
555 plugin_name); 555 plugin_name);
556 GNUNET_DISK_directory_remove (dir_name); 556 GNUNET_DISK_directory_remove (dir_name);
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index e72a6acd3..58a6b7a28 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -710,7 +710,7 @@ main (int argc,
710 char cfg_name[PATH_MAX]; 710 char cfg_name[PATH_MAX];
711 int ret; 711 int ret;
712 712
713 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 713 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
714 GNUNET_snprintf (cfg_name, 714 GNUNET_snprintf (cfg_name,
715 sizeof(cfg_name), 715 sizeof(cfg_name),
716 "test_datastore_api_data_%s.conf", 716 "test_datastore_api_data_%s.conf",
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 175765267..b9b134fbc 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -387,7 +387,7 @@ main (int argc, char *argv[])
387 char cfg_name[PATH_MAX]; 387 char cfg_name[PATH_MAX];
388 int ret; 388 int ret;
389 389
390 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 390 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
391 GNUNET_snprintf (cfg_name, 391 GNUNET_snprintf (cfg_name,
392 sizeof(cfg_name), 392 sizeof(cfg_name),
393 "test_datastore_api_data_%s.conf", 393 "test_datastore_api_data_%s.conf",
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c
index 9fe2462e7..7de1acf2d 100644
--- a/src/datastore/test_plugin_datastore.c
+++ b/src/datastore/test_plugin_datastore.c
@@ -457,7 +457,7 @@ main (int argc, char *argv[])
457 }; 457 };
458 458
459 /* determine name of plugin to use */ 459 /* determine name of plugin to use */
460 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 460 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
461 GNUNET_snprintf (dir_name, sizeof(dir_name), 461 GNUNET_snprintf (dir_name, sizeof(dir_name),
462 "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); 462 "/tmp/test-gnunet-datastore-plugin-%s", plugin_name);
463 GNUNET_DISK_directory_remove (dir_name); 463 GNUNET_DISK_directory_remove (dir_name);
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index b751ef044..be41fb1d9 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -18,7 +18,7 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 21#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly." 22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif 23#endif
24 24
@@ -41,7 +41,7 @@
41 * @{ 41 * @{
42 */ 42 */
43 43
44#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__) 44#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
45#error "Only <gnunet_util_lib.h> can be included directly." 45#error "Only <gnunet_util_lib.h> can be included directly."
46#endif 46#endif
47 47
@@ -670,6 +670,23 @@ GNUNET_strlcpy (char *dst,
670 size_t n); 670 size_t n);
671 671
672 672
673/**
674 * Sometimes we use the binary name to determine which specific
675 * test to run. In those cases, the string after the last "_"
676 * in 'argv[0]' specifies a string that determines the configuration
677 * file or plugin to use.
678 *
679 * This function returns the respective substring, taking care
680 * of issues such as binaries ending in '.exe' on W32.
681 *
682 * @param argv0 the name of the binary
683 * @return string between the last '_' and the '.exe' (or the end of the string),
684 * NULL if argv0 has no '_'
685 */
686char *
687GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0);
688
689
673/* ***************** IPv4/IPv6 parsing ****************** */ 690/* ***************** IPv4/IPv6 parsing ****************** */
674 691
675struct GNUNET_STRINGS_PortPolicy 692struct GNUNET_STRINGS_PortPolicy
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index cd9d88822..0d74de8c2 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -449,23 +449,6 @@ GNUNET_TESTING_service_run (const char *testdir,
449 void *tm_cls); 449 void *tm_cls);
450 450
451 451
452/**
453 * Sometimes we use the binary name to determine which specific
454 * test to run. In those cases, the string after the last "_"
455 * in 'argv[0]' specifies a string that determines the configuration
456 * file or plugin to use.
457 *
458 * This function returns the respective substring, taking care
459 * of issues such as binaries ending in '.exe' on W32.
460 *
461 * @param argv0 the name of the binary
462 * @return string between the last '_' and the '.exe' (or the end of the string),
463 * NULL if argv0 has no '_'
464 */
465char *
466GNUNET_TESTING_get_testname_from_underscore (const char *argv0);
467
468
469#if 0 /* keep Emacsens' auto-indent happy */ 452#if 0 /* keep Emacsens' auto-indent happy */
470{ 453{
471#endif 454#endif
diff --git a/src/namecache/test_plugin_namecache.c b/src/namecache/test_plugin_namecache.c
index 242b3503b..141698a23 100644
--- a/src/namecache/test_plugin_namecache.c
+++ b/src/namecache/test_plugin_namecache.c
@@ -113,7 +113,7 @@ main (int argc, char *argv[])
113 GNUNET_GETOPT_OPTION_END 113 GNUNET_GETOPT_OPTION_END
114 }; 114 };
115 115
116 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 116 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
117 GNUNET_snprintf (cfg_name, sizeof(cfg_name), "test_plugin_namecache_%s.conf", 117 GNUNET_snprintf (cfg_name, sizeof(cfg_name), "test_plugin_namecache_%s.conf",
118 plugin_name); 118 plugin_name);
119 119
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c
index 60749a0b1..4df24a7f7 100644
--- a/src/namestore/test_common.c
+++ b/src/namestore/test_common.c
@@ -98,7 +98,7 @@ TNC_test_plugin (const char *cfg_name)
98 do \ 98 do \
99 { \ 99 { \
100 GNUNET_log_setup (__FILE__, "WARNING", NULL); \ 100 GNUNET_log_setup (__FILE__, "WARNING", NULL); \
101 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ 101 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); \
102 GNUNET_asprintf (&cfg_name, file_template, plugin_name); \ 102 GNUNET_asprintf (&cfg_name, file_template, plugin_name); \
103 if (! TNC_test_plugin (cfg_name)) \ 103 if (! TNC_test_plugin (cfg_name)) \
104 { \ 104 { \
@@ -116,7 +116,7 @@ TNC_test_plugin (const char *cfg_name)
116 do \ 116 do \
117 { \ 117 { \
118 GNUNET_log_setup (__FILE__, "WARNING", NULL); \ 118 GNUNET_log_setup (__FILE__, "WARNING", NULL); \
119 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ 119 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); \
120 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \ 120 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \
121 if (! TNC_test_plugin (cfg_name)) \ 121 if (! TNC_test_plugin (cfg_name)) \
122 { \ 122 { \
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index b89cc95d0..d82a3d349 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -195,7 +195,7 @@ main (int argc, char *argv[])
195 { GNUNET_GETOPT_OPTION_END }; 195 { GNUNET_GETOPT_OPTION_END };
196 196
197 GNUNET_log_setup ("test-plugin-namestore", "WARNING", NULL); 197 GNUNET_log_setup ("test-plugin-namestore", "WARNING", NULL);
198 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 198 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
199 GNUNET_snprintf (cfg_name, 199 GNUNET_snprintf (cfg_name,
200 sizeof(cfg_name), 200 sizeof(cfg_name),
201 "test_plugin_namestore_%s.conf", 201 "test_plugin_namestore_%s.conf",
diff --git a/src/peerstore/test_plugin_peerstore.c b/src/peerstore/test_plugin_peerstore.c
index a4221ea63..bce62dda9 100644
--- a/src/peerstore/test_plugin_peerstore.c
+++ b/src/peerstore/test_plugin_peerstore.c
@@ -201,7 +201,7 @@ main (int argc, char *argv[])
201 GNUNET_log_setup ("test-plugin-peerstore", 201 GNUNET_log_setup ("test-plugin-peerstore",
202 "WARNING", 202 "WARNING",
203 NULL); 203 NULL);
204 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 204 plugin_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
205 GNUNET_snprintf (cfg_name, 205 GNUNET_snprintf (cfg_name,
206 sizeof(cfg_name), 206 sizeof(cfg_name),
207 "test_plugin_peerstore_%s.conf", 207 "test_plugin_peerstore_%s.conf",
diff --git a/src/testing/testing.c b/src/testing/testing.c
index e360d7083..fdfa80d87 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -272,7 +272,7 @@ struct GNUNET_TESTING_Peer
272 * @param system the testing system handle 272 * @param system the testing system handle
273 * @return #GNUNET_OK on success; #GNUNET_SYSERR on error 273 * @return #GNUNET_OK on success; #GNUNET_SYSERR on error
274 */ 274 */
275static int 275static enum GNUNET_GenericReturnValue
276hostkeys_load (struct GNUNET_TESTING_System *system) 276hostkeys_load (struct GNUNET_TESTING_System *system)
277{ 277{
278 uint64_t fs; 278 uint64_t fs;
@@ -505,7 +505,7 @@ cleanup_shared_service_instance (struct SharedServiceInstance *i)
505} 505}
506 506
507 507
508static int 508static enum GNUNET_GenericReturnValue
509start_shared_service_instance (struct SharedServiceInstance *i) 509start_shared_service_instance (struct SharedServiceInstance *i)
510{ 510{
511 char *binary; 511 char *binary;
@@ -1722,39 +1722,6 @@ GNUNET_TESTING_service_run (const char *testdir,
1722 1722
1723 1723
1724/** 1724/**
1725 * Sometimes we use the binary name to determine which specific
1726 * test to run. In those cases, the string after the last "_"
1727 * in 'argv[0]' specifies a string that determines the configuration
1728 * file or plugin to use.
1729 *
1730 * This function returns the respective substring, taking care
1731 * of issues such as binaries ending in '.exe' on W32.
1732 *
1733 * @param argv0 the name of the binary
1734 * @return string between the last '_' and the '.exe' (or the end of the string),
1735 * NULL if argv0 has no '_'
1736 */
1737char *
1738GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
1739{
1740 size_t slen = strlen (argv0) + 1;
1741 char sbuf[slen];
1742 char *ret;
1743 char *dot;
1744
1745 GNUNET_memcpy (sbuf, argv0, slen);
1746 ret = strrchr (sbuf, '_');
1747 if (NULL == ret)
1748 return NULL;
1749 ret++; /* skip underscore */
1750 dot = strchr (ret, '.');
1751 if (NULL != dot)
1752 *dot = '\0';
1753 return GNUNET_strdup (ret);
1754}
1755
1756
1757/**
1758 * Every line in the topology configuration starts with a string indicating which 1725 * Every line in the topology configuration starts with a string indicating which
1759 * kind of information will be configured with this line. Configuration values following 1726 * kind of information will be configured with this line. Configuration values following
1760 * this string are seperated by special sequences of characters. An integer value seperated 1727 * this string are seperated by special sequences of characters. An integer value seperated
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 713275fd3..fdbad0957 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -1095,7 +1095,7 @@ main (int argc,
1095 phase[0] = TP_INIT; 1095 phase[0] = TP_INIT;
1096 phase[1] = TP_INIT; 1096 phase[1] = TP_INIT;
1097 ret = 1; 1097 ret = 1;
1098 test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 1098 test_name = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
1099 communicator_name = strchr (test_name, '-'); 1099 communicator_name = strchr (test_name, '-');
1100 communicator_name[0] = '\0'; 1100 communicator_name[0] = '\0';
1101 communicator_name++; 1101 communicator_name++;
diff --git a/src/util/strings.c b/src/util/strings.c
index 479c0fcd6..86323bc83 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1859,11 +1859,18 @@ GNUNET_STRINGS_urlencode (const char *data,
1859 if (0 == (0x80 & *i8)) 1859 if (0 == (0x80 & *i8))
1860 { 1860 {
1861 /* traditional ASCII */ 1861 /* traditional ASCII */
1862 if (isalnum (*i8) || (*i8 == '-') || (*i8 == '_') || (*i8 == '.') || 1862 if ( isalnum (*i8) ||
1863 (*i8 == '~') ) 1863 (*i8 == '-') ||
1864 GNUNET_buffer_write (&buf, (const char*) i8, 1); 1864 (*i8 == '_') ||
1865 (*i8 == '.') ||
1866 (*i8 == '~') )
1867 GNUNET_buffer_write (&buf,
1868 (const char*) i8,
1869 1);
1865 else if (*i8 == ' ') 1870 else if (*i8 == ' ')
1866 GNUNET_buffer_write (&buf, "+", 1); 1871 GNUNET_buffer_write (&buf,
1872 "+",
1873 1);
1867 else 1874 else
1868 GNUNET_buffer_write_fstr (&buf, 1875 GNUNET_buffer_write_fstr (&buf,
1869 "%%%X%X", 1876 "%%%X%X",
@@ -1952,4 +1959,36 @@ GNUNET_STRINGS_urlencode (const char *data,
1952} 1959}
1953 1960
1954 1961
1962/**
1963 * Sometimes we use the binary name to determine which specific
1964 * test to run. In those cases, the string after the last "_"
1965 * in 'argv[0]' specifies a string that determines the configuration
1966 * file or plugin to use.
1967 *
1968 * This function returns the respective substring, taking care
1969 * of issues such as binaries ending in '.exe' on W32.
1970 *
1971 * @param argv0 the name of the binary
1972 * @return string between the last '_' and the '.exe' (or the end of the string),
1973 * NULL if argv0 has no '_'
1974 */
1975char *
1976GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0)
1977{
1978 const char *ret;
1979 const char *dot;
1980
1981 ret = strrchr (argv0, '_');
1982 if (NULL == ret)
1983 return NULL;
1984 ret++; /* skip underscore */
1985 dot = strchr (ret,
1986 '.');
1987 if (NULL != dot)
1988 return GNUNET_strndup (ret,
1989 dot - ret);
1990 return GNUNET_strdup (ret);
1991}
1992
1993
1955/* end of strings.c */ 1994/* end of strings.c */