From: Peter Somogyi Date: Fri, 26 Jan 2007 15:45:51 +0000 (+0100) Subject: Adjusted debug level and test scenario. X-Git-Tag: tevent-0.9.20~348^2~2975^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=952a1ba44d02a77ba150bc6bd11b669d4b6d4609;p=thirdparty%2Fsamba.git Adjusted debug level and test scenario. (This used to be ctdb commit 7d87132195e603f936368da5dd4cb6754c45b721) --- diff --git a/ctdb/include/includes.h b/ctdb/include/includes.h index b160e1f739c..2bd527d23df 100644 --- a/ctdb/include/includes.h +++ b/ctdb/include/includes.h @@ -12,7 +12,9 @@ typedef bool BOOL; #define True 1 #define False 0 -#define DEBUG(lvl, x) printf x +#define LogLevel 10 + +#define DEBUG(lvl, x) if ((lvl) <= LogLevel) (printf x) #define _PUBLIC_ diff --git a/ctdb/tests/ibwrapper_test.c b/ctdb/tests/ibwrapper_test.c index ba02d3c6f86..79324f5c4bd 100644 --- a/ctdb/tests/ibwrapper_test.c +++ b/ctdb/tests/ibwrapper_test.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "includes.h" #include "lib/events/events.h" @@ -58,6 +59,8 @@ struct ibwtest_ctx { int kill_me; struct ibw_ctx *ibwctx; + + struct timeval start_time, end_time; }; struct ibwtest_conn { @@ -183,6 +186,10 @@ int ibwtest_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn) DEBUG(10, ("test IBWC_INIT\n")); break; case IBWC_CONNECTED: + if (gettimeofday(&tcx->start_time, NULL)) { + DEBUG(0, ("gettimeofday error %d", errno)); + return -1; + } ibwtest_send_id(conn); break; case IBWC_DISCONNECTED: @@ -374,9 +381,10 @@ void ibwtest_usage(struct ibwtest_ctx *tcx, char *name) int main(int argc, char *argv[]) { int rc, op; - int result = 1; + int result = 1, nmsg; struct event_context *ev = NULL; struct ibwtest_ctx *tcx = NULL; + float usec; tcx = talloc_zero(NULL, struct ibwtest_ctx); memset(tcx, 0, sizeof(struct ibwtest_ctx)); @@ -387,7 +395,7 @@ int main(int argc, char *argv[]) testctx = tcx; signal(SIGQUIT, ibwtest_sigquit_handler); - while ((op=getopt(argc, argv, "i:o:d:m:st:")) != -1) { + while ((op=getopt(argc, argv, "i:o:d:m:st:n:")) != -1) { switch (op) { case 'i': tcx->id = talloc_strdup(tcx, optarg); @@ -408,6 +416,9 @@ int main(int argc, char *argv[]) case 't': tcx->nsec = (unsigned int)atoi(optarg); break; + case 'n': + tcx->nmsg = atoi(optarg); + break; default: fprintf(stderr, "ERROR: unknown option -%c\n", (char)op); ibwtest_usage(tcx, argv[0]); @@ -418,6 +429,7 @@ int main(int argc, char *argv[]) ibwtest_usage(tcx, argv[0]); goto cleanup; } + nmsg = tcx->nmsg; ev = event_context_init(NULL); assert(ev); @@ -445,6 +457,17 @@ int main(int argc, char *argv[]) event_loop_once(ev); } + if (!tcx->is_server && nmsg!=0) { + if (gettimeofday(&tcx->end_time, NULL)) { + DEBUG(0, ("gettimeofday error %d", errno)); + goto cleanup; + } + usec = (tcx->end_time.tv_sec - tcx->start_time.tv_sec) * 1000000 + + (tcx->end_time.tv_usec - tcx->start_time.tv_usec); + printf("usec: %f, nmsg: %d, usec/nmsg: %f\n", + usec, nmsg, usec/(float)nmsg); + } + result = 0; /* everything OK */ cleanup: