diff options
Diffstat (limited to 'src/transport/test_plugin_transport.c')
-rw-r--r-- | src/transport/test_plugin_transport.c | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index acb3911f0..2ef3a0ceb 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c | |||
@@ -566,8 +566,10 @@ handle_helper_message (void *cls, | |||
566 | * @param c configuration to use | 566 | * @param c configuration to use |
567 | */ | 567 | */ |
568 | static void | 568 | static void |
569 | run (void *cls, char * const *args, const char *cfgfile, | 569 | run (void *cls, |
570 | const struct GNUNET_CONFIGURATION_Handle *c) | 570 | char * const *args, |
571 | const char *cfgfile, | ||
572 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
571 | { | 573 | { |
572 | char * const *argv = cls; | 574 | char * const *argv = cls; |
573 | unsigned long long tneigh; | 575 | unsigned long long tneigh; |
@@ -575,26 +577,32 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
575 | char *plugin; | 577 | char *plugin; |
576 | char *sep; | 578 | char *sep; |
577 | 579 | ||
578 | timeout_endbadly = GNUNET_SCHEDULER_add_delayed (TIMEOUT, end_badly, &ok); | 580 | timeout_endbadly = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
579 | 581 | &end_badly, | |
582 | &ok); | ||
580 | cfg = c; | 583 | cfg = c; |
581 | /* parse configuration */ | 584 | /* parse configuration */ |
582 | if ((GNUNET_OK | 585 | if ( (GNUNET_OK != |
583 | != GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", | 586 | GNUNET_CONFIGURATION_get_value_number (c, |
584 | "NEIGHBOUR_LIMIT", &tneigh)) | 587 | "TRANSPORT", |
585 | || (GNUNET_OK | 588 | "NEIGHBOUR_LIMIT", |
586 | != GNUNET_CONFIGURATION_get_value_filename (c, "PEER", "PRIVATE_KEY", | 589 | &tneigh)) || |
587 | &keyfile))) | 590 | (GNUNET_OK != |
591 | GNUNET_CONFIGURATION_get_value_filename (c, | ||
592 | "PEER", | ||
593 | "PRIVATE_KEY", | ||
594 | &keyfile))) | ||
588 | { | 595 | { |
589 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 596 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
590 | "Transport service is lacking key configuration settings. Exiting.\n"); | 597 | "Transport service is lacking key configuration settings. Exiting.\n"); |
591 | return; | 598 | return; |
592 | } | 599 | } |
593 | 600 | ||
594 | if (NULL == (stats = GNUNET_STATISTICS_create ("transport", cfg))) | 601 | if (NULL == (stats = GNUNET_STATISTICS_create ("transport", |
602 | cfg))) | ||
595 | { | 603 | { |
596 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 604 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
597 | "Could not create statistics. Exiting.\n"); | 605 | "Could not create statistics. Exiting.\n"); |
598 | GNUNET_free(keyfile); | 606 | GNUNET_free(keyfile); |
599 | end_badly_now (); | 607 | end_badly_now (); |
600 | return; | 608 | return; |
@@ -602,27 +610,33 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
602 | 610 | ||
603 | if (GNUNET_OK != GNUNET_DISK_file_test (HOSTKEY_FILE)) | 611 | if (GNUNET_OK != GNUNET_DISK_file_test (HOSTKEY_FILE)) |
604 | { | 612 | { |
605 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Hostkey `%s' missing. Exiting.\n", | 613 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
606 | HOSTKEY_FILE); | 614 | "Hostkey `%s' missing. Exiting.\n", |
615 | HOSTKEY_FILE); | ||
607 | GNUNET_free(keyfile); | 616 | GNUNET_free(keyfile); |
608 | end_badly_now (); | 617 | end_badly_now (); |
609 | return; | 618 | return; |
610 | } | 619 | } |
611 | 620 | ||
612 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (keyfile)) | 621 | if (GNUNET_OK != |
622 | GNUNET_DISK_directory_create_for_file (keyfile)) | ||
613 | { | 623 | { |
614 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 624 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
615 | "Could not create a directory for hostkey `%s'. Exiting.\n", keyfile); | 625 | "Could not create a directory for hostkey `%s'. Exiting.\n", |
626 | keyfile); | ||
616 | GNUNET_free(keyfile); | 627 | GNUNET_free(keyfile); |
617 | end_badly_now (); | 628 | end_badly_now (); |
618 | return; | 629 | return; |
619 | } | 630 | } |
620 | 631 | ||
621 | if (GNUNET_OK != GNUNET_DISK_file_copy (HOSTKEY_FILE, keyfile)) | 632 | if (GNUNET_OK != |
633 | GNUNET_DISK_file_copy (HOSTKEY_FILE, | ||
634 | keyfile)) | ||
622 | { | 635 | { |
623 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 636 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
624 | "Could not copy hostkey `%s' to destination `%s'. Exiting.\n", | 637 | "Could not copy hostkey `%s' to destination `%s'. Exiting.\n", |
625 | HOSTKEY_FILE, keyfile); | 638 | HOSTKEY_FILE, |
639 | keyfile); | ||
626 | GNUNET_free(keyfile); | 640 | GNUNET_free(keyfile); |
627 | end_badly_now (); | 641 | end_badly_now (); |
628 | return; | 642 | return; |
@@ -730,9 +744,9 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
730 | end_badly_now (); | 744 | end_badly_now (); |
731 | return; | 745 | return; |
732 | } | 746 | } |
733 | |||
734 | } | 747 | } |
735 | 748 | ||
749 | |||
736 | /** | 750 | /** |
737 | * The main function for the test | 751 | * The main function for the test |
738 | * | 752 | * |
@@ -741,23 +755,32 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
741 | * @return 0 ok, 1 on error | 755 | * @return 0 ok, 1 on error |
742 | */ | 756 | */ |
743 | int | 757 | int |
744 | main (int argc, char * const *argv) | 758 | main (int argc, |
759 | char * const *argv) | ||
745 | { | 760 | { |
746 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 761 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
747 | GNUNET_GETOPT_OPTION_END }; | 762 | GNUNET_GETOPT_OPTION_END |
763 | }; | ||
748 | int ret; | 764 | int ret; |
749 | 765 | char * const argv_prog[] = { | |
750 | GNUNET_DISK_directory_remove (GNUNET_DISK_mktemp("test-gnunetd-plugin-transport")); | 766 | "test_plugin_transport", |
751 | 767 | "-c", | |
752 | char * const argv_prog[] = { "test_plugin_transport", "-c", | 768 | "test_plugin_transport_data.conf", |
753 | "test_plugin_transport_data.conf", NULL }; | 769 | NULL |
754 | GNUNET_log_setup ("test-plugin-transport", "WARNING", NULL ); | 770 | }; |
771 | |||
772 | GNUNET_log_setup ("test-plugin-transport", | ||
773 | "WARNING", | ||
774 | NULL); | ||
775 | GNUNET_DISK_purge_cfg_dir ("test_plugin_transport_data.conf", | ||
776 | "GNUNET_TEST_HOME"); | ||
755 | ok = 1; /* set to fail */ | 777 | ok = 1; /* set to fail */ |
756 | ret = | 778 | ret = |
757 | (GNUNET_OK | 779 | (GNUNET_OK |
758 | == GNUNET_PROGRAM_run (3, argv_prog, "test-plugin-transport", | 780 | == GNUNET_PROGRAM_run (3, argv_prog, "test-plugin-transport", |
759 | "testcase", options, &run, (void *) argv)) ? ok : 1; | 781 | "testcase", options, &run, (void *) argv)) ? ok : 1; |
760 | GNUNET_DISK_directory_remove (GNUNET_DISK_mktemp("test-gnunetd-plugin-transport")); | 782 | GNUNET_DISK_purge_cfg_dir ("test_plugin_transport_data.conf", |
783 | "GNUNET_TEST_HOME"); | ||
761 | return ret; | 784 | return ret; |
762 | } | 785 | } |
763 | 786 | ||