summaryrefslogtreecommitdiff
path: root/src/testing/testing.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-10 11:38:46 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-10 11:38:46 +0000
commit8efaae301b29ec7cbdb921ac5e6b30ae2c143568 (patch)
tree44b8417ebe93dac752f5611bfd5bede01b65c700 /src/testing/testing.c
parent5d2bfbd4a69f87c99083fc60954c884af69258f4 (diff)
downloadgnunet-8efaae301b29ec7cbdb921ac5e6b30ae2c143568.tar.gz
gnunet-8efaae301b29ec7cbdb921ac5e6b30ae2c143568.zip
-adding helper function to determine plugin names to testing
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r--src/testing/testing.c40
1 files changed, 39 insertions, 1 deletions
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 */