X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftesting%2Fgnunet-testing.c;h=ba864e3f0d6032a280d8385c39c68d2a863f3eb6;hb=747234f53f8c184b2a347e0f064c39161a5a09b9;hp=a84c512a72cf83c8519989a82f640f08a0a1aa8b;hpb=6df0871923df44be6602b115088b1c292ddac3be;p=oweals%2Fgnunet.git diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index a84c512a7..ba864e3f0 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c @@ -19,7 +19,7 @@ */ /** - * @file testing_old/gnunet-testing.c + * @file testing/gnunet-testing.c * @brief tool to use testing functionality from cmd line * @author Christian Grothoff */ @@ -27,8 +27,8 @@ #include "gnunet_util_lib.h" #include "gnunet_testing_lib-new.h" -#define HOSTKEYFILESIZE 914 +#define HOSTKEYFILESIZE 914 /** * Final status code. @@ -77,7 +77,7 @@ create_unique_cfgs (const char * template, const unsigned int no) } fail = GNUNET_NO; - system = GNUNET_TESTING_system_create ("testing", NULL /* controller */); + system = GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL); for (cur = 0; cur < no; cur++) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); @@ -122,21 +122,32 @@ create_hostkeys (const unsigned int no) struct GNUNET_PeerIdentity id; struct GNUNET_DISK_FileHandle *fd; struct GNUNET_CRYPTO_RsaPrivateKey *pk; + struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; - system = GNUNET_TESTING_system_create ("testing", NULL); + system = GNUNET_TESTING_system_create ("testing", NULL, NULL); pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); + if (NULL == pk) + { + fprintf (stderr, _("Could not extract hostkey %u (offset too large?)\n"), create_no); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + (void) GNUNET_DISK_directory_create_for_file (create_hostkey); fd = GNUNET_DISK_file_open (create_hostkey, GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); GNUNET_assert (fd != NULL); + pkb = GNUNET_CRYPTO_rsa_encode_key (pk); GNUNET_assert (HOSTKEYFILESIZE == - GNUNET_DISK_file_write (fd, pk, HOSTKEYFILESIZE)); + GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len))); GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", "Wrote hostkey to file: `%s'\n", create_hostkey); + GNUNET_free (pkb); GNUNET_CRYPTO_rsa_key_free (pk); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); return 0; } @@ -198,14 +209,15 @@ main (int argc, char *const *argv) GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template}, GNUNET_GETOPT_OPTION_END }; - if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) return 2; - return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, argv, "gnunet-testing", - gettext_noop ("Command line tool to access the testing library"), options, &run, - NULL)) ? ret : 1; + ret = (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, "gnunet-testing", + gettext_noop ("Command line tool to access the testing library"), options, &run, + NULL)) ? ret : 1; + GNUNET_free ((void*) argv); + return ret; } /* end of gnunet-testing.c */