aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-15 13:59:23 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-15 13:59:23 +0000
commitc592e22bd5c98416b81c66ccd0abb79ccb82540a (patch)
tree6d78ff4f5ded94f1037944fecbdaf1945d5cf5b3
parent46e7fe13591a6232f7680d048e8a79de21fdd3a7 (diff)
downloadgnunet-c592e22bd5c98416b81c66ccd0abb79ccb82540a.tar.gz
gnunet-c592e22bd5c98416b81c66ccd0abb79ccb82540a.zip
prefix support for testing
-rw-r--r--src/testing/testing.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index ce6af991c..7151cbd09 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -159,6 +159,7 @@ struct GNUNET_TESTING_Peer
159 * necessary). 159 * necessary).
160 */ 160 */
161 char *main_binary; 161 char *main_binary;
162 char *args;
162 163
163 /** 164 /**
164 * Handle to the running binary of the service, NULL if the 165 * Handle to the running binary of the service, NULL if the
@@ -837,6 +838,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
837 char *service_home; 838 char *service_home;
838 char hostkey_filename[128]; 839 char hostkey_filename[128];
839 char *config_filename; 840 char *config_filename;
841 char *libexec_binary;
840 char *emsg_; 842 char *emsg_;
841 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 843 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
842 844
@@ -935,9 +937,21 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
935 } 937 }
936 peer = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Peer)); 938 peer = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Peer));
937 peer->cfgfile = config_filename; /* Free in peer_destroy */ 939 peer->cfgfile = config_filename; /* Free in peer_destroy */
938 peer->main_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); 940
941 libexec_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
942 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "arm", "PREFIX", &peer->main_binary))
943 {
944 /* No prefix */
945 GNUNET_asprintf(&peer->main_binary, "%s", libexec_binary);
946 peer->args = strdup ("");
947 }
948 else
949 peer->args = strdup (libexec_binary);
950
939 peer->system = system; 951 peer->system = system;
940 peer->key_number = key_number; 952 peer->key_number = key_number;
953
954 GNUNET_free (libexec_binary);
941 return peer; 955 return peer;
942} 956}
943 957
@@ -976,6 +990,7 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
976 peer->main_process = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, 990 peer->main_process = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL,
977 peer->main_binary, 991 peer->main_binary,
978 peer->main_binary, 992 peer->main_binary,
993 peer->args,
979 "-c", 994 "-c",
980 peer->cfgfile, 995 peer->cfgfile,
981 NULL); 996 NULL);
@@ -1069,6 +1084,7 @@ GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer)
1069 } 1084 }
1070 GNUNET_free (peer->cfgfile); 1085 GNUNET_free (peer->cfgfile);
1071 GNUNET_free (peer->main_binary); 1086 GNUNET_free (peer->main_binary);
1087 GNUNET_free (peer->args);
1072 GNUNET_free (peer); 1088 GNUNET_free (peer);
1073} 1089}
1074 1090
@@ -1176,6 +1192,7 @@ GNUNET_TESTING_service_run (const char *testdir,
1176 struct GNUNET_TESTING_Peer *peer; 1192 struct GNUNET_TESTING_Peer *peer;
1177 struct GNUNET_CONFIGURATION_Handle *cfg; 1193 struct GNUNET_CONFIGURATION_Handle *cfg;
1178 char *binary; 1194 char *binary;
1195 char *libexec_binary;
1179 1196
1180 GNUNET_log_setup (testdir, "WARNING", NULL); 1197 GNUNET_log_setup (testdir, "WARNING", NULL);
1181 system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL); 1198 system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL);
@@ -1199,8 +1216,19 @@ GNUNET_TESTING_service_run (const char *testdir,
1199 return 1; 1216 return 1;
1200 } 1217 }
1201 GNUNET_free (peer->main_binary); 1218 GNUNET_free (peer->main_binary);
1219
1202 GNUNET_asprintf (&binary, "gnunet-service-%s", service_name); 1220 GNUNET_asprintf (&binary, "gnunet-service-%s", service_name);
1203 peer->main_binary = GNUNET_OS_get_libexec_binary_path (binary); 1221 libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
1222 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, service_name, "PREFIX", &peer->main_binary))
1223 {
1224 /* No prefix */
1225 GNUNET_asprintf(&peer->main_binary, "%s", libexec_binary);
1226 peer->args = strdup ("");
1227 }
1228 else
1229 peer->args = strdup (libexec_binary);
1230
1231 GNUNET_free (libexec_binary);
1204 GNUNET_free (binary); 1232 GNUNET_free (binary);
1205 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer)) 1233 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer))
1206 { 1234 {