1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

Adjusted debug level and test scenario.

(This used to be ctdb commit 7d87132195e603f936368da5dd4cb6754c45b721)
This commit is contained in:
Peter Somogyi 2007-01-26 16:45:51 +01:00
parent d47db1daaa
commit 952a1ba44d
2 changed files with 28 additions and 3 deletions

View File

@ -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_

View File

@ -34,6 +34,7 @@
#include <assert.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#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: