summaryrefslogtreecommitdiff
path: root/source4/torture/local/messaging.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/local/messaging.c')
-rw-r--r--source4/torture/local/messaging.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index 572ace0448..38d3056f6e 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -56,7 +56,7 @@ static void exit_message(struct messaging_context *msg, void *private,
/*
test ping speed
*/
-static void test_ping_speed(struct torture_context *torture)
+static BOOL test_ping_speed(struct torture_context *torture, const void *_data)
{
struct event_context *ev;
struct messaging_context *msg_client_ctx;
@@ -66,36 +66,33 @@ static void test_ping_speed(struct torture_context *torture)
struct timeval tv;
int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
uint32_t msg_ping, msg_exit;
- struct torture_test *test = torture_test(torture, "ping_speed", "ping speed");
lp_set_cmdline("lock dir", "lockdir.tmp");
- ev = event_context_init(test);
+ ev = event_context_init(torture);
- msg_server_ctx = messaging_init(test, 1, ev);
+ msg_server_ctx = messaging_init(torture, 1, ev);
if (!msg_server_ctx) {
- torture_fail(test, "Failed to init ping messaging context");
- talloc_free(test);
- return;
+ torture_fail(torture, "Failed to init ping messaging context");
+ return False;
}
messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping);
- messaging_register_tmp(msg_server_ctx, test, exit_message, &msg_exit);
+ messaging_register_tmp(msg_server_ctx, torture, exit_message, &msg_exit);
- msg_client_ctx = messaging_init(test, 2, ev);
+ msg_client_ctx = messaging_init(torture, 2, ev);
if (!msg_client_ctx) {
- torture_fail(test, "msg_client_ctx messaging_init() failed");
- talloc_free(test);
- return;
+ torture_fail(torture, "msg_client_ctx messaging_init() failed");
+ return False;
}
messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong);
tv = timeval_current();
- torture_comment(test, "Sending pings for %d seconds", timelimit);
+ torture_comment(torture, "Sending pings for %d seconds", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
DATA_BLOB data;
NTSTATUS status1, status2;
@@ -107,13 +104,13 @@ static void test_ping_speed(struct torture_context *torture)
status2 = messaging_send(msg_client_ctx, 1, msg_ping, NULL);
if (!NT_STATUS_IS_OK(status1)) {
- torture_fail(test, "msg1 failed - %s", nt_errstr(status1));
+ torture_fail(torture, "msg1 failed - %s", nt_errstr(status1));
} else {
ping_count++;
}
if (!NT_STATUS_IS_OK(status2)) {
- torture_fail(test, "msg2 failed - %s", nt_errstr(status2));
+ torture_fail(torture, "msg2 failed - %s", nt_errstr(status2));
} else {
ping_count++;
}
@@ -123,31 +120,34 @@ static void test_ping_speed(struct torture_context *torture)
}
}
- torture_comment(test, "waiting for %d remaining replies (done %d)",
+ torture_comment(torture, "waiting for %d remaining replies (done %d)",
ping_count - pong_count, pong_count);
while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
event_loop_once(ev);
}
- torture_comment(test, "sending exit");
+ torture_comment(torture, "sending exit");
messaging_send(msg_client_ctx, 1, msg_exit, NULL);
if (ping_count != pong_count) {
- torture_fail(test, "ping test failed! received %d, sent %d",
+ torture_fail(torture, "ping test failed! received %d, sent %d",
pong_count, ping_count);
}
- torture_comment(test, "ping rate of %.0f messages/sec",
+ torture_comment(torture, "ping rate of %.0f messages/sec",
(ping_count+pong_count)/timeval_elapsed(&tv));
talloc_free(msg_client_ctx);
talloc_free(msg_server_ctx);
talloc_free(ev);
+
+ return True;
}
BOOL torture_local_messaging(struct torture_context *torture)
{
- test_ping_speed(torture);
- return torture_result(torture);
+ struct torture_suite *s = torture_suite_create(torture, "LOCAL-MESSAGING");
+ torture_suite_add_simple_tcase(s, "ping_speed", test_ping_speed, NULL);
+ return torture_run_suite(torture, s);
}