aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_unreliability.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-06-16 12:35:26 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-06-16 12:35:26 +0000
commit33cbde487152c775a38628ae7b12e8f5e8040a52 (patch)
tree3edafc6f153c9cf47f92d71bcb3d2f64b1ddc6f9 /src/transport/test_transport_api_unreliability.c
parent2aff944f4bce448c67c576d384926c2ffe8c8c5a (diff)
downloadgnunet-33cbde487152c775a38628ae7b12e8f5e8040a52.tar.gz
gnunet-33cbde487152c775a38628ae7b12e8f5e8040a52.zip
clean up in transport tests
Diffstat (limited to 'src/transport/test_transport_api_unreliability.c')
-rw-r--r--src/transport/test_transport_api_unreliability.c88
1 files changed, 18 insertions, 70 deletions
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index fadb49f5d..2101def80 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -37,6 +37,7 @@
37#include "gnunet_transport_service.h" 37#include "gnunet_transport_service.h"
38#include "gauger.h" 38#include "gauger.h"
39#include "transport.h" 39#include "transport.h"
40#include "transport-testing.h"
40 41
41#define VERBOSE GNUNET_NO 42#define VERBOSE GNUNET_NO
42 43
@@ -60,16 +61,6 @@
60 61
61#define MTYPE 12345 62#define MTYPE 12345
62 63
63struct PeerContext
64{
65 struct GNUNET_CONFIGURATION_Handle *cfg;
66 struct GNUNET_TRANSPORT_Handle *th;
67 struct GNUNET_PeerIdentity id;
68#if START_ARM
69 struct GNUNET_OS_Process *arm_proc;
70#endif
71};
72
73static struct PeerContext p1; 64static struct PeerContext p1;
74 65
75static struct PeerContext p2; 66static struct PeerContext p2;
@@ -533,6 +524,13 @@ static void
533setup_peer (struct PeerContext *p, const char *cfgname) 524setup_peer (struct PeerContext *p, const char *cfgname)
534{ 525{
535 p->cfg = GNUNET_CONFIGURATION_create (); 526 p->cfg = GNUNET_CONFIGURATION_create ();
527
528 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
529 if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
530 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
531 GNUNET_DISK_directory_remove (p->servicehome);
532
533
536#if START_ARM 534#if START_ARM
537 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, 535 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
538 "gnunet-service-arm", 536 "gnunet-service-arm",
@@ -542,64 +540,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
542#endif 540#endif
543 "-c", cfgname, NULL); 541 "-c", cfgname, NULL);
544#endif 542#endif
545 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
546
547 if (is_https)
548 {
549 struct stat sbuf;
550 if (p==&p1)
551 {
552 if (GNUNET_CONFIGURATION_have_value (p->cfg,
553 "transport-https", "KEY_FILE"))
554 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
555 if (key_file_p1 == NULL)
556 GNUNET_asprintf(&key_file_p1,"https_p1.key");
557 if (0 == stat (key_file_p1, &sbuf ))
558 {
559 if (0 == remove(key_file_p1))
560 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1);
561 else
562 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1);
563 }
564 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
565 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
566 if (cert_file_p1 == NULL)
567 GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
568 if (0 == stat (cert_file_p1, &sbuf ))
569 {
570 if (0 == remove(cert_file_p1))
571 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
572 else
573 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1);
574 }
575 }
576 else if (p==&p2)
577 {
578 if (GNUNET_CONFIGURATION_have_value (p->cfg,
579 "transport-https", "KEY_FILE"))
580 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
581 if (key_file_p2 == NULL)
582 GNUNET_asprintf(&key_file_p2,"https_p2.key");
583 if (0 == stat (key_file_p2, &sbuf ))
584 {
585 if (0 == remove(key_file_p2))
586 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2);
587 else
588 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2);
589 }
590 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
591 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
592 if (cert_file_p2 == NULL)
593 GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
594 if (0 == stat (cert_file_p2, &sbuf ))
595 {
596 if (0 == remove(cert_file_p2))
597 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
598 else
599 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2);
600 }
601 }
602 }
603 543
604 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, 544 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
605 p, 545 p,
@@ -864,6 +804,15 @@ check ()
864 GNUNET_free(cert_file_p2); 804 GNUNET_free(cert_file_p2);
865 } 805 }
866 806
807 if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
808 {
809 GNUNET_DISK_directory_remove (p1.servicehome);
810 GNUNET_DISK_directory_remove (p2.servicehome);
811 GNUNET_free(p1.servicehome);
812 GNUNET_free(p2.servicehome);
813 }
814 return ok;
815
867 return ok; 816 return ok;
868} 817}
869 818
@@ -921,8 +870,7 @@ main (int argc, char *argv[])
921#endif 870#endif
922 NULL); 871 NULL);
923 ret = check (); 872 ret = check ();
924 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1"); 873
925 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
926 GNUNET_free_non_null(test_name); 874 GNUNET_free_non_null(test_name);
927 return ret; 875 return ret;
928} 876}