aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testing/test_testing_peerstartup.c36
-rw-r--r--src/testing/test_testing_portreservation.c2
-rw-r--r--src/testing/test_testing_servicestartup.c50
-rw-r--r--src/testing/testing.c7
4 files changed, 18 insertions, 77 deletions
diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c
index 13853fe68..990486467 100644
--- a/src/testing/test_testing_peerstartup.c
+++ b/src/testing/test_testing_peerstartup.c
@@ -33,8 +33,6 @@
33#define LOG(kind,...) \ 33#define LOG(kind,...) \
34 GNUNET_log (kind, __VA_ARGS__) 34 GNUNET_log (kind, __VA_ARGS__)
35 35
36#define TIME_REL_SEC(sec) \
37 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
38 36
39/** 37/**
40 * The testing context 38 * The testing context
@@ -89,37 +87,11 @@ run (void *cls, char *const *args, const char *cfgfile,
89 struct GNUNET_CONFIGURATION_Handle *new_cfg; 87 struct GNUNET_CONFIGURATION_Handle *new_cfg;
90 struct TestingContext *test_ctx; 88 struct TestingContext *test_ctx;
91 char *emsg; 89 char *emsg;
92 char *_tmpdir;
93 char *tmpdir;
94#ifdef MINGW
95 char *tmpdir_w;
96#endif
97
98 struct GNUNET_PeerIdentity id; 90 struct GNUNET_PeerIdentity id;
99 91
100 _tmpdir = getenv ("TMP"); 92 system = GNUNET_TESTING_system_create ("test-gnunet-testing",
101 if (NULL == _tmpdir)
102 _tmpdir = getenv ("TEMP");
103 if (NULL == _tmpdir)
104 _tmpdir = getenv ("TMPDIR");
105 if (NULL == _tmpdir)
106 _tmpdir = "/tmp";
107 GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX");
108#ifdef MINGW
109 tmpdir_w = GNUNET_malloc (MAX_PATH + 1);
110 GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w));
111 GNUNET_free (tmpdir);
112 tmpdir = tmpdir_w;
113 //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1));
114#else
115 GNUNET_assert (mkdtemp (tmpdir) == tmpdir);
116#endif
117 /* LOG (GNUNET_ERROR_TYPE_ERROR, */
118 /* "Temporary directory: %s\n", tmpdir); */
119 system = GNUNET_TESTING_system_create (tmpdir,
120 "127.0.0.1"); 93 "127.0.0.1");
121 GNUNET_assert (NULL != system); 94 GNUNET_assert (NULL != system);
122 GNUNET_free (tmpdir);
123 new_cfg = GNUNET_CONFIGURATION_dup (cfg); 95 new_cfg = GNUNET_CONFIGURATION_dup (cfg);
124 emsg = NULL; 96 emsg = NULL;
125 peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg); 97 peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg);
@@ -130,9 +102,7 @@ run (void *cls, char *const *args, const char *cfgfile,
130 test_ctx->system = system; 102 test_ctx->system = system;
131 test_ctx->peer = peer; 103 test_ctx->peer = peer;
132 test_ctx->cfg = new_cfg; 104 test_ctx->cfg = new_cfg;
133 GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (5), 105 GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx);
134 &do_shutdown, test_ctx);
135
136} 106}
137 107
138 108
@@ -150,3 +120,5 @@ int main (int argc, char *argv[])
150 return 1; 120 return 1;
151 return 0; 121 return 0;
152} 122}
123
124/* end of test_testing_peerstartup.c */
diff --git a/src/testing/test_testing_portreservation.c b/src/testing/test_testing_portreservation.c
index 02d6e1686..f689f455a 100644
--- a/src/testing/test_testing_portreservation.c
+++ b/src/testing/test_testing_portreservation.c
@@ -89,3 +89,5 @@ int main (int argc, char *argv[])
89 } 89 }
90 return 0; 90 return 0;
91} 91}
92
93/* end of test_testing_portreservation.c */
diff --git a/src/testing/test_testing_servicestartup.c b/src/testing/test_testing_servicestartup.c
index 0d3c6ca13..236e84789 100644
--- a/src/testing/test_testing_servicestartup.c
+++ b/src/testing/test_testing_servicestartup.c
@@ -23,7 +23,6 @@
23 * @brief test case for testing service startup using new testing API 23 * @brief test case for testing service startup using new testing API
24 * @author Sree Harsha Totakura 24 * @author Sree Harsha Totakura
25 */ 25 */
26
27#include "platform.h" 26#include "platform.h"
28#include "gnunet_scheduler_lib.h" 27#include "gnunet_scheduler_lib.h"
29#include "gnunet_testing_lib-new.h" 28#include "gnunet_testing_lib-new.h"
@@ -32,27 +31,12 @@
32#define LOG(kind,...) \ 31#define LOG(kind,...) \
33 GNUNET_log (kind, __VA_ARGS__) 32 GNUNET_log (kind, __VA_ARGS__)
34 33
35#define TIME_REL_SEC(sec) \
36 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
37 34
38/** 35/**
39 * Global test status 36 * Global test status
40 */ 37 */
41static int test_success; 38static int test_success;
42 39
43/**
44 * The shutdown task. Used to signal that testing is done and service has to be
45 * stopped
46 *
47 * @param cls NULL
48 */
49static void
50shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
51{
52 test_success = GNUNET_YES;
53 GNUNET_SCHEDULER_shutdown ();
54}
55
56 40
57/** 41/**
58 * The testing callback function 42 * The testing callback function
@@ -66,7 +50,8 @@ test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
66 GNUNET_assert (NULL == cls); 50 GNUNET_assert (NULL == cls);
67 GNUNET_assert (NULL != cfg); 51 GNUNET_assert (NULL != cfg);
68 LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n"); 52 LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n");
69 GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (3), &shutdown_task, NULL); 53 test_success = GNUNET_YES;
54 GNUNET_SCHEDULER_shutdown ();
70} 55}
71 56
72 57
@@ -75,37 +60,14 @@ test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
75 */ 60 */
76int main (int argc, char *argv[]) 61int main (int argc, char *argv[])
77{ 62{
78 char *_tmpdir;
79 char *tmpdir;
80#ifdef MINGW
81 char *tmpdir_w;
82#endif
83
84 GNUNET_log_setup ("test_testing_new_servicestartup", "DEBUG", NULL);
85 _tmpdir = getenv ("TMP");
86 if (NULL == _tmpdir)
87 _tmpdir = getenv ("TEMP");
88 if (NULL == _tmpdir)
89 _tmpdir = getenv ("TMPDIR");
90 if (NULL == _tmpdir)
91 _tmpdir = "/tmp";
92 GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX");
93#ifdef MINGW
94 tmpdir_w = GNUNET_malloc (MAX_PATH + 1);
95 GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w));
96 GNUNET_free (tmpdir);
97 tmpdir = tmpdir_w;
98 //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1));
99#else
100 GNUNET_assert (mkdtemp (tmpdir) == tmpdir);
101#endif
102
103 test_success = GNUNET_NO; 63 test_success = GNUNET_NO;
104 GNUNET_assert (0 == GNUNET_TESTING_service_run (tmpdir, 64 GNUNET_assert (0 == GNUNET_TESTING_service_run ("test-testing-servicestartup",
105 "arm", 65 "arm",
106 "test_testing_defaults.conf", 66 "test_testing_defaults.conf",
107 &test_run, 67 &test_run,
108 NULL)); 68 NULL));
109 GNUNET_free (tmpdir);
110 return (GNUNET_YES == test_success) ? 0 : 1; 69 return (GNUNET_YES == test_success) ? 0 : 1;
111} 70}
71
72/* end of test_testing_servicestartup.c */
73
diff --git a/src/testing/testing.c b/src/testing/testing.c
index ac5edab34..949dd5357 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -245,7 +245,12 @@ GNUNET_TESTING_system_create (const char *tmppath,
245 245
246 GNUNET_assert (NULL != tmppath); 246 GNUNET_assert (NULL != tmppath);
247 system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System)); 247 system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System));
248 system->tmppath = GNUNET_strdup (tmppath); 248 system->tmppath = GNUNET_DISK_mkdtemp (tmppath);
249 if (NULL == system->tmppath)
250 {
251 GNUNET_free (system);
252 return NULL;
253 }
249 if (NULL != controller) 254 if (NULL != controller)
250 system->controller = GNUNET_strdup (controller); 255 system->controller = GNUNET_strdup (controller);
251 if (GNUNET_OK != hostkeys_load (system)) 256 if (GNUNET_OK != hostkeys_load (system))