Changeset 745 for trunk/server/pidl/tests/samba3-cli.pl
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 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/pidl/tests/samba3-cli.pl
r414 r745 5 5 use warnings; 6 6 7 use Test::More tests => 9;7 use Test::More tests => 8; 8 8 use FindBin qw($RealBin); 9 9 use lib "$RealBin"; 10 10 use Util; 11 11 use Parse::Pidl::Util qw(MyDumper); 12 use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument);12 use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction); 13 13 use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv); 14 14 … … 32 32 is($x->{res}, 33 33 "struct rpccli_bar_state { 34 struct bar orig;35 struct bar tmp;36 34 TALLOC_CTX *out_mem_ctx; 37 NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);38 35 }; 39 36 … … 54 51 } 55 52 state->out_mem_ctx = NULL; 56 state->dispatch_recv = cli->dispatch_recv; 57 58 /* In parameters */ 59 60 /* Out parameters */ 61 62 if (DEBUGLEVEL >= 10) { 63 NDR_PRINT_IN_DEBUG(bar, &state->orig); 64 } 65 66 /* make a temporary copy, that we pass to the dispatch function */ 67 state->tmp = state->orig; 68 69 subreq = cli->dispatch_send(state, ev, cli, 70 &ndr_table_foo, 71 NDR_BAR, 72 &state->tmp); 53 54 subreq = dcerpc_bar_send(state, 55 ev, 56 cli->binding_handle); 73 57 if (tevent_req_nomem(subreq, req)) { 74 58 return tevent_req_post(req, ev); … … 93 77 } 94 78 95 status = state->dispatch_recv(subreq, mem_ctx); 79 status = dcerpc_bar_recv(subreq, 80 mem_ctx); 96 81 TALLOC_FREE(subreq); 97 82 if (!NT_STATUS_IS_OK(status)) { … … 100 85 } 101 86 102 /* Copy out parameters */103 104 /* Reset temporary structure */105 ZERO_STRUCT(state->tmp);106 107 if (DEBUGLEVEL >= 10) {108 NDR_PRINT_OUT_DEBUG(bar, &state->orig);109 }110 111 87 tevent_req_done(req); 112 88 } … … 124 100 } 125 101 126 /* Steal poss bile out parameters to the callers context */102 /* Steal possible out parameters to the callers context */ 127 103 talloc_steal(mem_ctx, state->out_mem_ctx); 128 104 … … 134 110 TALLOC_CTX *mem_ctx) 135 111 { 136 \tstruct bar r; 137 \tNTSTATUS status; 138 139 \t/* In parameters */ 140 141 \tif (DEBUGLEVEL >= 10) { 142 \t\tNDR_PRINT_IN_DEBUG(bar, &r); 143 \t} 144 145 status = cli->dispatch(cli, 146 mem_ctx, 147 &ndr_table_foo, 148 NDR_BAR, 149 &r); 150 151 \tif (!NT_STATUS_IS_OK(status)) { 152 \t\treturn status; 153 \t} 154 155 \tif (DEBUGLEVEL >= 10) { 156 \t\tNDR_PRINT_OUT_DEBUG(bar, &r); 157 \t} 158 159 \tif (NT_STATUS_IS_ERR(status)) { 160 \t\treturn status; 161 \t} 162 163 \t/* Return variables */ 164 165 \t/* Return result */ 166 \treturn NT_STATUS_OK; 112 NTSTATUS status; 113 114 status = dcerpc_bar(cli->binding_handle, 115 mem_ctx); 116 if (!NT_STATUS_IS_OK(status)) { 117 return status; 118 } 119 120 /* Return result */ 121 return NT_STATUS_OK; 167 122 } 168 123 … … 175 130 is($x->{res}, 176 131 "struct rpccli_bar_state { 177 struct bar orig;178 struct bar tmp;179 132 TALLOC_CTX *out_mem_ctx; 180 NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);133 WERROR result; 181 134 }; 182 135 … … 197 150 } 198 151 state->out_mem_ctx = NULL; 199 state->dispatch_recv = cli->dispatch_recv; 200 201 /* In parameters */ 202 203 /* Out parameters */ 204 205 /* Result */ 206 ZERO_STRUCT(state->orig.out.result); 207 208 if (DEBUGLEVEL >= 10) { 209 NDR_PRINT_IN_DEBUG(bar, &state->orig); 210 } 211 212 /* make a temporary copy, that we pass to the dispatch function */ 213 state->tmp = state->orig; 214 215 subreq = cli->dispatch_send(state, ev, cli, 216 &ndr_table_foo, 217 NDR_BAR, 218 &state->tmp); 152 153 subreq = dcerpc_bar_send(state, 154 ev, 155 cli->binding_handle); 219 156 if (tevent_req_nomem(subreq, req)) { 220 157 return tevent_req_post(req, ev); … … 239 176 } 240 177 241 status = state->dispatch_recv(subreq, mem_ctx); 178 status = dcerpc_bar_recv(subreq, 179 mem_ctx, 180 &state->result); 242 181 TALLOC_FREE(subreq); 243 182 if (!NT_STATUS_IS_OK(status)) { 244 183 tevent_req_nterror(req, status); 245 184 return; 246 }247 248 /* Copy out parameters */249 250 /* Copy result */251 state->orig.out.result = state->tmp.out.result;252 253 /* Reset temporary structure */254 ZERO_STRUCT(state->tmp);255 256 if (DEBUGLEVEL >= 10) {257 NDR_PRINT_OUT_DEBUG(bar, &state->orig);258 185 } 259 186 … … 274 201 } 275 202 276 /* Steal poss bile out parameters to the callers context */203 /* Steal possible out parameters to the callers context */ 277 204 talloc_steal(mem_ctx, state->out_mem_ctx); 278 205 279 206 /* Return result */ 280 *result = state-> orig.out.result;207 *result = state->result; 281 208 282 209 tevent_req_received(req); … … 288 215 WERROR *werror) 289 216 { 290 \tstruct bar r; 291 \tNTSTATUS status; 292 293 \t/* In parameters */ 294 295 \tif (DEBUGLEVEL >= 10) { 296 \t\tNDR_PRINT_IN_DEBUG(bar, &r); 297 \t} 298 299 status = cli->dispatch(cli, 300 mem_ctx, 301 &ndr_table_foo, 302 NDR_BAR, 303 &r); 304 305 \tif (!NT_STATUS_IS_OK(status)) { 306 \t\treturn status; 307 \t} 308 309 \tif (DEBUGLEVEL >= 10) { 310 \t\tNDR_PRINT_OUT_DEBUG(bar, &r); 311 \t} 312 313 \tif (NT_STATUS_IS_ERR(status)) { 314 \t\treturn status; 315 \t} 316 317 \t/* Return variables */ 318 319 \t/* Return result */ 320 \tif (werror) { 321 \t\t*werror = r.out.result; 322 \t} 323 324 \treturn werror_to_ntstatus(r.out.result); 217 WERROR result; 218 NTSTATUS status; 219 220 status = dcerpc_bar(cli->binding_handle, 221 mem_ctx, 222 &result); 223 if (!NT_STATUS_IS_OK(status)) { 224 return status; 225 } 226 227 /* Return result */ 228 if (werror) { 229 *werror = result; 230 } 231 232 return werror_to_ntstatus(result); 325 233 } 326 234 327 235 "); 328 236 329 $x = new Parse::Pidl::Samba3::ClientNDR();330 331 $fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };332 my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },333 LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};334 335 $x->ParseOutputArgument($fn, $e);336 is($x->{res}, "memcpy(foo, r.out.foo, (mysize) * sizeof(*foo));\n");
Note:
See TracChangeset
for help on using the changeset viewer.