aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testing_lib-new.h21
-rw-r--r--src/testing/testing.c40
2 files changed, 58 insertions, 3 deletions
diff --git a/src/include/gnunet_testing_lib-new.h b/src/include/gnunet_testing_lib-new.h
index b88cd9e98..9bd6c3b25 100644
--- a/src/include/gnunet_testing_lib-new.h
+++ b/src/include/gnunet_testing_lib-new.h
@@ -73,7 +73,6 @@ GNUNET_TESTING_system_create (const char *tmppath,
73 const char *controller); 73 const char *controller);
74 74
75 75
76
77/** 76/**
78 * Free system resources. 77 * Free system resources.
79 * 78 *
@@ -225,6 +224,7 @@ typedef void (*GNUNET_TESTING_TestMain)(void *cls,
225 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. 224 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'.
226 * 225 *
227 * @param tmppath path for storing temporary data for the test 226 * @param tmppath path for storing temporary data for the test
227 * also used to setup the program name for logging
228 * @param cfgfilename name of the configuration file to use; 228 * @param cfgfilename name of the configuration file to use;
229 * use NULL to only run with defaults 229 * use NULL to only run with defaults
230 * @param tm main function of the testcase 230 * @param tm main function of the testcase
@@ -238,7 +238,6 @@ GNUNET_TESTING_peer_run (const char *tmppath,
238 void *tm_cls); 238 void *tm_cls);
239 239
240 240
241
242/** 241/**
243 * Start a single service (no ARM, except of course if the given 242 * Start a single service (no ARM, except of course if the given
244 * service name is 'arm') and run a test using the testing library. 243 * service name is 'arm') and run a test using the testing library.
@@ -251,6 +250,7 @@ GNUNET_TESTING_peer_run (const char *tmppath,
251 * and if that service doesn't itself depend on other services. 250 * and if that service doesn't itself depend on other services.
252 * 251 *
253 * @param tmppath path for storing temporary data for the test 252 * @param tmppath path for storing temporary data for the test
253 * also used to setup the program name for logging
254 * @param service_name name of the service to run 254 * @param service_name name of the service to run
255 * @param cfgfilename name of the configuration file to use; 255 * @param cfgfilename name of the configuration file to use;
256 * use NULL to only run with defaults 256 * use NULL to only run with defaults
@@ -267,6 +267,23 @@ GNUNET_TESTING_service_run (const char *tmppath,
267 267
268 268
269 269
270/**
271 * Sometimes we use the binary name to determine which specific
272 * test to run. In those cases, the string after the last "_"
273 * in 'argv[0]' specifies a string that determines the configuration
274 * file or plugin to use.
275 *
276 * This function returns the respective substring, taking care
277 * of issues such as binaries ending in '.exe' on W32.
278 *
279 * @param argv0 the name of the binary
280 * @return string between the last '_' and the '.exe' (or the end of the string),
281 * NULL if argv0 has no '_'
282 */
283char *
284GNUNET_TESTING_get_testname_from_underscore (const char *argv0);
285
286
270#if 0 /* keep Emacsens' auto-indent happy */ 287#if 0 /* keep Emacsens' auto-indent happy */
271{ 288{
272#endif 289#endif
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 68d1f1f39..39d7b717d 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -877,6 +877,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
877 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. 877 * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'.
878 * 878 *
879 * @param tmppath path for storing temporary data for the test 879 * @param tmppath path for storing temporary data for the test
880 * also used to setup the program name for logging
880 * @param cfgfilename name of the configuration file to use; 881 * @param cfgfilename name of the configuration file to use;
881 * use NULL to only run with defaults 882 * use NULL to only run with defaults
882 * @param tm main function of the testcase 883 * @param tm main function of the testcase
@@ -943,7 +944,8 @@ service_run_main (void *cls,
943 * This function is useful if the testcase is for a single service 944 * This function is useful if the testcase is for a single service
944 * and if that service doesn't itself depend on other services. 945 * and if that service doesn't itself depend on other services.
945 * 946 *
946 * @param tmppath path for storing temporary data for the test 947 * @param tmppath path for storing temporary data for the test,
948 * also used to setup the program name for logging
947 * @param service_name name of the service to run 949 * @param service_name name of the service to run
948 * @param cfgfilename name of the configuration file to use; 950 * @param cfgfilename name of the configuration file to use;
949 * use NULL to only run with defaults 951 * use NULL to only run with defaults
@@ -963,6 +965,9 @@ GNUNET_TESTING_service_run (const char *tmppath,
963 struct GNUNET_TESTING_Peer *peer; 965 struct GNUNET_TESTING_Peer *peer;
964 struct GNUNET_CONFIGURATION_Handle *cfg; 966 struct GNUNET_CONFIGURATION_Handle *cfg;
965 967
968 GNUNET_log_setup (tmppath,
969 "WARNING",
970 NULL);
966 system = GNUNET_TESTING_system_create (tmppath, "127.0.0.1"); 971 system = GNUNET_TESTING_system_create (tmppath, "127.0.0.1");
967 if (NULL == system) 972 if (NULL == system)
968 return 1; 973 return 1;
@@ -1010,4 +1015,37 @@ GNUNET_TESTING_service_run (const char *tmppath,
1010} 1015}
1011 1016
1012 1017
1018/**
1019 * Sometimes we use the binary name to determine which specific
1020 * test to run. In those cases, the string after the last "_"
1021 * in 'argv[0]' specifies a string that determines the configuration
1022 * file or plugin to use.
1023 *
1024 * This function returns the respective substring, taking care
1025 * of issues such as binaries ending in '.exe' on W32.
1026 *
1027 * @param argv0 the name of the binary
1028 * @return string between the last '_' and the '.exe' (or the end of the string),
1029 * NULL if argv0 has no '_'
1030 */
1031char *
1032GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
1033{
1034 size_t slen = strlen (argv0) + 1;
1035 char sbuf[slen];
1036 char *ret;
1037 char *dot;
1038
1039 memcpy (sbuf, argv0, slen);
1040 ret = strrchr (sbuf, '_');
1041 if (NULL == ret)
1042 return NULL;
1043 ret++; /* skip underscore */
1044 dot = strchr (ret, '.');
1045 if (NULL != dot)
1046 *dot = '\0';
1047 return GNUNET_strdup (ret);
1048}
1049
1050
1013/* end of testing.c */ 1051/* end of testing.c */