aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-06-23 22:07:20 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2012-06-23 22:07:20 +0000
commita7e40c3b0df908d8f84acafb0290fed3b218f995 (patch)
tree20a520a7e57713ea5a6745bf3d9483dec4ed79ae /src
parent5b49b546f20c8f5812c2e2d27a4cbb8bcb53f935 (diff)
-removing dead old code
git-svn-id: https://gnunet.org/svn/gnunet@22237 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r--src/ats/Makefile.am10
-rw-r--r--src/ats/test_ats_api_bandwidth_consumption.c78
-rw-r--r--src/ats/test_ats_api_reset_backoff.c70
-rw-r--r--src/ats/test_ats_api_scheduling.c65
-rw-r--r--src/ats/test_ats_api_scheduling_add_address.c66
-rw-r--r--src/ats/test_ats_api_scheduling_destroy_address.c69
-rw-r--r--src/ats/test_ats_api_scheduling_destroy_session.c69
7 files changed, 99 insertions, 328 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 889650bca8..06d4f1dfec 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -54,10 +54,10 @@ gnunet_service_ats_LDADD = \
$(GN_LIBINTL)
gnunet_service_ats_DEPENDENCIES = \
libgnunetats.la
-
+
gnunet_ats_SOURCES = \
gnunet-ats.c gnunet-service-ats.h
-gnunet_ats_LDADD = \
+gnunet_ats_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/ats/libgnunetats.la \
$(GN_LIBINTL)
@@ -111,30 +111,35 @@ test_ats_api_scheduling_SOURCES = \
test_ats_api_scheduling.c
test_ats_api_scheduling_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/ats/libgnunetats.la
test_ats_api_reset_backoff_SOURCES = \
test_ats_api_reset_backoff.c
test_ats_api_reset_backoff_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/ats/libgnunetats.la
test_ats_api_scheduling_add_address_SOURCES = \
test_ats_api_scheduling_add_address.c
test_ats_api_scheduling_add_address_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/ats/libgnunetats.la
test_ats_api_scheduling_destroy_address_SOURCES = \
test_ats_api_scheduling_destroy_address.c
test_ats_api_scheduling_destroy_address_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/ats/libgnunetats.la
test_ats_api_scheduling_destroy_session_SOURCES = \
test_ats_api_scheduling_destroy_session.c
test_ats_api_scheduling_destroy_session_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/ats/libgnunetats.la
#test_ats_api_scheduling_get_type_SOURCES = \
@@ -147,6 +152,7 @@ test_ats_api_scheduling_destroy_session_LDADD = \
# test_ats_api_bandwidth_consumption.c
#test_ats_api_bandwidth_consumption_LDADD = \
# $(top_builddir)/src/util/libgnunetutil.la \
+# $(top_builddir)/src/testing/libgnunettesting.la \
# $(top_builddir)/src/ats/libgnunetats.la
#test_ats_api_update_address_SOURCES = \
diff --git a/src/ats/test_ats_api_bandwidth_consumption.c b/src/ats/test_ats_api_bandwidth_consumption.c
index 01321e1479..5b1b2df458 100644
--- a/src/ats/test_ats_api_bandwidth_consumption.c
+++ b/src/ats/test_ats_api_bandwidth_consumption.c
@@ -26,6 +26,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -40,8 +41,6 @@ static struct GNUNET_ATS_PerformanceHandle *atp;
struct GNUNET_ATS_ReservationContext *sh;
-static struct GNUNET_OS_Process *arm_proc;
-
static struct PeerContext *p;
static uint32_t bw_in;
@@ -53,12 +52,15 @@ static int ret;
struct Address
{
char *plugin;
+
size_t plugin_len;
void *addr;
+
size_t addr_len;
struct GNUNET_ATS_Information *ats;
+
int ats_count;
void *session;
@@ -73,41 +75,23 @@ struct PeerContext
static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
-
-
-static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
die_task = GNUNET_SCHEDULER_NO_TASK;
-
if (consume_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (consume_task);
consume_task = GNUNET_SCHEDULER_NO_TASK;
}
-
if (sh != NULL)
GNUNET_ATS_reserve_bandwidth_cancel (sh);
-
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
if (atp != NULL)
GNUNET_ATS_performance_done (atp);
-
GNUNET_free (p->addr);
GNUNET_free (p);
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -119,26 +103,20 @@ end ()
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
-
if (consume_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (consume_task);
consume_task = GNUNET_SCHEDULER_NO_TASK;
}
-
GNUNET_ATS_scheduling_done (ats);
-
GNUNET_ATS_performance_done (atp);
-
GNUNET_free (p->addr);
GNUNET_free (p);
-
ret = 0;
-
- stop_arm ();
}
-void
+
+static void
performance_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
size_t plugin_addr_len,
@@ -149,7 +127,8 @@ performance_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
}
-void
+
+static void
reservation_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
int32_t amount, struct GNUNET_TIME_Relative res_delay)
{
@@ -159,6 +138,7 @@ reservation_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_i2s (peer), res_delay.rel_value);
}
+
static void
consume_bandwidth (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -173,6 +153,7 @@ consume_bandwidth (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
NULL);
}
+
static void
address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
@@ -191,25 +172,16 @@ address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
consume_task = GNUNET_SCHEDULER_add_now (&consume_bandwidth, NULL);
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
- ret = GNUNET_SYSERR;
struct Address *addr;
+ ret = GNUNET_SYSERR;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
if (ats == NULL)
{
@@ -217,7 +189,6 @@ check (void *cls, char *const *args, const char *cfgfile,
end ();
return;
}
-
p = GNUNET_malloc (sizeof (struct PeerContext));
addr = GNUNET_malloc (sizeof (struct Address));
@@ -250,25 +221,14 @@ check (void *cls, char *const *args, const char *cfgfile,
GNUNET_ATS_suggest_address (ats, &p->id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_bandwidth_consumption",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_bandwidth_consumption", "nohelp", options,
- &check, NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_bandwidth_consumption",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}
diff --git a/src/ats/test_ats_api_reset_backoff.c b/src/ats/test_ats_api_reset_backoff.c
index 859cfc2156..ecdf0cb531 100644
--- a/src/ats/test_ats_api_reset_backoff.c
+++ b/src/ats/test_ats_api_reset_backoff.c
@@ -25,6 +25,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -36,10 +37,9 @@ static GNUNET_SCHEDULER_TaskIdentifier suggest_timeout_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process *arm_proc;
-
static int ret;
+
struct Address
{
char *plugin;
@@ -62,41 +62,29 @@ struct PeerContext
};
struct GNUNET_HELLO_Address hello_addr;
+
struct Address address;
+
struct PeerContext peer;
-struct GNUNET_ATS_Information atsi[2];
-static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
+struct GNUNET_ATS_Information atsi[2];
static void
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
die_task = GNUNET_SCHEDULER_NO_TASK;
-
if (suggest_timeout_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (suggest_timeout_task);
suggest_timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
-
if (ats != NULL)
{
GNUNET_ATS_scheduling_done (ats);
ats = NULL;
}
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -115,12 +103,8 @@ end ()
GNUNET_SCHEDULER_cancel (suggest_timeout_task);
suggest_timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
-
GNUNET_ATS_scheduling_done (ats);
-
ret = 0;
-
- stop_arm ();
}
@@ -128,18 +112,16 @@ static void
suggest_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
suggest_timeout_task = GNUNET_SCHEDULER_NO_TASK;
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting address for peer timed out\n");
-
if (die_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
-
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
+
static void
address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *a,
struct Session *session,
@@ -149,6 +131,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *a,
uint32_t ats_count)
{
static int suggestions;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n",
GNUNET_i2s (&a->peer));
@@ -230,26 +213,15 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *a,
suggest_timeout_task = GNUNET_SCHEDULER_add_delayed(ATS_TIMEOUT, &suggest_timeout, NULL);
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peerx)
{
ret = GNUNET_SYSERR;
-
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
-
if (ats == NULL)
{
ret = GNUNET_SYSERR;
@@ -280,30 +252,18 @@ check (void *cls, char *const *args, const char *cfgfile,
GNUNET_i2s (&peer.id));
/* Increase block timout far beyond ATS_TIMEOUT */
GNUNET_ATS_suggest_address (ats, &peer.id);
-
GNUNET_ATS_reset_backoff(ats, &peer.id);
GNUNET_ATS_suggest_address (ats, &peer.id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_scheduling",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_scheduling", "nohelp", options, &check,
- NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_reset_backoff",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}
/* end of file test_ats_api_reset_backoff.c */
diff --git a/src/ats/test_ats_api_scheduling.c b/src/ats/test_ats_api_scheduling.c
index 39d53ddd4a..750bae6c2f 100644
--- a/src/ats/test_ats_api_scheduling.c
+++ b/src/ats/test_ats_api_scheduling.c
@@ -32,6 +32,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -40,10 +41,6 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process *arm_proc;
-
-
-
static int ret;
struct Address
@@ -67,19 +64,11 @@ struct PeerContext
struct Address *addr;
};
-struct Address test_addr[2];
-struct PeerContext p[2];
-struct GNUNET_ATS_Information atsi[2];
+static struct Address test_addr[2];
-static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
+static struct PeerContext p[2];
+
+static struct GNUNET_ATS_Information atsi[2];
static void
@@ -88,10 +77,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
die_task = GNUNET_SCHEDULER_NO_TASK;
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -106,10 +92,7 @@ end ()
}
GNUNET_ATS_scheduling_done (ats);
-
ret = 0;
-
- stop_arm ();
}
@@ -139,35 +122,24 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
GNUNET_SCHEDULER_add_now (&end, NULL);
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
struct GNUNET_HELLO_Address address0;
ret = GNUNET_SYSERR;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
-
if (ats == NULL)
{
ret = GNUNET_SYSERR;
end ();
return;
}
-
/* set up peer */
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
&p[0].id.hashPubKey);
@@ -215,25 +187,14 @@ check (void *cls, char *const *args, const char *cfgfile,
GNUNET_ATS_suggest_address (ats, &p[0].id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_scheduling",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_scheduling", "nohelp", options, &check,
- NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}
diff --git a/src/ats/test_ats_api_scheduling_add_address.c b/src/ats/test_ats_api_scheduling_add_address.c
index 587515df31..29dd33c71e 100644
--- a/src/ats/test_ats_api_scheduling_add_address.c
+++ b/src/ats/test_ats_api_scheduling_add_address.c
@@ -25,6 +25,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -33,10 +34,6 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process *arm_proc;
-
-
-
static int ret;
struct Address
@@ -60,19 +57,12 @@ struct PeerContext
struct Address *addr;
};
-struct Address test_addr;
-struct PeerContext p;
-struct GNUNET_ATS_Information atsi;
-static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
+static struct Address test_addr;
+
+static struct PeerContext p;
+
+static struct GNUNET_ATS_Information atsi;
static void
@@ -81,10 +71,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
die_task = GNUNET_SCHEDULER_NO_TASK;
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -97,12 +84,8 @@ end ()
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
-
GNUNET_ATS_scheduling_done (ats);
-
ret = 0;
-
- stop_arm ();
}
@@ -132,26 +115,16 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
GNUNET_SCHEDULER_add_now (&end, NULL);
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
struct GNUNET_HELLO_Address address0;
ret = GNUNET_SYSERR;
-
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
if (ats == NULL)
@@ -194,25 +167,14 @@ check (void *cls, char *const *args, const char *cfgfile,
GNUNET_ATS_suggest_address (ats, &p.id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_scheduling_add_address",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_scheduling_add_address", "nohelp", options, &check,
- NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}
diff --git a/src/ats/test_ats_api_scheduling_destroy_address.c b/src/ats/test_ats_api_scheduling_destroy_address.c
index 9cf6217f88..ff29e9a2da 100644
--- a/src/ats/test_ats_api_scheduling_destroy_address.c
+++ b/src/ats/test_ats_api_scheduling_destroy_address.c
@@ -26,6 +26,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -34,13 +35,11 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process *arm_proc;
-
-
-
static int ret;
+
static int stage;
+
struct Address
{
char *plugin;
@@ -62,20 +61,11 @@ struct PeerContext
struct Address *addr;
};
-struct Address test_addr;
-struct PeerContext p;
-struct GNUNET_ATS_Information atsi;
-struct GNUNET_HELLO_Address hello_address;
+static struct Address test_addr;
-static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
+static struct PeerContext p;
+
+static struct GNUNET_HELLO_Address hello_address;
static void
@@ -84,10 +74,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
die_task = GNUNET_SCHEDULER_NO_TASK;
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -100,9 +87,7 @@ end ()
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
-
GNUNET_ATS_scheduling_done (ats);
-
if (2 == stage)
ret = 0;
else
@@ -110,8 +95,6 @@ end ()
GNUNET_break (0);
ret = 1;
}
-
- stop_arm ();
}
@@ -155,26 +138,16 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
stage++;
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
ret = GNUNET_SYSERR;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
-
if (ats == NULL)
{
ret = GNUNET_SYSERR;
@@ -199,29 +172,17 @@ check (void *cls, char *const *args, const char *cfgfile,
hello_address.address = test_addr.addr;
hello_address.address_length = test_addr.addr_len;
GNUNET_ATS_address_add (ats, &hello_address, test_addr.session, NULL, 0);
-
GNUNET_ATS_suggest_address (ats, &p.id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_scheduling_destroy_address",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_scheduling_destroy_address", "nohelp", options, &check,
- NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_destroy_address",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}
diff --git a/src/ats/test_ats_api_scheduling_destroy_session.c b/src/ats/test_ats_api_scheduling_destroy_session.c
index 7d223a71ee..722102b32b 100644
--- a/src/ats/test_ats_api_scheduling_destroy_session.c
+++ b/src/ats/test_ats_api_scheduling_destroy_session.c
@@ -27,6 +27,7 @@
*/
#include "platform.h"
#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib-new.h"
#include "ats.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
@@ -35,11 +36,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process *arm_proc;
-
-
-
static int ret;
+
static int stage;
struct Address
@@ -63,20 +61,12 @@ struct PeerContext
struct Address *addr;
};
-struct Address test_addr;
-struct PeerContext p;
-struct GNUNET_ATS_Information atsi;
-struct GNUNET_HELLO_Address hello_address;
-static void
-stop_arm ()
-{
- if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (arm_proc);
- GNUNET_OS_process_destroy (arm_proc);
- arm_proc = NULL;
-}
+static struct Address test_addr;
+
+static struct PeerContext p;
+
+static struct GNUNET_HELLO_Address hello_address;
static void
@@ -85,10 +75,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
die_task = GNUNET_SCHEDULER_NO_TASK;
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
-
ret = GNUNET_SYSERR;
-
- stop_arm ();
}
@@ -101,9 +88,7 @@ end ()
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
-
GNUNET_ATS_scheduling_done (ats);
-
if (2 == stage)
ret = 0;
else
@@ -111,8 +96,6 @@ end ()
GNUNET_break (0);
ret = 1;
}
-
- stop_arm ();
}
@@ -167,26 +150,16 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
stage++;
}
-void
-start_arm (const char *cfgname)
-{
- arm_proc =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
- "-c", cfgname, NULL);
-}
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
ret = GNUNET_SYSERR;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- start_arm (cfgfile);
-
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
-
if (ats == NULL)
{
ret = GNUNET_SYSERR;
@@ -211,29 +184,17 @@ check (void *cls, char *const *args, const char *cfgfile,
hello_address.address = test_addr.addr;
hello_address.address_length = test_addr.addr_len;
GNUNET_ATS_address_add (ats, &hello_address, test_addr.session, NULL, 0);
-
GNUNET_ATS_suggest_address (ats, &p.id);
}
+
int
main (int argc, char *argv[])
{
- static char *const argv2[] = { "test_ats_api_scheduling_destroy_session",
- "-c",
- "test_ats_api.conf",
- "-L", "WARNING",
- NULL
- };
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_scheduling_destroy_session", "nohelp", options, &check,
- NULL);
-
-
+ if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_destroy_session",
+ "test_ats_api.conf",
+ &run, NULL))
+ return 1;
return ret;
}