Changeset 740 for vendor/current/pidl/tests
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/pidl/tests
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/pidl/tests/Util.pm
r414 r740 77 77 78 78 my $main = " 79 #define uint_t unsigned int80 79 #include <stdint.h> 81 80 #include <stdlib.h> -
vendor/current/pidl/tests/ndr.pl
r414 r740 23 23 'LINE' => 42 }; 24 24 25 is_deeply(GetElementLevelTable($e, "unique" ), [25 is_deeply(GetElementLevelTable($e, "unique", 0), [ 26 26 { 27 27 'IS_DEFERRED' => 0, … … 34 34 ]); 35 35 36 my $ne = ParseElement($e, "unique" );36 my $ne = ParseElement($e, "unique", 0); 37 37 is($ne->{ORIGINAL}, $e); 38 38 is($ne->{NAME}, "v"); … … 61 61 'LINE' => 42 }; 62 62 63 is_deeply(GetElementLevelTable($e, "unique" ), [63 is_deeply(GetElementLevelTable($e, "unique", 0), [ 64 64 { 65 65 LEVEL_INDEX => 0, … … 91 91 'LINE' => 42 }; 92 92 93 is_deeply(GetElementLevelTable($e, "unique" ), [93 is_deeply(GetElementLevelTable($e, "unique", 0), [ 94 94 { 95 95 LEVEL_INDEX => 0, … … 129 129 'LINE' => 42 }; 130 130 131 is_deeply(GetElementLevelTable($e, "unique" ), [131 is_deeply(GetElementLevelTable($e, "unique", 0), [ 132 132 { 133 133 LEVEL_INDEX => 0, … … 159 159 'LINE' => 42 }; 160 160 161 is_deeply(GetElementLevelTable($e, "unique" ), [161 is_deeply(GetElementLevelTable($e, "unique", 0), [ 162 162 { 163 163 LEVEL_INDEX => 0, … … 205 205 'LINE' => 42 }; 206 206 207 is_deeply(GetElementLevelTable($e, "ref" ), [207 is_deeply(GetElementLevelTable($e, "ref", 0), [ 208 208 { 209 209 LEVEL_INDEX => 0, … … 251 251 'LINE' => 42 }; 252 252 253 is_deeply(GetElementLevelTable($e, "unique" ), [253 is_deeply(GetElementLevelTable($e, "unique", 0), [ 254 254 { 255 255 LEVEL_INDEX => 0, … … 281 281 'LINE' => 42 }; 282 282 283 is_deeply(GetElementLevelTable($e, "unique" ), [283 is_deeply(GetElementLevelTable($e, "unique", 0), [ 284 284 { 285 285 LEVEL_INDEX => 0, … … 327 327 'LINE' => 42 }; 328 328 329 is_deeply(GetElementLevelTable($e, "unique" ), [329 is_deeply(GetElementLevelTable($e, "unique", 0), [ 330 330 { 331 331 LEVEL_INDEX => 0, … … 373 373 'LINE' => 42 }; 374 374 375 is_deeply(GetElementLevelTable($e, "ref" ), [375 is_deeply(GetElementLevelTable($e, "ref", 0), [ 376 376 { 377 377 LEVEL_INDEX => 0, … … 419 419 'LINE' => 42 }; 420 420 421 is_deeply(GetElementLevelTable($e, "ref" ), [421 is_deeply(GetElementLevelTable($e, "ref", 0), [ 422 422 { 423 423 LEVEL_INDEX => 0, … … 464 464 'LINE' => 42 }; 465 465 466 $ne = ParseElement($e, undef );466 $ne = ParseElement($e, undef, 0); 467 467 is($ne->{REPRESENTATION_TYPE}, "bar"); 468 468 … … 477 477 'LINE' => 42 }; 478 478 479 $ne = ParseElement($e, undef );479 $ne = ParseElement($e, undef, 0); 480 480 is($ne->{REPRESENTATION_TYPE}, "uint8"); 481 481 … … 522 522 ALIGN => undef 523 523 }; 524 is_deeply(ParseType($t->{ORIGINAL}, "ref" ), $t);524 is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t); 525 525 526 526 $t = { … … 531 531 PROPERTIES => undef, 532 532 HAS_DEFAULT => 0, 533 IS_MS_UNION => 0, 533 534 ORIGINAL => { 534 535 TYPE => "UNION", 535 536 NAME => "foo" 536 } 537 }, 538 ALIGN => undef 537 539 }; 538 is_deeply(ParseType($t->{ORIGINAL}, "ref" ), $t);540 is_deeply(ParseType($t->{ORIGINAL}, "ref", 0), $t); 539 541 540 542 ok(not can_contain_deferred("uint32")); … … 553 555 ELEMENTS => [ { TYPE => "someunknowntype" } ]})); 554 556 # Make sure the elements for a enum without body aren't filled in 555 ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref" )->{ELEMENTS}));557 ok(not defined(ParseType({TYPE => "ENUM", NAME => "foo" }, "ref", 0)->{ELEMENTS})); 556 558 # Make sure the elements for a bitmap without body aren't filled in 557 ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref" )->{ELEMENTS}));559 ok(not defined(ParseType({TYPE => "BITMAP", NAME => "foo" }, "ref", 0)->{ELEMENTS})); 558 560 # Make sure the elements for a union without body aren't filled in 559 ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref" )->{ELEMENTS}));561 ok(not defined(ParseType({TYPE => "UNION", NAME => "foo" }, "ref", 0)->{ELEMENTS})); -
vendor/current/pidl/tests/ndr_string.pl
r414 r740 15 15 uint8_t data[] = { 0x00, 0x00, 0x00, 0x00 }; 16 16 DATA_BLOB b = { data, 4 }; 17 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 18 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 17 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 19 18 struct TestString r; 20 19 r.in.data = NULL; … … 38 37 \'f\', \'o\', \'o\', 0 }; 39 38 DATA_BLOB b = { data, 8 }; 40 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 41 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 39 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 42 40 struct TestString r; 43 41 r.in.data = NULL; … … 75 73 }; 76 74 DATA_BLOB b = { data, sizeof(data) }; 77 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 78 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 75 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 79 76 struct TestString r; 80 77 struct TestStringStruct str; … … 121 118 }; 122 119 DATA_BLOB b = { data, sizeof(data) }; 123 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 124 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 120 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 125 121 struct TestString r; 126 122 struct TestStringStruct str; … … 153 149 }; 154 150 DATA_BLOB b = { data, sizeof(data) }; 155 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 156 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 151 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 157 152 struct TestString r; 158 153 struct TestStringStruct str; … … 175 170 \'f\', \'o\', \'o\', 0 }; 176 171 DATA_BLOB b = { data, 8 }; 177 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, 178 smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); 172 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL); 179 173 struct TestString r; 180 174 char *str = NULL; -
vendor/current/pidl/tests/parse_idl.pl
r414 r740 159 159 'TYPE' => 'TYPEDEF', 160 160 'NAME' => 'y', 161 'POINTERS' => 0, 161 162 'DATA' => { 162 163 'TYPE' => 'STRUCT', … … 181 182 'TYPE' => 'TYPEDEF', 182 183 'NAME' => 'y', 184 'POINTERS' => 0, 183 185 'DATA' => { 184 186 'TYPE' => 'STRUCT', … … 203 205 'TYPE' => 'TYPEDEF', 204 206 'NAME' => 'y', 207 'POINTERS' => 0, 205 208 'DATA' => { 206 209 'TYPE' => 'BITMAP', … … 226 229 'TYPE' => 'TYPEDEF', 227 230 'NAME' => 'y', 231 'POINTERS' => 0, 228 232 'DATA' => { 229 233 'TYPE' => 'UNION', -
vendor/current/pidl/tests/samba-ndr.pl
r414 r740 224 224 is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { 225 225 NDR_CHECK(ndr_push_align(ndr, 4)); 226 NDR_CHECK(ndr_push_trailer_align(ndr, 4)); 226 227 } 227 228 if (ndr_flags & NDR_BUFFERS) { … … 249 250 NDR_CHECK(ndr_push_align(ndr, 4)); 250 251 NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1)); 252 NDR_CHECK(ndr_push_trailer_align(ndr, 4)); 251 253 } 252 254 if (ndr_flags & NDR_BUFFERS) { -
vendor/current/pidl/tests/samba3-cli.pl
r414 r740 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.