[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24668 - gnunet/src/testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24668 - gnunet/src/testing |
Date: |
Thu, 1 Nov 2012 23:02:16 +0100 |
Author: harsha
Date: 2012-11-01 23:02:16 +0100 (Thu, 01 Nov 2012)
New Revision: 24668
Modified:
gnunet/src/testing/test_testing_peerstartup.c
gnunet/src/testing/test_testing_portreservation.c
Log:
fix crashing checks
Modified: gnunet/src/testing/test_testing_peerstartup.c
===================================================================
--- gnunet/src/testing/test_testing_peerstartup.c 2012-11-01 21:30:15 UTC
(rev 24667)
+++ gnunet/src/testing/test_testing_peerstartup.c 2012-11-01 22:02:16 UTC
(rev 24668)
@@ -33,6 +33,10 @@
#define LOG(kind,...) \
GNUNET_log (kind, __VA_ARGS__)
+/**
+ * The status of the test
+ */
+int status;
/**
* The testing context
@@ -67,10 +71,16 @@
{
struct TestingContext *test_ctx = cls;
- GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_stop (test_ctx->peer));
- GNUNET_TESTING_peer_destroy (test_ctx->peer);
- GNUNET_CONFIGURATION_destroy (test_ctx->cfg);
- GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES);
+ GNUNET_assert (NULL != test_ctx);
+ if (NULL != test_ctx->peer)
+ {
+ (void) GNUNET_TESTING_peer_stop (test_ctx->peer);
+ GNUNET_TESTING_peer_destroy (test_ctx->peer);
+ }
+ if (NULL != test_ctx->cfg)
+ GNUNET_CONFIGURATION_destroy (test_ctx->cfg);
+ if (NULL != test_ctx->system)
+ GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES);
GNUNET_free (test_ctx);
}
@@ -82,26 +92,33 @@
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- struct GNUNET_TESTING_System *system;
- struct GNUNET_TESTING_Peer *peer;
- struct GNUNET_CONFIGURATION_Handle *new_cfg;
struct TestingContext *test_ctx;
char *emsg;
struct GNUNET_PeerIdentity id;
-
- system = GNUNET_TESTING_system_create ("test-gnunet-testing",
- "127.0.0.1", NULL);
- GNUNET_assert (NULL != system);
- new_cfg = GNUNET_CONFIGURATION_dup (cfg);
+
+ test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
+ test_ctx->system =
+ GNUNET_TESTING_system_create ("test-gnunet-testing",
+ "127.0.0.1", NULL);
+ if (NULL == test_ctx->system)
+ goto end;
+ test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg);
emsg = NULL;
- peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg);
- GNUNET_assert (NULL != peer);
- GNUNET_assert (NULL == emsg);
- GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_start (peer));
- test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
- test_ctx->system = system;
- test_ctx->peer = peer;
- test_ctx->cfg = new_cfg;
+ test_ctx->peer =
+ GNUNET_TESTING_peer_configure (test_ctx->system,
+ test_ctx->cfg,
+ 0, &id, &emsg);
+ if (NULL == test_ctx->peer)
+ {
+ if (NULL != emsg)
+ printf ("Test failed upon error: %s", emsg);
+ goto end;
+ }
+ if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer))
+ goto end;
+ status = GNUNET_OK;
+
+ end:
GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx);
}
Modified: gnunet/src/testing/test_testing_portreservation.c
===================================================================
--- gnunet/src/testing/test_testing_portreservation.c 2012-11-01 21:30:15 UTC
(rev 24667)
+++ gnunet/src/testing/test_testing_portreservation.c 2012-11-01 22:02:16 UTC
(rev 24668)
@@ -33,6 +33,11 @@
GNUNET_log (kind, __VA_ARGS__)
/**
+ * The status of the test
+ */
+int status;
+
+/**
* Main point of test execution
*/
static void
@@ -50,11 +55,13 @@
new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Reserved TCP port %u\n", new_port1);
- GNUNET_assert (0 != new_port1);
+ if (0 == new_port1)
+ goto end;
new_port2 = GNUNET_TESTING_reserve_port (system, GNUNET_YES);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Reserved TCP port %u\n", new_port2);
- GNUNET_assert (0 != new_port2);
+ if (0 == new_port2)
+ goto end;
GNUNET_assert (new_port1 != new_port2);
GNUNET_TESTING_release_port (system, GNUNET_YES, new_port1);
old_port1 = new_port1;
@@ -66,6 +73,9 @@
GNUNET_assert (old_port1 == new_port1);
GNUNET_TESTING_release_port (system, GNUNET_YES, new_port1);
GNUNET_TESTING_release_port (system, GNUNET_YES, new_port2);
+ status = GNUNET_OK;
+
+ end:
GNUNET_TESTING_system_destroy (system, GNUNET_YES);
}
@@ -75,6 +85,8 @@
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
+
+ status = GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc,
argv,
@@ -87,7 +99,7 @@
{
return 1;
}
- return 0;
+ return (GNUNET_OK == status) ? 0 : 1;
}
/* end of test_testing_portreservation.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24668 - gnunet/src/testing,
gnunet <=