torture3: Add a test deleting a different req
authorVolker Lendecke <vl@samba.org>
Tue, 29 Apr 2014 12:27:03 +0000 (14:27 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 30 Apr 2014 15:09:59 +0000 (17:09 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Apr 30 17:09:59 CEST 2014 on sn-devel-104

source3/selftest/tests.py
source3/torture/proto.h
source3/torture/test_messaging_read.c
source3/torture/torture.c

index 7200329d3a0f1e9a0e9a9ca496171f52bd3e9025..fcf3cd58c01f9f5bb7c8a3d1fe4fe36db7fc8064 100755 (executable)
@@ -103,6 +103,7 @@ local_tests = [
     "LOCAL-CONV-AUTH-INFO",
     "LOCAL-IDMAP-TDB-COMMON",
     "LOCAL-MESSAGING-READ1",
+    "LOCAL-MESSAGING-READ2",
     "LOCAL-hex_encode_buf",
     "LOCAL-sprintf_append",
     "LOCAL-remove_duplicate_addrs2"]
index f23efa184b2b7c4a33a9899ee7ce486e82be26c2..a737ea4eacc3c75733ed0fd065dd62dc5366baab 100644 (file)
@@ -114,5 +114,6 @@ bool run_local_dbwrap_ctdb(int dummy);
 bool run_qpathinfo_bufsize(int dummy);
 bool run_bench_pthreadpool(int dummy);
 bool run_messaging_read1(int dummy);
+bool run_messaging_read2(int dummy);
 
 #endif /* __TORTURE_H__ */
index 6c8cdba724d4f25f4497dcb528eb900c6adeff66..387ebfde8784cec5d83a8fb2d4806303108623fb 100644 (file)
@@ -142,3 +142,106 @@ fail:
        TALLOC_FREE(ev);
        return retval;
 }
+
+struct msg_free_state {
+       struct tevent_req **to_free;
+};
+
+static void msg_free_done(struct tevent_req *subreq);
+
+static struct tevent_req *msg_free_send(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       struct messaging_context *msg_ctx,
+                                       uint32_t msg_type,
+                                       struct tevent_req **to_free)
+{
+       struct tevent_req *req, *subreq;
+       struct msg_free_state *state;
+
+       req = tevent_req_create(mem_ctx, &state, struct msg_free_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->to_free = to_free;
+
+       subreq = messaging_read_send(state, ev, msg_ctx, msg_type);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, msg_free_done, req);
+       return req;
+}
+
+static void msg_free_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct msg_free_state *state = tevent_req_data(
+               req, struct msg_free_state);
+       int ret;
+
+       ret = messaging_read_recv(subreq, NULL, NULL);
+       TALLOC_FREE(subreq);
+       if (tevent_req_error(req, ret)) {
+               return;
+       }
+       TALLOC_FREE(*state->to_free);
+       tevent_req_done(req);
+}
+
+bool run_messaging_read2(int dummy)
+{
+       struct tevent_context *ev = NULL;
+       struct messaging_context *msg_ctx = NULL;
+       struct tevent_req *req1 = NULL;
+       struct tevent_req *req2 = NULL;
+       unsigned count = 0;
+       NTSTATUS status;
+       bool retval = false;
+
+       ev = samba_tevent_context_init(talloc_tos());
+       if (ev == NULL) {
+               fprintf(stderr, "tevent_context_init failed\n");
+               goto fail;
+       }
+       msg_ctx = messaging_init(ev, ev);
+       if (msg_ctx == NULL) {
+               fprintf(stderr, "messaging_init failed\n");
+               goto fail;
+       }
+
+       req1 = msg_free_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY, &req2);
+       if (req1 == NULL) {
+               fprintf(stderr, "msg_count_send failed\n");
+               goto fail;
+       }
+       req2 = msg_count_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY, &count);
+       if (req1 == NULL) {
+               fprintf(stderr, "msg_count_send failed\n");
+               goto fail;
+       }
+       status = messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
+                                   MSG_SMB_NOTIFY, NULL, 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               fprintf(stderr, "messaging_send_buf failed: %s\n",
+                       nt_errstr(status));
+               goto fail;
+       }
+
+       if (!tevent_req_poll(req1, ev) != 0) {
+               fprintf(stderr, "tevent_req_poll failed\n");
+               goto fail;
+       }
+
+       if (count != 0) {
+               fprintf(stderr, "Got %u msgs, expected none\n", count);
+               goto fail;
+       }
+
+       retval = true;
+fail:
+       TALLOC_FREE(req1);
+       TALLOC_FREE(msg_ctx);
+       TALLOC_FREE(ev);
+       return retval;
+}
index 5d75bbfd29b3a4055e4e2d13b6be7878229658cc..f97119add56ad31549ecbc2779935f54922d03d5 100644 (file)
@@ -9575,6 +9575,7 @@ static struct {
        { "LOCAL-CTDB-CONN", run_ctdb_conn, 0},
        { "LOCAL-DBWRAP-WATCH1", run_dbwrap_watch1, 0 },
        { "LOCAL-MESSAGING-READ1", run_messaging_read1, 0 },
+       { "LOCAL-MESSAGING-READ2", run_messaging_read2, 0 },
        { "LOCAL-BASE64", run_local_base64, 0},
        { "LOCAL-RBTREE", run_local_rbtree, 0},
        { "LOCAL-MEMCACHE", run_local_memcache, 0},