aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_servicestartup.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-10 01:01:03 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-10 01:01:03 +0000
commit823825f3995c0850c4bc748fa267c0a74d35dbb3 (patch)
treeac5e16ea917031bad5b9807821f1bcc5a86a0ad5 /src/testing/test_testing_servicestartup.c
parentcefe62b18a22ae045fa64fa6bba44c3581ab64d5 (diff)
downloadgnunet-823825f3995c0850c4bc748fa267c0a74d35dbb3.tar.gz
gnunet-823825f3995c0850c4bc748fa267c0a74d35dbb3.zip
-minor fixes
Diffstat (limited to 'src/testing/test_testing_servicestartup.c')
-rw-r--r--src/testing/test_testing_servicestartup.c50
1 files changed, 6 insertions, 44 deletions
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