diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-01 22:02:16 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-01 22:02:16 +0000 |
commit | 4d501ee10c63e2edc044d6bcdb8ba060f78b34e5 (patch) | |
tree | 1bf7dca53ed163cf9f7acdd4e9a9e9e7a1f75ccc /src/testing/test_testing_peerstartup.c | |
parent | 71cc3e168ae8b07413645ff4a8be8bfe5b732cf7 (diff) | |
download | gnunet-4d501ee10c63e2edc044d6bcdb8ba060f78b34e5.tar.gz gnunet-4d501ee10c63e2edc044d6bcdb8ba060f78b34e5.zip |
fix crashing checks
Diffstat (limited to 'src/testing/test_testing_peerstartup.c')
-rw-r--r-- | src/testing/test_testing_peerstartup.c | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c index 7f78827f6..1de3d5b35 100644 --- a/src/testing/test_testing_peerstartup.c +++ b/src/testing/test_testing_peerstartup.c | |||
@@ -33,6 +33,10 @@ | |||
33 | #define LOG(kind,...) \ | 33 | #define LOG(kind,...) \ |
34 | GNUNET_log (kind, __VA_ARGS__) | 34 | GNUNET_log (kind, __VA_ARGS__) |
35 | 35 | ||
36 | /** | ||
37 | * The status of the test | ||
38 | */ | ||
39 | int status; | ||
36 | 40 | ||
37 | /** | 41 | /** |
38 | * The testing context | 42 | * The testing context |
@@ -67,10 +71,16 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
67 | { | 71 | { |
68 | struct TestingContext *test_ctx = cls; | 72 | struct TestingContext *test_ctx = cls; |
69 | 73 | ||
70 | GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_stop (test_ctx->peer)); | 74 | GNUNET_assert (NULL != test_ctx); |
71 | GNUNET_TESTING_peer_destroy (test_ctx->peer); | 75 | if (NULL != test_ctx->peer) |
72 | GNUNET_CONFIGURATION_destroy (test_ctx->cfg); | 76 | { |
73 | GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES); | 77 | (void) GNUNET_TESTING_peer_stop (test_ctx->peer); |
78 | GNUNET_TESTING_peer_destroy (test_ctx->peer); | ||
79 | } | ||
80 | if (NULL != test_ctx->cfg) | ||
81 | GNUNET_CONFIGURATION_destroy (test_ctx->cfg); | ||
82 | if (NULL != test_ctx->system) | ||
83 | GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES); | ||
74 | GNUNET_free (test_ctx); | 84 | GNUNET_free (test_ctx); |
75 | } | 85 | } |
76 | 86 | ||
@@ -82,26 +92,33 @@ static void | |||
82 | run (void *cls, char *const *args, const char *cfgfile, | 92 | run (void *cls, char *const *args, const char *cfgfile, |
83 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 93 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
84 | { | 94 | { |
85 | struct GNUNET_TESTING_System *system; | ||
86 | struct GNUNET_TESTING_Peer *peer; | ||
87 | struct GNUNET_CONFIGURATION_Handle *new_cfg; | ||
88 | struct TestingContext *test_ctx; | 95 | struct TestingContext *test_ctx; |
89 | char *emsg; | 96 | char *emsg; |
90 | struct GNUNET_PeerIdentity id; | 97 | struct GNUNET_PeerIdentity id; |
91 | 98 | ||
92 | system = GNUNET_TESTING_system_create ("test-gnunet-testing", | ||
93 | "127.0.0.1", NULL); | ||
94 | GNUNET_assert (NULL != system); | ||
95 | new_cfg = GNUNET_CONFIGURATION_dup (cfg); | ||
96 | emsg = NULL; | ||
97 | peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg); | ||
98 | GNUNET_assert (NULL != peer); | ||
99 | GNUNET_assert (NULL == emsg); | ||
100 | GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_start (peer)); | ||
101 | test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); | 99 | test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); |
102 | test_ctx->system = system; | 100 | test_ctx->system = |
103 | test_ctx->peer = peer; | 101 | GNUNET_TESTING_system_create ("test-gnunet-testing", |
104 | test_ctx->cfg = new_cfg; | 102 | "127.0.0.1", NULL); |
103 | if (NULL == test_ctx->system) | ||
104 | goto end; | ||
105 | test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg); | ||
106 | emsg = NULL; | ||
107 | test_ctx->peer = | ||
108 | GNUNET_TESTING_peer_configure (test_ctx->system, | ||
109 | test_ctx->cfg, | ||
110 | 0, &id, &emsg); | ||
111 | if (NULL == test_ctx->peer) | ||
112 | { | ||
113 | if (NULL != emsg) | ||
114 | printf ("Test failed upon error: %s", emsg); | ||
115 | goto end; | ||
116 | } | ||
117 | if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer)) | ||
118 | goto end; | ||
119 | status = GNUNET_OK; | ||
120 | |||
121 | end: | ||
105 | GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx); | 122 | GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx); |
106 | } | 123 | } |
107 | 124 | ||