Changeset 745 for trunk/server/source4/lib/messaging/tests
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/lib/messaging/tests/irpc.c
r414 r745 24 24 #include "lib/messaging/irpc.h" 25 25 #include "librpc/gen_ndr/ndr_echo.h" 26 #include "librpc/gen_ndr/ndr_echo_c.h" 26 27 #include "torture/torture.h" 27 28 #include "cluster/cluster.h" … … 58 59 { 59 60 struct irpc_message *irpc = talloc_get_type(private_data, struct irpc_message); 60 struct echo_EchoData *r = irpc->data;61 r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len);61 struct echo_EchoData *r = (struct echo_EchoData *)irpc->data; 62 r->out.out_data = (uint8_t *)talloc_memdup(r, r->in.in_data, r->in.len); 62 63 if (r->out.out_data == NULL) { 63 64 irpc_send_reply(irpc, NT_STATUS_NO_MEMORY); … … 89 90 const struct irpc_test_data *data = (const struct irpc_test_data *)_data; 90 91 uint32_t value = *(const uint32_t *)_value; 92 struct dcerpc_binding_handle *irpc_handle; 93 94 irpc_handle = irpc_binding_handle(test, data->msg_ctx1, 95 cluster_id(0, MSG_ID2), 96 &ndr_table_rpcecho); 97 torture_assert(test, irpc_handle, "no memory"); 91 98 92 99 /* make the call */ … … 94 101 95 102 test_debug = true; 96 status = IRPC_CALL(data->msg_ctx1, cluster_id(0, MSG_ID2), 97 rpcecho, ECHO_ADDONE, &r, test); 103 status = dcerpc_echo_AddOne_r(irpc_handle, test, &r); 98 104 test_debug = false; 99 105 torture_assert_ntstatus_ok(test, status, "AddOne failed"); … … 118 124 const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data; 119 125 TALLOC_CTX *mem_ctx = tctx; 126 struct dcerpc_binding_handle *irpc_handle; 127 128 irpc_handle = irpc_binding_handle(mem_ctx, data->msg_ctx1, 129 cluster_id(0, MSG_ID2), 130 &ndr_table_rpcecho); 131 torture_assert(tctx, irpc_handle, "no memory"); 120 132 121 133 /* make the call */ … … 123 135 r.in.len = strlen((char *)r.in.in_data); 124 136 125 status = IRPC_CALL(data->msg_ctx1, cluster_id(0, MSG_ID2), 126 rpcecho, ECHO_ECHODATA, &r, 127 mem_ctx); 137 status = dcerpc_echo_EchoData_r(irpc_handle, mem_ctx, &r); 128 138 torture_assert_ntstatus_ok(tctx, status, "EchoData failed"); 129 139 … … 142 152 } 143 153 144 145 static void irpc_callback(struct irpc_request *irpc) 146 { 147 struct echo_AddOne *r = (struct echo_AddOne *)irpc->r; 148 int *pong_count = (int *)irpc->async.private_data; 149 NTSTATUS status = irpc_call_recv(irpc); 154 struct irpc_callback_state { 155 struct echo_AddOne r; 156 int *pong_count; 157 }; 158 159 static void irpc_callback(struct tevent_req *subreq) 160 { 161 struct irpc_callback_state *s = 162 tevent_req_callback_data(subreq, 163 struct irpc_callback_state); 164 NTSTATUS status; 165 166 status = dcerpc_echo_AddOne_r_recv(subreq, s); 167 TALLOC_FREE(subreq); 150 168 if (!NT_STATUS_IS_OK(status)) { 151 169 printf("irpc call failed - %s\n", nt_errstr(status)); 152 170 } 153 if (* r->out.out_data != r->in.in_data + 1) {171 if (*s->r.out.out_data != s->r.in.in_data + 1) { 154 172 printf("AddOne wrong answer - %u + 1 = %u should be %u\n", 155 r->in.in_data, *r->out.out_data, r->in.in_data+1);156 } 157 (* pong_count)++;173 s->r.in.in_data, *s->r.out.out_data, s->r.in.in_data+1); 174 } 175 (*s->pong_count)++; 158 176 } 159 177 … … 169 187 const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data; 170 188 struct timeval tv; 171 struct echo_AddOne r;172 189 TALLOC_CTX *mem_ctx = tctx; 173 190 int timelimit = torture_setting_int(tctx, "timelimit", 10); 191 struct dcerpc_binding_handle *irpc_handle; 192 193 irpc_handle = irpc_binding_handle(mem_ctx, data->msg_ctx1, 194 cluster_id(0, MSG_ID2), 195 &ndr_table_rpcecho); 196 torture_assert(tctx, irpc_handle, "no memory"); 174 197 175 198 tv = timeval_current(); 176 177 r.in.in_data = 0;178 199 179 200 torture_comment(tctx, "Sending echo for %d seconds\n", timelimit); 180 201 while (timeval_elapsed(&tv) < timelimit) { 181 struct irpc_request *irpc; 182 183 irpc = IRPC_CALL_SEND(data->msg_ctx1, cluster_id(0, MSG_ID2), 184 rpcecho, ECHO_ADDONE, 185 &r, mem_ctx); 186 torture_assert(tctx, irpc != NULL, "AddOne send failed"); 187 188 irpc->async.fn = irpc_callback; 189 irpc->async.private_data = &pong_count; 202 struct tevent_req *subreq; 203 struct irpc_callback_state *s; 204 205 s = talloc_zero(mem_ctx, struct irpc_callback_state); 206 torture_assert(tctx, s != NULL, "no mem"); 207 208 s->pong_count = &pong_count; 209 210 subreq = dcerpc_echo_AddOne_r_send(mem_ctx, 211 tctx->ev, 212 irpc_handle, 213 &s->r); 214 torture_assert(tctx, subreq != NULL, "AddOne send failed"); 215 216 tevent_req_set_callback(subreq, irpc_callback, s); 190 217 191 218 ping_count++; … … 216 243 *_data = data = talloc(tctx, struct irpc_test_data); 217 244 218 lp _set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp");245 lpcfg_set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp"); 219 246 220 247 data->ev = tctx->ev; 221 248 torture_assert(tctx, data->msg_ctx1 = 222 249 messaging_init(tctx, 223 lp _messaging_path(tctx, tctx->lp_ctx),250 lpcfg_messaging_path(tctx, tctx->lp_ctx), 224 251 cluster_id(0, MSG_ID1), 225 lp_iconv_convenience(tctx->lp_ctx),226 252 data->ev), 227 253 "Failed to init first messaging context"); … … 229 255 torture_assert(tctx, data->msg_ctx2 = 230 256 messaging_init(tctx, 231 lp _messaging_path(tctx, tctx->lp_ctx),257 lpcfg_messaging_path(tctx, tctx->lp_ctx), 232 258 cluster_id(0, MSG_ID2), 233 lp_iconv_convenience(tctx->lp_ctx),234 259 data->ev), 235 260 "Failed to init second messaging context"); … … 247 272 struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) 248 273 { 249 struct torture_suite *suite = torture_suite_create(mem_ctx, " IRPC");274 struct torture_suite *suite = torture_suite_create(mem_ctx, "irpc"); 250 275 struct torture_tcase *tcase = torture_suite_add_tcase(suite, "irpc"); 251 276 int i; -
trunk/server/source4/lib/messaging/tests/messaging.c
r414 r745 68 68 uint32_t msg_ping, msg_exit; 69 69 70 lp _set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp");70 lpcfg_set_cmdline(tctx->lp_ctx, "pid directory", "piddir.tmp"); 71 71 72 72 ev = tctx->ev; 73 73 74 74 msg_server_ctx = messaging_init(tctx, 75 lp_messaging_path(tctx, tctx->lp_ctx), 76 cluster_id(0, 1), 77 lp_iconv_convenience(tctx->lp_ctx), 75 lpcfg_messaging_path(tctx, tctx->lp_ctx), cluster_id(0, 1), 78 76 ev); 79 77 … … 84 82 85 83 msg_client_ctx = messaging_init(tctx, 86 lp _messaging_path(tctx, tctx->lp_ctx),84 lpcfg_messaging_path(tctx, tctx->lp_ctx), 87 85 cluster_id(0, 2), 88 lp_iconv_convenience(tctx->lp_ctx),89 86 ev); 90 87 … … 140 137 struct torture_suite *torture_local_messaging(TALLOC_CTX *mem_ctx) 141 138 { 142 struct torture_suite *s = torture_suite_create(mem_ctx, " MESSAGING");139 struct torture_suite *s = torture_suite_create(mem_ctx, "messaging"); 143 140 torture_suite_add_simple_test(s, "ping_speed", test_ping_speed); 144 141 return s;
Note:
See TracChangeset
for help on using the changeset viewer.