summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_testing_lib-new.h4
-rw-r--r--src/peerinfo-tool/test_gnunet_peerinfo_data.conf3
-rw-r--r--src/testing/Makefile.am12
-rw-r--r--src/testing/gnunet-testing-run-service.c6
-rw-r--r--src/testing/gnunet-testing.c (renamed from src/testing_old/gnunet-testing.c)74
-rw-r--r--src/testing/testing.c19
-rw-r--r--src/testing_old/Makefile.am11
7 files changed, 56 insertions, 73 deletions
diff --git a/src/include/gnunet_testing_lib-new.h b/src/include/gnunet_testing_lib-new.h
index fb51d2fb7..31bc2234a 100644
--- a/src/include/gnunet_testing_lib-new.h
+++ b/src/include/gnunet_testing_lib-new.h
@@ -102,9 +102,9 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
* @param key_number desired pre-created hostkey to obtain
* @param id set to the peer's identity (hash of the public
* key; if NULL, GNUNET_SYSERR is returned immediately
- * @return GNUNET_SYSERR on error (not enough keys)
+ * @return NULL on error (not enough keys)
*/
-int
+struct GNUNET_CRYPTO_RsaPrivateKey *
GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
uint32_t key_number,
struct GNUNET_PeerIdentity *id);
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo_data.conf b/src/peerinfo-tool/test_gnunet_peerinfo_data.conf
index 90da74fbf..843dc983a 100644
--- a/src/peerinfo-tool/test_gnunet_peerinfo_data.conf
+++ b/src/peerinfo-tool/test_gnunet_peerinfo_data.conf
@@ -1,6 +1,9 @@
[PATHS]
SERVICEHOME = /tmp/gnunet-test-peerinfo/
+[gnunetd]
+#HOSTKEY = test_gnunet_peerinfo.hostkey
+
[peerinfo]
PORT = 24354
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 670b1d2e0..f680ad669 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -27,7 +27,8 @@ libgnunettesting_la_LDFLAGS = \
-version-info 0:1:0
bin_PROGRAMS = \
- gnunet-testing-run-service
+ gnunet-testing-run-service \
+ gnunet-testing
gnunet_testing_run_service_SOURCES = \
@@ -40,6 +41,15 @@ gnunet_testing_run_service_LDADD = \
gnunet_testing_run_service_DEPENDENCIES = \
libgnunettesting.la
+gnunet_testing_SOURCES = \
+ gnunet-testing.c
+gnunet_testing_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+gnunet_testing_DEPENDENCIES = \
+ libgnunettesting.la
+
check_PROGRAMS = \
test_testing_portreservation \
diff --git a/src/testing/gnunet-testing-run-service.c b/src/testing/gnunet-testing-run-service.c
index 38351d75e..72415e606 100644
--- a/src/testing/gnunet-testing-run-service.c
+++ b/src/testing/gnunet-testing-run-service.c
@@ -34,15 +34,9 @@
* This executable is intended to be used by gnunet-java, in order to reliably
* start and stop services for test cases.
*/
-
#include "platform.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_program_lib.h"
#include "gnunet_util_lib.h"
-#include "gnunet_signal_lib.h"
#include "gnunet_testing_lib-new.h"
-#include "gnunet_os_lib.h"
-
#define LOG(kind,...) \
GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__)
diff --git a/src/testing_old/gnunet-testing.c b/src/testing/gnunet-testing.c
index 3b0c83b6b..b7e115761 100644
--- a/src/testing_old/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -24,9 +24,8 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_testing_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_lib-new.h"
#define HOSTKEYFILESIZE 914
@@ -45,28 +44,23 @@ static char * create_cfg_template;
static char * create_hostkey_file;
+
static int
create_unique_cfgs (const char * template, const unsigned int no)
{
- int fail = GNUNET_NO;
-
- uint16_t port = 20000;
- uint32_t upnum = 1;
- uint32_t fdnum = 1;
+ struct GNUNET_TESTING_System *system;
+ int fail;
+ unsigned int cur;
+ char *cur_file;
+ struct GNUNET_CONFIGURATION_Handle *cfg_new;
+ struct GNUNET_CONFIGURATION_Handle *cfg_tmpl;
if (GNUNET_NO == GNUNET_DISK_file_test(template))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template);
return 1;
}
-
- int cur = 0;
- char * cur_file;
- char *service_home = NULL;
- char *cur_service_home = NULL;
-
- struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL;
- struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create();
+ cfg_tmpl = GNUNET_CONFIGURATION_create();
/* load template */
if ((create_cfg_template != NULL) && (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template)))
@@ -77,24 +71,15 @@ create_unique_cfgs (const char * template, const unsigned int no)
return 1;
}
/* load defaults */
- else if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, NULL))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, NULL))
{
GNUNET_break (0);
return 1;
}
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg_tmpl, "PATHS", "SERVICEHOME", &service_home))
- {
- GNUNET_asprintf(&service_home, "%s", "/tmp/testing");
- }
- else
- {
- int s = strlen (service_home);
- if (service_home[s-1] == DIR_SEPARATOR)
- service_home[s-1] = '\0';
- }
-
- while (cur < no)
+ fail = GNUNET_NO;
+ system = GNUNET_TESTING_system_create ("testing", NULL /* controller */);
+ for (cur = 0; cur < no; cur++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur);
if (create_cfg_template != NULL)
@@ -102,36 +87,35 @@ create_unique_cfgs (const char * template, const unsigned int no)
else
GNUNET_asprintf (&cur_file,"%04u%s",cur, ".conf");
-
- GNUNET_asprintf (&cur_service_home, "%s-%04u%c",service_home, cur, DIR_SEPARATOR);
- GNUNET_CONFIGURATION_set_value_string (cfg_tmpl,"PATHS","SERVICEHOME", cur_service_home);
- GNUNET_CONFIGURATION_set_value_string (cfg_tmpl,"PATHS","DEFAULTCONFIG", cur_file);
- GNUNET_free (cur_service_home);
-
- cfg_new = GNUNET_TESTING_create_cfg(cfg_tmpl, cur, &port, &upnum, NULL, &fdnum);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing configuration no. %u to file `%s' \n", cur, cur_file);
+ cfg_new = GNUNET_CONFIGURATION_dup (cfg_tmpl);
+ if (GNUNET_OK !=
+ GNUNET_TESTING_configuration_create (system, cfg_new))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not create another configuration\n");
+ GNUNET_CONFIGURATION_destroy (cfg_new);
+ fail = GNUNET_YES;
+ break;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Writing configuration no. %u to file `%s' \n", cur, cur_file);
if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur);
fail = GNUNET_YES;
}
-
GNUNET_CONFIGURATION_destroy (cfg_new);
GNUNET_free (cur_file);
if (fail == GNUNET_YES)
break;
- cur ++;
}
-
GNUNET_CONFIGURATION_destroy(cfg_tmpl);
- GNUNET_free (service_home);
- if (fail == GNUNET_NO)
- return 0;
- else
+ GNUNET_TESTING_system_destroy (system, GNUNET_NO);
+ if (GNUNET_YES == fail)
return 1;
+ return 0;
}
+
static int
create_hostkeys (const unsigned int no)
{
diff --git a/src/testing/testing.c b/src/testing/testing.c
index fca969b19..369bd4e51 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -441,9 +441,9 @@ reserve_path (struct GNUNET_TESTING_System *system)
* @param key_number desired pre-created hostkey to obtain
* @param id set to the peer's identity (hash of the public
* key; if NULL, GNUNET_SYSERR is returned immediately
- * @return GNUNET_SYSERR on error (not enough keys)
+ * @return NULL on error (not enough keys)
*/
-int
+struct GNUNET_CRYPTO_RsaPrivateKey *
GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
uint32_t key_number,
struct GNUNET_PeerIdentity *id)
@@ -452,12 +452,12 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
if ((NULL == id) || (NULL == system->hostkeys_data))
- return GNUNET_SYSERR;
+ return NULL;
if (key_number >= system->total_hostkeys)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Key number %u does not exist\n"), key_number);
- return GNUNET_SYSERR;
+ return NULL;
}
private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data +
(key_number * HOSTKEYFILESIZE),
@@ -466,14 +466,13 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Error while decoding key %u\n"), key_number);
- return GNUNET_SYSERR;
+ return NULL;
}
GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key);
GNUNET_CRYPTO_hash (&public_key,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&(id->hashPubKey));
- GNUNET_CRYPTO_rsa_key_free (private_key);
- return GNUNET_OK;
+ return private_key;
}
@@ -698,6 +697,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
char hostkey_filename[128];
char *config_filename;
char *emsg_;
+ struct GNUNET_CRYPTO_RsaPrivateKey *pk;
if (NULL != emsg)
*emsg = NULL;
@@ -724,8 +724,9 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
GNUNET_free (emsg_);
return NULL;
}
+ pk = NULL;
if ((NULL != id) &&
- (GNUNET_SYSERR == GNUNET_TESTING_hostkey_get (system, key_number, id)))
+ (NULL == (pk = GNUNET_TESTING_hostkey_get (system, key_number, id))))
{
GNUNET_asprintf (&emsg_,
_("Failed to initialize hostkey for peer %u\n"),
@@ -737,6 +738,8 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
GNUNET_free (emsg_);
return NULL;
}
+ if (NULL != pk)
+ GNUNET_CRYPTO_rsa_key_free (pk);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
"SERVICEHOME",
diff --git a/src/testing_old/Makefile.am b/src/testing_old/Makefile.am
index fa4cf7394..7a7f19364 100644
--- a/src/testing_old/Makefile.am
+++ b/src/testing_old/Makefile.am
@@ -54,9 +54,6 @@ libgnunettesting_old_la_LDFLAGS = \
-version-info 0:1:0
-bin_PROGRAMS = \
- gnunet-testing
-
check_PROGRAMS = \
test_testing \
test_testing_connect \
@@ -91,14 +88,6 @@ TESTS = \
test_testing_peergroup
endif
-gnunet_testing_SOURCES = \
- gnunet-testing.c
-gnunet_testing_LDADD = \
- $(top_builddir)/src/testing_old/libgnunettesting_old.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL)
-gnunet_testing_DEPENDENCIES = \
- libgnunettesting_old.la
test_testing_SOURCES = \