diff --git a/test_brandt.c b/test_brandt.c index 9d91260..47f3711 100644 --- a/test_brandt.c +++ b/test_brandt.c @@ -149,7 +149,7 @@ expected_outcome (uint16_t i, uint16_t *rlen) { if (cur_winner >= winners) { - weprintf ("got too many winners"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "got too many winners\n"); _exit (1); } ret[cur_winner].bidder = h; @@ -168,7 +168,7 @@ bidder_start (void *arg) { uint16_t i = *(uint16_t *)arg; - weprintf ("starting bidder %d", i); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "starting bidder %d\n", i); BRANDT_bidder_start (tcase.ad[i], i, tcase.n); } @@ -179,8 +179,8 @@ transfer_message (void *arg) struct msg *m = (struct msg *)arg; struct msg_head *h = (struct msg_head *)m->buf; - weprintf ("xfer msg %d %x from %d to %d", ntohl ( - h->msg_type), arg, m->sender, m->receiver); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "xfer msg %d %p from %d to %d\n", + ntohl (h->msg_type), arg, m->sender, m->receiver); BRANDT_got_message (tcase.ad[m->receiver], m->sender, m->buf, m->buf_len); GNUNET_free (m->buf); GNUNET_free (m); @@ -194,7 +194,8 @@ cb_start (void *auction_closure) if (tcase.n != *s) { - weprintf ("start callback called from bidder"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "start callback called from bidder\n"); _exit (1); } @@ -260,29 +261,40 @@ cb_result (void *auction_closure, if (mustlen != results_len) { - weprintf ("expected result len is: %d", mustlen); - weprintf ("computed result len is: %d (by agent %d)", results_len, *s); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "expected result len is: %d\n", + mustlen); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "computed result len is: %d (by agent %d)\n", + results_len, + *s); tcase.ret = 1; goto quit; } - if (0 == results_len) + if (0 == results_len && NULL != must) { - weprintf ("expected result is: %p", must); - weprintf ("computed result is: (nil) (by agent %d)", *s); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "expected result is: %p\n", + (void *)must); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "computed result is: (nil) (by agent %d)\n", + *s); - if (NULL != must) - tcase.ret = 1; + tcase.ret = 1; } for (uint16_t i = 0; i < results_len; i++) { - weprintf ("expected result is: bidder %d got status %d with price %d", - must[i].bidder, - must[i].status, - must[i].price); - weprintf ( - "computed result is: bidder %d got status %d with price %d (by agent %d)", + GNUNET_log ( + GNUNET_ERROR_TYPE_INFO, + "expected result is: bidder %d got status %d with price %d\n", + must[i].bidder, + must[i].status, + must[i].price); + GNUNET_log ( + GNUNET_ERROR_TYPE_INFO, + "computed result is: bidder %d got status %d with price %d (by agent %d)\n", results[i].bidder, results[i].status, results[i].price, @@ -321,7 +333,7 @@ run_auction (void *arg) tcase.outcome_public); /* outcome public */ if (!tcase.ad[tcase.n]) { - weprintf ("BRANDT_new() failed."); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BRANDT_new() failed.\n"); _exit (1); } @@ -336,7 +348,7 @@ run_auction (void *arg) tcase.bids[i]); /* bid */ if (!tcase.ad[i]) { - weprintf ("BRANDT_join() failed."); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BRANDT_join() failed.\n"); tcase.ret = 1; return; } @@ -351,7 +363,8 @@ run_auction (void *arg) !tcase.ad[tcase.n]->seller_mode || /* todo: split out */ tcase.ad[i]->seller_mode) { - weprintf ("error/mismatch in basic auction data"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "error/mismatch in basic auction data\n"); tcase.ret = 1; return; } @@ -385,13 +398,16 @@ test_auction (uint16_t n, tcase.outcome_public = outcome_public; tcase.ret = 0; - weprintf ("######################################"); - weprintf ("testing %s auction with m = %d and %s outcome", - tcase.m > 0 ? "M+1ST PRICE" : "FIRST PRICE", - tcase.m, - tcase.outcome_public ? "PUBLIC" : "PRIVATE"); - /** \todo: output bids when migrating to GNUNET_log */ - weprintf ("######################################"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "######################################\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "testing %s auction with m = %d and %s outcome\n", + tcase.m > 0 ? "M+1ST PRICE" : "FIRST PRICE", + tcase.m, + tcase.outcome_public ? "PUBLIC" : "PRIVATE"); + /** \todo: output bids */ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "######################################\n"); tcase.ad = GNUNET_new_array (tcase.n + 1, struct BRANDT_Auction *); tcase.id = GNUNET_new_array (tcase.n + 1, uint16_t); for (uint16_t i = 0; i <= tcase.n; i++) @@ -405,7 +421,9 @@ test_auction (uint16_t n, BRANDT_destroy (tcase.ad[i]); if (!tcase.result_called[i]) { - weprintf ("result callback not called for bidder %d", i); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "result callback not called for bidder %d\n", + i); tcase.ret = 1; } } @@ -424,6 +442,9 @@ main (int argc, char *argv[]) int ret = 0; struct GNUNET_CRYPTO_EccDlogContext *edc; + if (GNUNET_OK != GNUNET_log_setup ("test_brandt", "WARNING", NULL)) + return 1; + edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16); BRANDT_init (edc);