diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_testing_lib-new.h | 4 | ||||
-rw-r--r-- | src/peerinfo-tool/test_gnunet_peerinfo_data.conf | 3 | ||||
-rw-r--r-- | src/testing/Makefile.am | 12 | ||||
-rw-r--r-- | src/testing/gnunet-testing-run-service.c | 6 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c (renamed from src/testing_old/gnunet-testing.c) | 74 | ||||
-rw-r--r-- | src/testing/testing.c | 19 | ||||
-rw-r--r-- | src/testing_old/Makefile.am | 11 |
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, | |||
102 | * @param key_number desired pre-created hostkey to obtain | 102 | * @param key_number desired pre-created hostkey to obtain |
103 | * @param id set to the peer's identity (hash of the public | 103 | * @param id set to the peer's identity (hash of the public |
104 | * key; if NULL, GNUNET_SYSERR is returned immediately | 104 | * key; if NULL, GNUNET_SYSERR is returned immediately |
105 | * @return GNUNET_SYSERR on error (not enough keys) | 105 | * @return NULL on error (not enough keys) |
106 | */ | 106 | */ |
107 | int | 107 | struct GNUNET_CRYPTO_RsaPrivateKey * |
108 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | 108 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, |
109 | uint32_t key_number, | 109 | uint32_t key_number, |
110 | struct GNUNET_PeerIdentity *id); | 110 | 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 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/gnunet-test-peerinfo/ | 2 | SERVICEHOME = /tmp/gnunet-test-peerinfo/ |
3 | 3 | ||
4 | [gnunetd] | ||
5 | #HOSTKEY = test_gnunet_peerinfo.hostkey | ||
6 | |||
4 | [peerinfo] | 7 | [peerinfo] |
5 | PORT = 24354 | 8 | PORT = 24354 |
6 | 9 | ||
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 = \ | |||
27 | -version-info 0:1:0 | 27 | -version-info 0:1:0 |
28 | 28 | ||
29 | bin_PROGRAMS = \ | 29 | bin_PROGRAMS = \ |
30 | gnunet-testing-run-service | 30 | gnunet-testing-run-service \ |
31 | gnunet-testing | ||
31 | 32 | ||
32 | 33 | ||
33 | gnunet_testing_run_service_SOURCES = \ | 34 | gnunet_testing_run_service_SOURCES = \ |
@@ -40,6 +41,15 @@ gnunet_testing_run_service_LDADD = \ | |||
40 | gnunet_testing_run_service_DEPENDENCIES = \ | 41 | gnunet_testing_run_service_DEPENDENCIES = \ |
41 | libgnunettesting.la | 42 | libgnunettesting.la |
42 | 43 | ||
44 | gnunet_testing_SOURCES = \ | ||
45 | gnunet-testing.c | ||
46 | gnunet_testing_LDADD = \ | ||
47 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
48 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
49 | $(GN_LIBINTL) | ||
50 | gnunet_testing_DEPENDENCIES = \ | ||
51 | libgnunettesting.la | ||
52 | |||
43 | 53 | ||
44 | check_PROGRAMS = \ | 54 | check_PROGRAMS = \ |
45 | test_testing_portreservation \ | 55 | 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 @@ | |||
34 | * This executable is intended to be used by gnunet-java, in order to reliably | 34 | * This executable is intended to be used by gnunet-java, in order to reliably |
35 | * start and stop services for test cases. | 35 | * start and stop services for test cases. |
36 | */ | 36 | */ |
37 | |||
38 | #include "platform.h" | 37 | #include "platform.h" |
39 | #include "gnunet_getopt_lib.h" | ||
40 | #include "gnunet_program_lib.h" | ||
41 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
42 | #include "gnunet_signal_lib.h" | ||
43 | #include "gnunet_testing_lib-new.h" | 39 | #include "gnunet_testing_lib-new.h" |
44 | #include "gnunet_os_lib.h" | ||
45 | |||
46 | 40 | ||
47 | #define LOG(kind,...) \ | 41 | #define LOG(kind,...) \ |
48 | GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__) | 42 | 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 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_getopt_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_program_lib.h" | 28 | #include "gnunet_testing_lib-new.h" |
29 | #include "gnunet_testing_lib.h" | ||
30 | 29 | ||
31 | #define HOSTKEYFILESIZE 914 | 30 | #define HOSTKEYFILESIZE 914 |
32 | 31 | ||
@@ -45,28 +44,23 @@ static char * create_cfg_template; | |||
45 | 44 | ||
46 | static char * create_hostkey_file; | 45 | static char * create_hostkey_file; |
47 | 46 | ||
47 | |||
48 | static int | 48 | static int |
49 | create_unique_cfgs (const char * template, const unsigned int no) | 49 | create_unique_cfgs (const char * template, const unsigned int no) |
50 | { | 50 | { |
51 | int fail = GNUNET_NO; | 51 | struct GNUNET_TESTING_System *system; |
52 | 52 | int fail; | |
53 | uint16_t port = 20000; | 53 | unsigned int cur; |
54 | uint32_t upnum = 1; | 54 | char *cur_file; |
55 | uint32_t fdnum = 1; | 55 | struct GNUNET_CONFIGURATION_Handle *cfg_new; |
56 | struct GNUNET_CONFIGURATION_Handle *cfg_tmpl; | ||
56 | 57 | ||
57 | if (GNUNET_NO == GNUNET_DISK_file_test(template)) | 58 | if (GNUNET_NO == GNUNET_DISK_file_test(template)) |
58 | { | 59 | { |
59 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template); | 60 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template); |
60 | return 1; | 61 | return 1; |
61 | } | 62 | } |
62 | 63 | cfg_tmpl = GNUNET_CONFIGURATION_create(); | |
63 | int cur = 0; | ||
64 | char * cur_file; | ||
65 | char *service_home = NULL; | ||
66 | char *cur_service_home = NULL; | ||
67 | |||
68 | struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL; | ||
69 | struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create(); | ||
70 | 64 | ||
71 | /* load template */ | 65 | /* load template */ |
72 | if ((create_cfg_template != NULL) && (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template))) | 66 | 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) | |||
77 | return 1; | 71 | return 1; |
78 | } | 72 | } |
79 | /* load defaults */ | 73 | /* load defaults */ |
80 | else if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, NULL)) | 74 | if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, NULL)) |
81 | { | 75 | { |
82 | GNUNET_break (0); | 76 | GNUNET_break (0); |
83 | return 1; | 77 | return 1; |
84 | } | 78 | } |
85 | 79 | ||
86 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg_tmpl, "PATHS", "SERVICEHOME", &service_home)) | 80 | fail = GNUNET_NO; |
87 | { | 81 | system = GNUNET_TESTING_system_create ("testing", NULL /* controller */); |
88 | GNUNET_asprintf(&service_home, "%s", "/tmp/testing"); | 82 | for (cur = 0; cur < no; cur++) |
89 | } | ||
90 | else | ||
91 | { | ||
92 | int s = strlen (service_home); | ||
93 | if (service_home[s-1] == DIR_SEPARATOR) | ||
94 | service_home[s-1] = '\0'; | ||
95 | } | ||
96 | |||
97 | while (cur < no) | ||
98 | { | 83 | { |
99 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); | 84 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); |
100 | if (create_cfg_template != NULL) | 85 | if (create_cfg_template != NULL) |
@@ -102,36 +87,35 @@ create_unique_cfgs (const char * template, const unsigned int no) | |||
102 | else | 87 | else |
103 | GNUNET_asprintf (&cur_file,"%04u%s",cur, ".conf"); | 88 | GNUNET_asprintf (&cur_file,"%04u%s",cur, ".conf"); |
104 | 89 | ||
105 | 90 | cfg_new = GNUNET_CONFIGURATION_dup (cfg_tmpl); | |
106 | GNUNET_asprintf (&cur_service_home, "%s-%04u%c",service_home, cur, DIR_SEPARATOR); | 91 | if (GNUNET_OK != |
107 | GNUNET_CONFIGURATION_set_value_string (cfg_tmpl,"PATHS","SERVICEHOME", cur_service_home); | 92 | GNUNET_TESTING_configuration_create (system, cfg_new)) |
108 | GNUNET_CONFIGURATION_set_value_string (cfg_tmpl,"PATHS","DEFAULTCONFIG", cur_file); | 93 | { |
109 | GNUNET_free (cur_service_home); | 94 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not create another configuration\n"); |
110 | 95 | GNUNET_CONFIGURATION_destroy (cfg_new); | |
111 | cfg_new = GNUNET_TESTING_create_cfg(cfg_tmpl, cur, &port, &upnum, NULL, &fdnum); | 96 | fail = GNUNET_YES; |
112 | 97 | break; | |
113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing configuration no. %u to file `%s' \n", cur, cur_file); | 98 | } |
99 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
100 | "Writing configuration no. %u to file `%s' \n", cur, cur_file); | ||
114 | if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file)) | 101 | if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file)) |
115 | { | 102 | { |
116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur); | 103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur); |
117 | fail = GNUNET_YES; | 104 | fail = GNUNET_YES; |
118 | } | 105 | } |
119 | |||
120 | GNUNET_CONFIGURATION_destroy (cfg_new); | 106 | GNUNET_CONFIGURATION_destroy (cfg_new); |
121 | GNUNET_free (cur_file); | 107 | GNUNET_free (cur_file); |
122 | if (fail == GNUNET_YES) | 108 | if (fail == GNUNET_YES) |
123 | break; | 109 | break; |
124 | cur ++; | ||
125 | } | 110 | } |
126 | |||
127 | GNUNET_CONFIGURATION_destroy(cfg_tmpl); | 111 | GNUNET_CONFIGURATION_destroy(cfg_tmpl); |
128 | GNUNET_free (service_home); | 112 | GNUNET_TESTING_system_destroy (system, GNUNET_NO); |
129 | if (fail == GNUNET_NO) | 113 | if (GNUNET_YES == fail) |
130 | return 0; | ||
131 | else | ||
132 | return 1; | 114 | return 1; |
115 | return 0; | ||
133 | } | 116 | } |
134 | 117 | ||
118 | |||
135 | static int | 119 | static int |
136 | create_hostkeys (const unsigned int no) | 120 | create_hostkeys (const unsigned int no) |
137 | { | 121 | { |
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) | |||
441 | * @param key_number desired pre-created hostkey to obtain | 441 | * @param key_number desired pre-created hostkey to obtain |
442 | * @param id set to the peer's identity (hash of the public | 442 | * @param id set to the peer's identity (hash of the public |
443 | * key; if NULL, GNUNET_SYSERR is returned immediately | 443 | * key; if NULL, GNUNET_SYSERR is returned immediately |
444 | * @return GNUNET_SYSERR on error (not enough keys) | 444 | * @return NULL on error (not enough keys) |
445 | */ | 445 | */ |
446 | int | 446 | struct GNUNET_CRYPTO_RsaPrivateKey * |
447 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | 447 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, |
448 | uint32_t key_number, | 448 | uint32_t key_number, |
449 | struct GNUNET_PeerIdentity *id) | 449 | struct GNUNET_PeerIdentity *id) |
@@ -452,12 +452,12 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | |||
452 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 452 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
453 | 453 | ||
454 | if ((NULL == id) || (NULL == system->hostkeys_data)) | 454 | if ((NULL == id) || (NULL == system->hostkeys_data)) |
455 | return GNUNET_SYSERR; | 455 | return NULL; |
456 | if (key_number >= system->total_hostkeys) | 456 | if (key_number >= system->total_hostkeys) |
457 | { | 457 | { |
458 | LOG (GNUNET_ERROR_TYPE_ERROR, | 458 | LOG (GNUNET_ERROR_TYPE_ERROR, |
459 | _("Key number %u does not exist\n"), key_number); | 459 | _("Key number %u does not exist\n"), key_number); |
460 | return GNUNET_SYSERR; | 460 | return NULL; |
461 | } | 461 | } |
462 | private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + | 462 | private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + |
463 | (key_number * HOSTKEYFILESIZE), | 463 | (key_number * HOSTKEYFILESIZE), |
@@ -466,14 +466,13 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | |||
466 | { | 466 | { |
467 | LOG (GNUNET_ERROR_TYPE_ERROR, | 467 | LOG (GNUNET_ERROR_TYPE_ERROR, |
468 | _("Error while decoding key %u\n"), key_number); | 468 | _("Error while decoding key %u\n"), key_number); |
469 | return GNUNET_SYSERR; | 469 | return NULL; |
470 | } | 470 | } |
471 | GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); | 471 | GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); |
472 | GNUNET_CRYPTO_hash (&public_key, | 472 | GNUNET_CRYPTO_hash (&public_key, |
473 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 473 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
474 | &(id->hashPubKey)); | 474 | &(id->hashPubKey)); |
475 | GNUNET_CRYPTO_rsa_key_free (private_key); | 475 | return private_key; |
476 | return GNUNET_OK; | ||
477 | } | 476 | } |
478 | 477 | ||
479 | 478 | ||
@@ -698,6 +697,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
698 | char hostkey_filename[128]; | 697 | char hostkey_filename[128]; |
699 | char *config_filename; | 698 | char *config_filename; |
700 | char *emsg_; | 699 | char *emsg_; |
700 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | ||
701 | 701 | ||
702 | if (NULL != emsg) | 702 | if (NULL != emsg) |
703 | *emsg = NULL; | 703 | *emsg = NULL; |
@@ -724,8 +724,9 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
724 | GNUNET_free (emsg_); | 724 | GNUNET_free (emsg_); |
725 | return NULL; | 725 | return NULL; |
726 | } | 726 | } |
727 | pk = NULL; | ||
727 | if ((NULL != id) && | 728 | if ((NULL != id) && |
728 | (GNUNET_SYSERR == GNUNET_TESTING_hostkey_get (system, key_number, id))) | 729 | (NULL == (pk = GNUNET_TESTING_hostkey_get (system, key_number, id)))) |
729 | { | 730 | { |
730 | GNUNET_asprintf (&emsg_, | 731 | GNUNET_asprintf (&emsg_, |
731 | _("Failed to initialize hostkey for peer %u\n"), | 732 | _("Failed to initialize hostkey for peer %u\n"), |
@@ -737,6 +738,8 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
737 | GNUNET_free (emsg_); | 738 | GNUNET_free (emsg_); |
738 | return NULL; | 739 | return NULL; |
739 | } | 740 | } |
741 | if (NULL != pk) | ||
742 | GNUNET_CRYPTO_rsa_key_free (pk); | ||
740 | GNUNET_assert (GNUNET_OK == | 743 | GNUNET_assert (GNUNET_OK == |
741 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", | 744 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", |
742 | "SERVICEHOME", | 745 | "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 = \ | |||
54 | -version-info 0:1:0 | 54 | -version-info 0:1:0 |
55 | 55 | ||
56 | 56 | ||
57 | bin_PROGRAMS = \ | ||
58 | gnunet-testing | ||
59 | |||
60 | check_PROGRAMS = \ | 57 | check_PROGRAMS = \ |
61 | test_testing \ | 58 | test_testing \ |
62 | test_testing_connect \ | 59 | test_testing_connect \ |
@@ -91,14 +88,6 @@ TESTS = \ | |||
91 | test_testing_peergroup | 88 | test_testing_peergroup |
92 | endif | 89 | endif |
93 | 90 | ||
94 | gnunet_testing_SOURCES = \ | ||
95 | gnunet-testing.c | ||
96 | gnunet_testing_LDADD = \ | ||
97 | $(top_builddir)/src/testing_old/libgnunettesting_old.la \ | ||
98 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
99 | $(GN_LIBINTL) | ||
100 | gnunet_testing_DEPENDENCIES = \ | ||
101 | libgnunettesting_old.la | ||
102 | 91 | ||
103 | 92 | ||
104 | test_testing_SOURCES = \ | 93 | test_testing_SOURCES = \ |