#include "gnunet_scheduler_lib.h"
#include "gnunet_transport_service.h"
#include "transport.h"
+#include "transport-testing.h"
#define VERBOSE GNUNET_NO
#define MTYPE 12345
-struct PeerContext
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- struct GNUNET_TRANSPORT_Handle *th;
- struct GNUNET_PeerIdentity id;
-#if START_ARM
- struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
static struct PeerContext p1;
static struct PeerContext p2;
const char *cfgname)
{
p->cfg = GNUNET_CONFIGURATION_create ();
+
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
+ GNUNET_DISK_directory_remove (p->servicehome);
+
#if START_ARM
p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#endif
"-c", cfgname, NULL);
#endif
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+
+
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
if (is_https)
{
GNUNET_free(cert_file_p1);
GNUNET_free(cert_file_p2);
}
+
+ if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
+ {
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_DISK_directory_remove (p2.servicehome);
+ GNUNET_free(p1.servicehome);
+ GNUNET_free(p2.servicehome);
+ }
return ok;
}
"`%s' not properly installed, cannot run NAT test!\n",
"gnunet-nat-server");
return 0;
- }
+ } GNUNET_free(p1.servicehome);
+ GNUNET_free(p2.servicehome);
}
else if (strstr(argv[0], "udp") != NULL)
{
}
ret = check ();
- if (is_multi_protocol)
- {
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-multi-peer-1/");
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-multi-peer-2/");
- }
- else
- {
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
- }
return ret;
}
#include "gnunet_transport_service.h"
#include "gauger.h"
#include "transport.h"
+#include "transport-testing.h"
#define VERBOSE GNUNET_NO
#define MTYPE 12345
-struct PeerContext
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- struct GNUNET_TRANSPORT_Handle *th;
- struct GNUNET_PeerIdentity id;
-#if START_ARM
- struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
static struct PeerContext p1;
static struct PeerContext p2;
setup_peer (struct PeerContext *p, const char *cfgname)
{
p->cfg = GNUNET_CONFIGURATION_create ();
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
+ GNUNET_DISK_directory_remove (p->servicehome);
+
#if START_ARM
p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
#endif
"-c", cfgname, NULL);
#endif
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
if (is_https)
{
if (0 == stat (key_file_p1, &sbuf ))
{
if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully removed existing private key file `%s'\n",
key_file_p1);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to remove private key file `%s'\n",
key_file_p1);
}
if (0 == stat (cert_file_p1, &sbuf ))
{
if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully removed existing certificate file `%s'\n",
cert_file_p1);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to remove existing certificate file `%s'\n",
cert_file_p1);
}
if (0 == stat (key_file_p2, &sbuf ))
{
if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully removed existing private key file `%s'\n",
key_file_p2);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to remove private key file `%s'\n",
key_file_p2);
}
if (0 == stat (cert_file_p2, &sbuf ))
{
if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully removed existing certificate file `%s'\n",
cert_file_p2);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to remove existing certificate file `%s'\n",
cert_file_p2);
}
GNUNET_free(key_file_p2);
GNUNET_free(cert_file_p1);
GNUNET_free(cert_file_p2);
+ GNUNET_free(p1.servicehome);
+ GNUNET_free(p2.servicehome);
}
return ok;
return GNUNET_SYSERR;
#endif
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
-
if (strstr(argv[0], "tcp_nat") != NULL)
{
is_tcp_nat = GNUNET_YES;
#endif
NULL);
ret = check ();
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_DISK_directory_remove (p2.servicehome);
return ret;
}
#include "gnunet_transport_service.h"
#include "gauger.h"
#include "transport.h"
+#include "transport-testing.h"
#define VERBOSE GNUNET_NO
#define MTYPE 12345
-struct PeerContext
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- struct GNUNET_TRANSPORT_Handle *th;
- struct GNUNET_PeerIdentity id;
-#if START_ARM
- struct GNUNET_OS_Process *arm_proc;
-#endif
-};
-
static struct PeerContext p1;
static struct PeerContext p2;
setup_peer (struct PeerContext *p, const char *cfgname)
{
p->cfg = GNUNET_CONFIGURATION_create ();
+
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
+ GNUNET_DISK_directory_remove (p->servicehome);
+
+
#if START_ARM
p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
#endif
"-c", cfgname, NULL);
#endif
- GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-
- if (is_https)
- {
- struct stat sbuf;
- if (p==&p1)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
- if (key_file_p1 == NULL)
- GNUNET_asprintf(&key_file_p1,"https_p1.key");
- if (0 == stat (key_file_p1, &sbuf ))
- {
- if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
- if (cert_file_p1 == NULL)
- GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
- if (0 == stat (cert_file_p1, &sbuf ))
- {
- if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1);
- }
- }
- else if (p==&p2)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
- if (key_file_p2 == NULL)
- GNUNET_asprintf(&key_file_p2,"https_p2.key");
- if (0 == stat (key_file_p2, &sbuf ))
- {
- if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
- if (cert_file_p2 == NULL)
- GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
- if (0 == stat (cert_file_p2, &sbuf ))
- {
- if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2);
- }
- }
- }
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
p,
GNUNET_free(cert_file_p2);
}
+ if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
+ {
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_DISK_directory_remove (p2.servicehome);
+ GNUNET_free(p1.servicehome);
+ GNUNET_free(p2.servicehome);
+ }
+ return ok;
+
return ok;
}
#endif
NULL);
ret = check ();
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
- GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
+
GNUNET_free_non_null(test_name);
return ret;
}
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2006, 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file transport_testing.h
+ * @brief testing lib for transport service
+ *
+ * @author Matthias Wachs
+ */
+
+struct PeerContext
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+ struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_PeerIdentity id;
+ struct GNUNET_OS_Process *arm_proc;
+ char * servicehome;
+};
+
+/* end of transport_testing.h */