Rev 56: Adjusted debug level and test scenario. in
http://samba.org/~tridge/psomogyi/
psomogyi at gamax.hu
psomogyi at gamax.hu
Fri Jan 26 15:45:51 GMT 2007
------------------------------------------------------------
revno: 56
revision-id: psomogyi at gamax.hu-20070126154551-wtp1ufo5kfytcq74
parent: psomogyi at gamax.hu-20070125175747-i22qqqgoh97f7i90
committer: Peter Somogyi <psomogyi at gamax.hu>
branch nick: ctdb
timestamp: Fri 2007-01-26 16:45:51 +0100
message:
Adjusted debug level and test scenario.
modified:
include/includes.h includes.h-20061117234101-o3qt14umlg9en8z0-17
tests/ibwrapper_test.c ibwrapper_test.c-20061214171730-h11a2z5ed6pt66hj-1
=== modified file 'include/includes.h'
--- a/include/includes.h 2006-11-28 09:48:34 +0000
+++ b/include/includes.h 2007-01-26 15:45:51 +0000
@@ -12,7 +12,9 @@
#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_
=== modified file 'tests/ibwrapper_test.c'
--- a/tests/ibwrapper_test.c 2007-01-25 17:57:47 +0000
+++ b/tests/ibwrapper_test.c 2007-01-26 15:45:51 +0000
@@ -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 @@
int kill_me;
struct ibw_ctx *ibwctx;
+
+ struct timeval start_time, end_time;
};
struct ibwtest_conn {
@@ -183,6 +186,10 @@
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 @@
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 @@
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 @@
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 @@
ibwtest_usage(tcx, argv[0]);
goto cleanup;
}
+ nmsg = tcx->nmsg;
ev = event_context_init(NULL);
assert(ev);
@@ -445,6 +457,17 @@
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:
More information about the samba-cvs
mailing list