aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_plugin_transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_plugin_transport.c')
-rw-r--r--src/transport/test_plugin_transport.c99
1 files changed, 60 insertions, 39 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index 1d92588ea..85ab9659d 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -1,21 +1,19 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009 GNUnet e.V. 3 Copyright (C) 2009, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */ 17 */
20/** 18/**
21 * @file transport/test_plugin_transport.c 19 * @file transport/test_plugin_transport.c
@@ -566,8 +564,10 @@ handle_helper_message (void *cls,
566 * @param c configuration to use 564 * @param c configuration to use
567 */ 565 */
568static void 566static void
569run (void *cls, char * const *args, const char *cfgfile, 567run (void *cls,
570 const struct GNUNET_CONFIGURATION_Handle *c) 568 char * const *args,
569 const char *cfgfile,
570 const struct GNUNET_CONFIGURATION_Handle *c)
571{ 571{
572 char * const *argv = cls; 572 char * const *argv = cls;
573 unsigned long long tneigh; 573 unsigned long long tneigh;
@@ -575,26 +575,32 @@ run (void *cls, char * const *args, const char *cfgfile,
575 char *plugin; 575 char *plugin;
576 char *sep; 576 char *sep;
577 577
578 timeout_endbadly = GNUNET_SCHEDULER_add_delayed (TIMEOUT, end_badly, &ok); 578 timeout_endbadly = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
579 579 &end_badly,
580 &ok);
580 cfg = c; 581 cfg = c;
581 /* parse configuration */ 582 /* parse configuration */
582 if ((GNUNET_OK 583 if ( (GNUNET_OK !=
583 != GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", 584 GNUNET_CONFIGURATION_get_value_number (c,
584 "NEIGHBOUR_LIMIT", &tneigh)) 585 "TRANSPORT",
585 || (GNUNET_OK 586 "NEIGHBOUR_LIMIT",
586 != GNUNET_CONFIGURATION_get_value_filename (c, "PEER", "PRIVATE_KEY", 587 &tneigh)) ||
587 &keyfile))) 588 (GNUNET_OK !=
589 GNUNET_CONFIGURATION_get_value_filename (c,
590 "PEER",
591 "PRIVATE_KEY",
592 &keyfile)))
588 { 593 {
589 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 594 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
590 "Transport service is lacking key configuration settings. Exiting.\n"); 595 "Transport service is lacking key configuration settings. Exiting.\n");
591 return; 596 return;
592 } 597 }
593 598
594 if (NULL == (stats = GNUNET_STATISTICS_create ("transport", cfg))) 599 if (NULL == (stats = GNUNET_STATISTICS_create ("transport",
600 cfg)))
595 { 601 {
596 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 602 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
597 "Could not create statistics. Exiting.\n"); 603 "Could not create statistics. Exiting.\n");
598 GNUNET_free(keyfile); 604 GNUNET_free(keyfile);
599 end_badly_now (); 605 end_badly_now ();
600 return; 606 return;
@@ -602,27 +608,33 @@ run (void *cls, char * const *args, const char *cfgfile,
602 608
603 if (GNUNET_OK != GNUNET_DISK_file_test (HOSTKEY_FILE)) 609 if (GNUNET_OK != GNUNET_DISK_file_test (HOSTKEY_FILE))
604 { 610 {
605 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Hostkey `%s' missing. Exiting.\n", 611 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
606 HOSTKEY_FILE); 612 "Hostkey `%s' missing. Exiting.\n",
613 HOSTKEY_FILE);
607 GNUNET_free(keyfile); 614 GNUNET_free(keyfile);
608 end_badly_now (); 615 end_badly_now ();
609 return; 616 return;
610 } 617 }
611 618
612 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (keyfile)) 619 if (GNUNET_OK !=
620 GNUNET_DISK_directory_create_for_file (keyfile))
613 { 621 {
614 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 622 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
615 "Could not create a directory for hostkey `%s'. Exiting.\n", keyfile); 623 "Could not create a directory for hostkey `%s'. Exiting.\n",
624 keyfile);
616 GNUNET_free(keyfile); 625 GNUNET_free(keyfile);
617 end_badly_now (); 626 end_badly_now ();
618 return; 627 return;
619 } 628 }
620 629
621 if (GNUNET_OK != GNUNET_DISK_file_copy (HOSTKEY_FILE, keyfile)) 630 if (GNUNET_OK !=
631 GNUNET_DISK_file_copy (HOSTKEY_FILE,
632 keyfile))
622 { 633 {
623 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 634 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
624 "Could not copy hostkey `%s' to destination `%s'. Exiting.\n", 635 "Could not copy hostkey `%s' to destination `%s'. Exiting.\n",
625 HOSTKEY_FILE, keyfile); 636 HOSTKEY_FILE,
637 keyfile);
626 GNUNET_free(keyfile); 638 GNUNET_free(keyfile);
627 end_badly_now (); 639 end_badly_now ();
628 return; 640 return;
@@ -730,9 +742,9 @@ run (void *cls, char * const *args, const char *cfgfile,
730 end_badly_now (); 742 end_badly_now ();
731 return; 743 return;
732 } 744 }
733
734} 745}
735 746
747
736/** 748/**
737 * The main function for the test 749 * The main function for the test
738 * 750 *
@@ -741,23 +753,32 @@ run (void *cls, char * const *args, const char *cfgfile,
741 * @return 0 ok, 1 on error 753 * @return 0 ok, 1 on error
742 */ 754 */
743int 755int
744main (int argc, char * const *argv) 756main (int argc,
757 char * const *argv)
745{ 758{
746 static struct GNUNET_GETOPT_CommandLineOption options[] = { 759 static struct GNUNET_GETOPT_CommandLineOption options[] = {
747 GNUNET_GETOPT_OPTION_END }; 760 GNUNET_GETOPT_OPTION_END
761 };
748 int ret; 762 int ret;
749 763 char * const argv_prog[] = {
750 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); 764 "test_plugin_transport",
751 765 "-c",
752 char * const argv_prog[] = { "test_plugin_transport", "-c", 766 "test_plugin_transport_data.conf",
753 "test_plugin_transport_data.conf", NULL }; 767 NULL
754 GNUNET_log_setup ("test-plugin-transport", "WARNING", NULL ); 768 };
769
770 GNUNET_log_setup ("test-plugin-transport",
771 "WARNING",
772 NULL);
773 GNUNET_DISK_purge_cfg_dir ("test_plugin_transport_data.conf",
774 "GNUNET_TEST_HOME");
755 ok = 1; /* set to fail */ 775 ok = 1; /* set to fail */
756 ret = 776 ret =
757 (GNUNET_OK 777 (GNUNET_OK
758 == GNUNET_PROGRAM_run (3, argv_prog, "test-plugin-transport", 778 == GNUNET_PROGRAM_run (3, argv_prog, "test-plugin-transport",
759 "testcase", options, &run, (void *) argv)) ? ok : 1; 779 "testcase", options, &run, (void *) argv)) ? ok : 1;
760 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); 780 GNUNET_DISK_purge_cfg_dir ("test_plugin_transport_data.conf",
781 "GNUNET_TEST_HOME");
761 return ret; 782 return ret;
762} 783}
763 784