[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29317 - in gnunet/src: namestore psycstore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29317 - in gnunet/src: namestore psycstore |
Date: |
Mon, 16 Sep 2013 15:23:12 +0200 |
Author: tg
Date: 2013-09-16 15:23:12 +0200 (Mon, 16 Sep 2013)
New Revision: 29317
Modified:
gnunet/src/namestore/test_namestore_api_store.c
gnunet/src/psycstore/test_plugin_psycstore.c
gnunet/src/psycstore/test_psycstore.c
Log:
psycstore: use GNUNET_assert()
Modified: gnunet/src/namestore/test_namestore_api_store.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_store.c 2013-09-16 13:22:08 UTC
(rev 29316)
+++ gnunet/src/namestore/test_namestore_api_store.c 2013-09-16 13:23:12 UTC
(rev 29317)
@@ -94,8 +94,8 @@
static void
rd_decrypt_cb (void *cls,
- unsigned int rd_count,
- const struct
GNUNET_NAMESTORE_RecordData *rd)
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
char rd_cmp_data[TEST_RECORD_DATALEN];
@@ -116,7 +116,7 @@
static void
name_lookup_proc (void *cls,
- const
struct GNUNET_NAMESTORE_Block *block)
+ const struct GNUNET_NAMESTORE_Block *block)
{
const char *name = cls;
nsqe = NULL;
Modified: gnunet/src/psycstore/test_plugin_psycstore.c
===================================================================
--- gnunet/src/psycstore/test_plugin_psycstore.c 2013-09-16 13:22:08 UTC
(rev 29316)
+++ gnunet/src/psycstore/test_plugin_psycstore.c 2013-09-16 13:23:12 UTC
(rev 29317)
@@ -43,15 +43,6 @@
#define LOG(kind,...)
\
GNUNET_log_from (kind, "test-plugin-psycstore", __VA_ARGS__)
-#define ASSERT(x)
\
- do {
\
- if (! (x))
\
- {
\
- LOG (GNUNET_ERROR_TYPE_ERROR, "Error at %s:%d\n", __FILE__, __LINE__);
\
- goto FAILURE;
\
- }
\
- } while (0)
-
static int ok;
/**
@@ -186,28 +177,29 @@
channel_key = GNUNET_CRYPTO_ecc_key_create ();
slave_key = GNUNET_CRYPTO_ecc_key_create ();
- GNUNET_CRYPTO_ecc_key_get_public_for_signature (channel_key,
&channel_pub_key);
+ GNUNET_CRYPTO_ecc_key_get_public_for_signature (channel_key,
+ &channel_pub_key);
GNUNET_CRYPTO_ecc_key_get_public_for_signature (slave_key, &slave_pub_key);
- ASSERT (GNUNET_OK == db->membership_store (db->cls, &channel_pub_key,
- &slave_pub_key, GNUNET_YES,
- 4, 2, 1));
+ GNUNET_assert (GNUNET_OK == db->membership_store (db->cls, &channel_pub_key,
+ &slave_pub_key, GNUNET_YES,
+ 4, 2, 1));
- ASSERT (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
- &slave_pub_key, 4));
+ GNUNET_assert (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
+ &slave_pub_key, 4));
- ASSERT (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
- &slave_pub_key, 2));
+ GNUNET_assert (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
+ &slave_pub_key, 2));
- ASSERT (GNUNET_NO == db->membership_test (db->cls, &channel_pub_key,
- &slave_pub_key, 1));
+ GNUNET_assert (GNUNET_NO == db->membership_test (db->cls, &channel_pub_key,
+ &slave_pub_key, 1));
/* Store & get messages */
struct GNUNET_MULTICAST_MessageHeader *msg
= GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key));
- ASSERT (msg != NULL);
+ GNUNET_assert (msg != NULL);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
msg->header.size = htons (sizeof (*msg) + sizeof (channel_pub_key));
@@ -233,33 +225,35 @@
fcls.msg[0] = msg;
fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE;
- ASSERT (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg,
+ GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key,
msg,
fcls.flags[0]));
- ASSERT (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
+ GNUNET_assert (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
GNUNET_ntohll (msg->fragment_id),
fragment_cb, &fcls));
- ASSERT (fcls.n == 1);
+ GNUNET_assert (fcls.n == 1);
fcls.n = 0;
- ASSERT (GNUNET_OK == db->message_get_fragment (db->cls, &channel_pub_key,
- GNUNET_ntohll
(msg->message_id),
- GNUNET_ntohll
(msg->fragment_offset),
- fragment_cb, &fcls));
- ASSERT (fcls.n == 1);
+ GNUNET_assert (
+ GNUNET_OK == db->message_get_fragment (db->cls, &channel_pub_key,
+ GNUNET_ntohll (msg->message_id),
+ GNUNET_ntohll
(msg->fragment_offset),
+ fragment_cb, &fcls));
+ GNUNET_assert (fcls.n == 1);
- ASSERT (GNUNET_OK == db->message_add_flags (
- db->cls, &channel_pub_key, GNUNET_ntohll (msg->message_id),
- GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED));
+ GNUNET_assert (
+ GNUNET_OK == db->message_add_flags (db->cls, &channel_pub_key,
+ GNUNET_ntohll (msg->message_id),
+
GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED));
fcls.n = 0;
fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED;
- ASSERT (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
- GNUNET_ntohll (msg->fragment_id),
- fragment_cb, &fcls));
- ASSERT (fcls.n == 1);
+ GNUNET_assert (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
+ GNUNET_ntohll
(msg->fragment_id),
+ fragment_cb, &fcls));
+ GNUNET_assert (fcls.n == 1);
struct GNUNET_MULTICAST_MessageHeader *msg1
= GNUNET_malloc (sizeof (*msg1) + sizeof (channel_pub_key));
@@ -273,75 +267,77 @@
fcls.msg[1] = msg1;
fcls.flags[1] = GNUNET_PSYCSTORE_MESSAGE_STATE_HASH;
- ASSERT (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg1,
- fcls.flags[1]));
+ GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key,
msg1,
+ fcls.flags[1]));
uint64_t retfrags = 0;
- ASSERT (GNUNET_OK == db->message_get (db->cls, &channel_pub_key,
- GNUNET_ntohll (msg->message_id),
- &retfrags, fragment_cb, &fcls));
- ASSERT (fcls.n == 2 && retfrags == 2);
+ GNUNET_assert (GNUNET_OK == db->message_get (db->cls, &channel_pub_key,
+ GNUNET_ntohll (msg->message_id),
+ &retfrags, fragment_cb, &fcls));
+ GNUNET_assert (fcls.n == 2 && retfrags == 2);
/* Master counters */
uint64_t fragment_id = 0, message_id = 0, group_generation = 0;
- ASSERT (GNUNET_OK == db->counters_get_master (db->cls, &channel_pub_key,
- &fragment_id, &message_id,
- &group_generation)
- && fragment_id == GNUNET_ntohll (msg1->fragment_id)
- && message_id == GNUNET_ntohll (msg1->message_id)
- && group_generation == GNUNET_ntohll (msg1->group_generation));
+ GNUNET_assert (
+ GNUNET_OK == db->counters_get_master (db->cls, &channel_pub_key,
+ &fragment_id, &message_id,
+ &group_generation)
+ && fragment_id == GNUNET_ntohll (msg1->fragment_id)
+ && message_id == GNUNET_ntohll (msg1->message_id)
+ && group_generation == GNUNET_ntohll (msg1->group_generation));
-
/* Modify state */
message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 1;
- ASSERT (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key,
- message_id, 1));
+ GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls,
&channel_pub_key,
+ message_id, 1));
- ASSERT (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key, "_foo",
- C2ARG("one two three")));
+ GNUNET_assert (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key,
+ "_foo",
+ C2ARG("one two three")));
- ASSERT (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key,
- "_foo_bar", slave_key,
- sizeof (*slave_key)));
+ GNUNET_assert (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key,
+ "_foo_bar", slave_key,
+ sizeof (*slave_key)));
- ASSERT (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
- message_id));
+ GNUNET_assert (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
+ message_id));
struct StateClosure scls = { 0 };
scls.n = 0;
scls.value[0] = "one two three";
scls.value_size[0] = strlen ("one two three");
- ASSERT (GNUNET_OK == db->state_get (db->cls, &channel_pub_key, "_foo",
- state_cb, &scls));
- ASSERT (scls.n == 1);
+ GNUNET_assert (GNUNET_OK == db->state_get (db->cls, &channel_pub_key, "_foo",
+ state_cb, &scls));
+ GNUNET_assert (scls.n == 1);
scls.n = 0;
scls.value[1] = slave_key;
scls.value_size[1] = sizeof (*slave_key);
- ASSERT (GNUNET_OK == db->state_get_prefix (db->cls, &channel_pub_key, "_foo",
- state_cb, &scls));
- ASSERT (scls.n == 2);
+ GNUNET_assert (GNUNET_OK == db->state_get_prefix (db->cls, &channel_pub_key,
+ "_foo", state_cb, &scls));
+ GNUNET_assert (scls.n == 2);
scls.n = 0;
- ASSERT (GNUNET_NO == db->state_get_signed (db->cls, &channel_pub_key,
- state_cb, &scls));
- ASSERT (scls.n == 0);
+ GNUNET_assert (GNUNET_NO == db->state_get_signed (db->cls, &channel_pub_key,
+ state_cb, &scls));
+ GNUNET_assert (scls.n == 0);
- ASSERT (GNUNET_OK == db->state_update_signed (db->cls, &channel_pub_key));
+ GNUNET_assert (GNUNET_OK == db->state_update_signed (db->cls,
+ &channel_pub_key));
scls.n = 0;
- ASSERT (GNUNET_YES == db->state_get_signed (db->cls, &channel_pub_key,
- state_cb, &scls));
- ASSERT (scls.n == 2);
+ GNUNET_assert (GNUNET_YES == db->state_get_signed (db->cls, &channel_pub_key,
+ state_cb, &scls));
+ GNUNET_assert (scls.n == 2);
/* Slave counters */
uint64_t max_state_msg_id = 0;
- ASSERT (GNUNET_OK == db->counters_get_slave (db->cls, &channel_pub_key,
+ GNUNET_assert (GNUNET_OK == db->counters_get_slave (db->cls,
&channel_pub_key,
&max_state_msg_id)
&& max_state_msg_id == message_id);
@@ -353,53 +349,53 @@
scls.value[1] = "three two one";
scls.value_size[1] = strlen ("three two one");
- ASSERT (GNUNET_OK == db->state_sync_begin (db->cls, &channel_pub_key));
+ GNUNET_assert (GNUNET_OK == db->state_sync_begin (db->cls,
&channel_pub_key));
- ASSERT (GNUNET_OK == db->state_sync_set (db->cls, &channel_pub_key,
- "_sync_bar",
- scls.value[0], scls.value_size[0]));
+ GNUNET_assert (GNUNET_OK == db->state_sync_set (db->cls, &channel_pub_key,
+ "_sync_bar", scls.value[0],
+ scls.value_size[0]));
- ASSERT (GNUNET_OK == db->state_sync_set (db->cls, &channel_pub_key,
- "_sync_foo",
- scls.value[1], scls.value_size[1]));
+ GNUNET_assert (GNUNET_OK == db->state_sync_set (db->cls, &channel_pub_key,
+ "_sync_foo", scls.value[1],
+ scls.value_size[1]));
- ASSERT (GNUNET_OK == db->state_sync_end (db->cls, &channel_pub_key,
INT64_MAX - 5));
+ GNUNET_assert (GNUNET_OK == db->state_sync_end (db->cls, &channel_pub_key,
+ INT64_MAX - 5));
- ASSERT (GNUNET_NO == db->state_get_prefix (db->cls, &channel_pub_key, "_foo",
- state_cb, &scls));
- ASSERT (scls.n == 0);
+ GNUNET_assert (GNUNET_NO == db->state_get_prefix (db->cls, &channel_pub_key,
+ "_foo", state_cb, &scls));
+ GNUNET_assert (scls.n == 0);
- ASSERT (GNUNET_OK == db->state_get_prefix (db->cls, &channel_pub_key,
"_sync",
- state_cb, &scls));
- ASSERT (scls.n == 2);
+ GNUNET_assert (GNUNET_OK == db->state_get_prefix (db->cls, &channel_pub_key,
+ "_sync", state_cb, &scls));
+ GNUNET_assert (scls.n == 2);
scls.n = 0;
- ASSERT (GNUNET_OK == db->state_get_signed (db->cls, &channel_pub_key,
- state_cb, &scls));
- ASSERT (scls.n == 2);
+ GNUNET_assert (GNUNET_OK == db->state_get_signed (db->cls, &channel_pub_key,
+ state_cb, &scls));
+ GNUNET_assert (scls.n == 2);
/* Modify state after sync */
message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 6;
- ASSERT (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key,
- message_id, 3));
+ GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls,
&channel_pub_key,
+ message_id, 3));
- ASSERT (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key,
"_sync_foo",
- C2ARG("five six seven")));
+ GNUNET_assert (GNUNET_OK == db->state_modify_set (db->cls, &channel_pub_key,
+ "_sync_foo",
+ C2ARG("five six seven")));
- ASSERT (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
- message_id));
+ GNUNET_assert (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
+ message_id));
/* Reset state */
scls.n = 0;
- ASSERT (GNUNET_OK == db->state_reset (db->cls, &channel_pub_key));
- ASSERT (scls.n == 0);
+ GNUNET_assert (GNUNET_OK == db->state_reset (db->cls, &channel_pub_key));
+ GNUNET_assert (scls.n == 0);
ok = 0;
-FAILURE:
-
if (NULL != channel_key)
{
GNUNET_free (channel_key);
Modified: gnunet/src/psycstore/test_psycstore.c
===================================================================
--- gnunet/src/psycstore/test_psycstore.c 2013-09-16 13:22:08 UTC (rev
29316)
+++ gnunet/src/psycstore/test_psycstore.c 2013-09-16 13:23:12 UTC (rev
29317)
@@ -31,9 +31,6 @@
#include "gnunet_psycstore_service.h"
#include "gnunet_testing_lib.h"
-#define ASSERT(x) do { if (! (x)) { printf ("Error at %s:%d\n", __FILE__,
__LINE__); cleanup (); return; } } while (0)
-#define ASSERRT(x) do { if (! (x)) { printf ("Error at %s:%d\n", __FILE__,
__LINE__); cleanup (); return GNUNET_SYSERR; } } while (0)
-
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
#define DEBUG_SERVICE 0
@@ -161,7 +158,7 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_reset_result:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
op = GNUNET_PSYCSTORE_state_reset (h, &channel_pub_key,
&state_reset_result, cls);
@@ -191,7 +188,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
" variable %s differs\nReceived: %.*s\nExpected: %.*s\n",
name, value_size, value, val_size, val);
- ASSERRT (0);
+ GNUNET_assert (0);
return GNUNET_SYSERR;
}
}
@@ -203,7 +200,7 @@
struct StateClosure *scls = cls;
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_get_prefix_result:\t%d\n",
result);
- ASSERT (GNUNET_OK == result && 2 == scls->n);
+ GNUNET_assert (GNUNET_OK == result && 2 == scls->n);
op = GNUNET_PSYCSTORE_state_reset (h, &channel_pub_key,
&state_reset_result, cls);
@@ -215,7 +212,7 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_get_result:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
scls.n = 0;
@@ -244,7 +241,7 @@
result = 1;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "counters_get_slave:\t%d\n", result);
- ASSERT (result == 1);
+ GNUNET_assert (result == 1);
scls.n = 0;
scls.name[0] = "_bar";
@@ -261,7 +258,7 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_modify_result:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
op = GNUNET_PSYCSTORE_counters_get_slave (h, &channel_pub_key,
&counters_slave_result, cls);
@@ -274,7 +271,7 @@
struct FragmentClosure *fcls = cls;
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_sync_result:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
modifiers[0] = (struct GNUNET_ENV_Modifier) {
.oper = '=',
@@ -309,7 +306,7 @@
result = 1;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "counters_get_master:\t%d\n", result);
- ASSERT (result == 1);
+ GNUNET_assert (result == 1);
modifiers[0] = (struct GNUNET_ENV_Modifier) {
.oper = '=',
@@ -350,7 +347,7 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " fragment %llu differs\n",
GNUNET_ntohll (msg->fragment_id));
- ASSERRT (0);
+ GNUNET_assert (0);
return GNUNET_SYSERR;
}
}
@@ -362,7 +359,7 @@
struct FragmentClosure *fcls = cls;
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get:\t%d\n", result);
- ASSERT (result > 0 && fcls->n && fcls->n_expected);
+ GNUNET_assert (result > 0 && fcls->n && fcls->n_expected);
op = GNUNET_PSYCSTORE_counters_get_master (h, &channel_pub_key,
&counters_master_result, fcls);
@@ -375,7 +372,7 @@
struct FragmentClosure *fcls = cls;
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get_fragment:\t%d\n",
result);
- ASSERT (result > 0 && fcls->n && fcls->n_expected);
+ GNUNET_assert (result > 0 && fcls->n && fcls->n_expected);
fcls->n = 0;
fcls->n_expected = 3;
@@ -392,7 +389,7 @@
struct FragmentClosure *fcls = cls;
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_get:\t%d\n", result);
- ASSERT (result > 0 && fcls->n && fcls->n_expected);
+ GNUNET_assert (result > 0 && fcls->n && fcls->n_expected);
fcls->n = 1;
fcls->n_expected = 2;
@@ -411,7 +408,7 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "fragment_store:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
if ((intptr_t) cls == GNUNET_YES)
{
@@ -430,12 +427,12 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "membership_test:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
struct GNUNET_MULTICAST_MessageHeader *msg;
fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE;
fcls.msg[0] = msg = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key));
- ASSERT (msg != NULL);
+ GNUNET_assert (msg != NULL);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
msg->header.size = htons (sizeof (*msg) + sizeof (channel_pub_key));
@@ -454,8 +451,8 @@
- sizeof (msg->hop_counter)
- sizeof (msg->signature));
msg->purpose.purpose = htonl (234);
- ASSERT (GNUNET_OK == GNUNET_CRYPTO_ecc_sign (slave_key, &msg->purpose,
- &msg->signature));
+ GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_ecc_sign (slave_key, &msg->purpose,
+ &msg->signature));
op = GNUNET_PSYCSTORE_fragment_store (h, &channel_pub_key, msg,
fcls.flags[0],
&fragment_store_result, GNUNET_NO);
@@ -484,7 +481,7 @@
{
op = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "membership_store:\t%d\n", result);
- ASSERT (GNUNET_OK == result);
+ GNUNET_assert (GNUNET_OK == result);
op = GNUNET_PSYCSTORE_membership_test (h, &channel_pub_key, &slave_pub_key,
4, 1,
@@ -511,7 +508,7 @@
end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly, NULL);
h = GNUNET_PSYCSTORE_connect (cfg);
- ASSERT (NULL != h);
+ GNUNET_assert (NULL != h);
channel_key = GNUNET_CRYPTO_ecc_key_create ();
slave_key = GNUNET_CRYPTO_ecc_key_create ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29317 - in gnunet/src: namestore psycstore,
gnunet <=