diff options
Diffstat (limited to 'pidl/tests')
-rw-r--r-- | pidl/tests/Util.pm | 13 | ||||
-rwxr-xr-x | pidl/tests/ndr.pl | 3 | ||||
-rwxr-xr-x | pidl/tests/ndr_string.pl | 110 | ||||
-rwxr-xr-x | pidl/tests/parse_idl.pl | 131 | ||||
-rwxr-xr-x | pidl/tests/samba-ndr.pl | 2 | ||||
-rwxr-xr-x | pidl/tests/samba3-cli.pl | 214 | ||||
-rwxr-xr-x | pidl/tests/typelist.pl | 11 |
7 files changed, 40 insertions, 444 deletions
diff --git a/pidl/tests/Util.pm b/pidl/tests/Util.pm index ff876ec039..4ad216a6a1 100644 --- a/pidl/tests/Util.pm +++ b/pidl/tests/Util.pm @@ -13,8 +13,6 @@ use strict; use FindBin qw($RealBin); use lib "$RealBin/../lib"; -use Parse::Pidl::Samba4 qw(is_intree); - use Parse::Pidl; my $warnings = ""; undef &Parse::Pidl::warning; @@ -68,15 +66,12 @@ sub test_samba4_ndr SKIP: { - my $flags; - if (system("pkg-config --exists ndr") == 0 and !is_intree()) { - $flags = `pkg-config --libs --cflags ndr`; - } else { - skip "no samba environment available, skipping compilation", 3; - } + skip "no samba environment available, skipping compilation", 3 + if (system("pkg-config --exists ndr") != 0); my $main = " #define uint_t unsigned int +#define _GNU_SOURCE #include <stdint.h> #include <stdlib.h> #include <stdio.h> @@ -139,6 +134,8 @@ $c $cc = "cc"; } + my $flags = `pkg-config --libs --cflags ndr`; + my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags"; $cmd =~ s/\n//g; open CC, "|$cmd"; diff --git a/pidl/tests/ndr.pl b/pidl/tests/ndr.pl index 53b8cb89e3..504b7ec8de 100755 --- a/pidl/tests/ndr.pl +++ b/pidl/tests/ndr.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 47; +use Test::More tests => 46; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -480,7 +480,6 @@ $ne = ParseElement($e, undef); is($ne->{REPRESENTATION_TYPE}, "uint8"); is(align_type("hyper"), 8); -is(align_type("double"), 8); is(align_type("uint32"), 4); is(align_type("uint16"), 2); is(align_type("uint8"), 1); diff --git a/pidl/tests/ndr_string.pl b/pidl/tests/ndr_string.pl index 7b76c7b295..2f2d941665 100755 --- a/pidl/tests/ndr_string.pl +++ b/pidl/tests/ndr_string.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 6 * 8; +use Test::More tests => 3 * 8; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); @@ -55,114 +55,6 @@ test_samba4_ndr("string-ascii-pull", return 4; '); -test_samba4_ndr("string-wchar-fixed-array-01", -' - typedef struct { - uint32 l1; - [string,charset(UTF16)] uint16 str[6]; - uint32 l2; - } TestStringStruct; - - [public] void TestString([in,ref] TestStringStruct *str); -', -' - uint8_t data[] = { 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, - \'f\', 0x00, \'o\', 0x00, - \'o\', 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00 - }; - DATA_BLOB b = { data, sizeof(data) }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, - smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); - struct TestString r; - struct TestStringStruct str; - r.in.str = &str; - - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) - return 1; - - if (r.in.str == NULL) - return 2; - - if (r.in.str->l1 != 0x00000001) - return 3; - - if (strncmp(str.str, "foo", 3) != 0) - return 4; - - if (r.in.str->str[4] != 0) - return 5; - - if (r.in.str->l2 != 0x00000002) - return 6; -'); - -test_samba4_ndr("string-wchar-fixed-array-02", -' - typedef struct { - uint32 l1; - [string,charset(UTF16)] uint16 str[6]; - uint32 l2; - } TestStringStruct; - - [public] void TestString([in,ref] TestStringStruct *str); -', -' - uint8_t data[] = { 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, - \'f\', 0x00, \'o\', 0x00, - \'o\', 0x00, \'b\', 0x00, - \'a\', 0x00, \'r\', 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00 - }; - DATA_BLOB b = { data, sizeof(data) }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, - smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); - struct TestString r; - struct TestStringStruct str; - r.in.str = &str; - - /* the string terminator is wrong */ - if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) - return 1; -'); - -test_samba4_ndr("string-wchar-fixed-array-03", -' - typedef struct { - uint32 l1; - [string,charset(UTF16)] uint16 str[6]; - uint32 l2; - } TestStringStruct; - - [public] void TestString([in,ref] TestStringStruct *str); -', -' - uint8_t data[] = { 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, - \'f\', 0x00, \'o\', 0x00, - \'o\', 0x00, \'b\', 0x00, - \'a\', 0x00, \'r\', 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00 - }; - DATA_BLOB b = { data, sizeof(data) }; - struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, - smb_iconv_convenience_init(NULL, "ASCII", "UTF8", true)); - struct TestString r; - struct TestStringStruct str; - r.in.str = &str; - - /* the length 0x07 is to large */ - if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestString(ndr, NDR_IN, &r))) - return 1; -'); - SKIP: { skip "doesn't seem to work yet", 8; diff --git a/pidl/tests/parse_idl.pl b/pidl/tests/parse_idl.pl index e06526dd1e..9d43ddccc7 100755 --- a/pidl/tests/parse_idl.pl +++ b/pidl/tests/parse_idl.pl @@ -113,127 +113,52 @@ testok "cpp-quote", "cpp_quote(\"bla\")"; my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'STRUCT', - 'NAME' => 'x', - 'ELEMENTS' => [], - 'FILE' => '<foo>', - 'LINE' => 0 - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT', ELEMENTS => [] } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); $x = Parse::Pidl::IDL::parse_string("interface foo { struct x; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'STRUCT', - 'NAME' => 'x', - 'FILE' => '<foo>', - 'LINE' => 0 - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT' } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); $x = Parse::Pidl::IDL::parse_string("cpp_quote(\"foobar\")", "<quote>"); -is_deeply($x, [ { - 'TYPE' => 'CPP_QUOTE', - 'DATA' => '"foobar"', - 'FILE' => '<quote>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<quote>', 'DATA' => '"foobar"', + 'TYPE' => 'CPP_QUOTE', 'LINE' => 0 } ]); # A typedef of a struct without body $x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct x y; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'TYPEDEF', - 'NAME' => 'y', - 'DATA' => { - 'TYPE' => 'STRUCT', - 'NAME' => 'x', - 'FILE' => '<foo>', - 'LINE' => 0, - }, - 'FILE' => '<foo>', - 'LINE' => 0, - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { + TYPE => 'STRUCT', NAME => 'x' } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); # A typedef of a struct with empty body $x = Parse::Pidl::IDL::parse_string("interface foo { typedef struct {} y; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'TYPEDEF', - 'NAME' => 'y', - 'DATA' => { - 'TYPE' => 'STRUCT', - 'ELEMENTS' => [], - 'FILE' => '<foo>', - 'LINE' => 0 - }, - 'FILE' => '<foo>', - 'LINE' => 0 - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'STRUCT', ELEMENTS => [] } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); # A typedef of a bitmap with no body $x = Parse::Pidl::IDL::parse_string("interface foo { typedef bitmap x y; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'TYPEDEF', - 'NAME' => 'y', - 'DATA' => { - 'TYPE' => 'BITMAP', - 'NAME' => 'x', - 'FILE' => '<foo>', - 'LINE' => 0 - }, - 'FILE' => '<foo>', - 'LINE' => 0 - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'BITMAP', NAME => 'x' } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); # A typedef of a union with no body $x = Parse::Pidl::IDL::parse_string("interface foo { typedef union x y; }", "<foo>"); -is_deeply($x, [ { - 'TYPE' => 'INTERFACE', - 'NAME' => 'foo', - 'DATA' => [ { - 'TYPE' => 'TYPEDEF', - 'NAME' => 'y', - 'DATA' => { - 'TYPE' => 'UNION', - 'NAME' => 'x', - 'FILE' => '<foo>', - 'LINE' => 0 - }, - 'FILE' => '<foo>', - 'LINE' => 0 - } ], - 'FILE' => '<foo>', - 'LINE' => 0 -}]); +is_deeply($x, + [ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [ + { 'FILE' => '<foo>', 'LINE' => 0, 'NAME' => 'y', 'TYPE' => 'TYPEDEF', DATA => { TYPE => 'UNION', NAME => 'x' } } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); diff --git a/pidl/tests/samba-ndr.pl b/pidl/tests/samba-ndr.pl index 5c9c6afd85..cdfe0514f1 100755 --- a/pidl/tests/samba-ndr.pl +++ b/pidl/tests/samba-ndr.pl @@ -245,7 +245,7 @@ $generator->ParseStructPush({ SURROUNDING_ELEMENT => $e, ELEMENTS => [ $e ]}, "ndr", "x"); is($generator->{res}, "if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1))); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1)); } diff --git a/pidl/tests/samba3-cli.pl b/pidl/tests/samba3-cli.pl index 0d283a2d5a..27ab99dd34 100755 --- a/pidl/tests/samba3-cli.pl +++ b/pidl/tests/samba3-cli.pl @@ -30,107 +30,7 @@ my $x = new Parse::Pidl::Samba3::ClientNDR(); $fn = { NAME => "bar", ELEMENTS => [ ] }; $x->ParseFunction("foo", $fn); is($x->{res}, -"struct rpccli_bar_state { - struct bar orig; - struct bar tmp; - TALLOC_CTX *out_mem_ctx; - NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); -}; - -static void rpccli_bar_done(struct tevent_req *subreq); - -struct tevent_req *rpccli_bar_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct rpc_pipe_client *cli) -{ - struct tevent_req *req; - struct rpccli_bar_state *state; - struct tevent_req *subreq; - - req = tevent_req_create(mem_ctx, &state, - struct rpccli_bar_state); - if (req == NULL) { - return NULL; - } - state->out_mem_ctx = NULL; - state->dispatch_recv = cli->dispatch_recv; - - /* In parameters */ - - /* Out parameters */ - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(bar, &state->orig); - } - - /* make a temporary copy, that we pass to the dispatch function */ - state->tmp = state->orig; - - subreq = cli->dispatch_send(state, ev, cli, - &ndr_table_foo, - NDR_BAR, - &state->tmp); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - tevent_req_set_callback(subreq, rpccli_bar_done, req); - return req; -} - -static void rpccli_bar_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct rpccli_bar_state *state = tevent_req_data( - req, struct rpccli_bar_state); - NTSTATUS status; - TALLOC_CTX *mem_ctx; - - if (state->out_mem_ctx) { - mem_ctx = state->out_mem_ctx; - } else { - mem_ctx = state; - } - - status = state->dispatch_recv(subreq, mem_ctx); - TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - tevent_req_nterror(req, status); - return; - } - - /* Copy out parameters */ - - /* Reset temporary structure */ - ZERO_STRUCT(state->tmp); - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(bar, &state->orig); - } - - tevent_req_done(req); -} - -NTSTATUS rpccli_bar_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx) -{ - struct rpccli_bar_state *state = tevent_req_data( - req, struct rpccli_bar_state); - NTSTATUS status; - - if (tevent_req_is_nterror(req, &status)) { - tevent_req_received(req); - return status; - } - - /* Steal possbile out parameters to the callers context */ - talloc_steal(mem_ctx, state->out_mem_ctx); - - tevent_req_received(req); - return NT_STATUS_OK; -} - -NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, +"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) { \tstruct bar r; @@ -173,117 +73,7 @@ $x = new Parse::Pidl::Samba3::ClientNDR(); $fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" }; $x->ParseFunction("foo", $fn); is($x->{res}, -"struct rpccli_bar_state { - struct bar orig; - struct bar tmp; - TALLOC_CTX *out_mem_ctx; - NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); -}; - -static void rpccli_bar_done(struct tevent_req *subreq); - -struct tevent_req *rpccli_bar_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct rpc_pipe_client *cli) -{ - struct tevent_req *req; - struct rpccli_bar_state *state; - struct tevent_req *subreq; - - req = tevent_req_create(mem_ctx, &state, - struct rpccli_bar_state); - if (req == NULL) { - return NULL; - } - state->out_mem_ctx = NULL; - state->dispatch_recv = cli->dispatch_recv; - - /* In parameters */ - - /* Out parameters */ - - /* Result */ - ZERO_STRUCT(state->orig.out.result); - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_IN_DEBUG(bar, &state->orig); - } - - /* make a temporary copy, that we pass to the dispatch function */ - state->tmp = state->orig; - - subreq = cli->dispatch_send(state, ev, cli, - &ndr_table_foo, - NDR_BAR, - &state->tmp); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - tevent_req_set_callback(subreq, rpccli_bar_done, req); - return req; -} - -static void rpccli_bar_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct rpccli_bar_state *state = tevent_req_data( - req, struct rpccli_bar_state); - NTSTATUS status; - TALLOC_CTX *mem_ctx; - - if (state->out_mem_ctx) { - mem_ctx = state->out_mem_ctx; - } else { - mem_ctx = state; - } - - status = state->dispatch_recv(subreq, mem_ctx); - TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - tevent_req_nterror(req, status); - return; - } - - /* Copy out parameters */ - - /* Copy result */ - state->orig.out.result = state->tmp.out.result; - - /* Reset temporary structure */ - ZERO_STRUCT(state->tmp); - - if (DEBUGLEVEL >= 10) { - NDR_PRINT_OUT_DEBUG(bar, &state->orig); - } - - tevent_req_done(req); -} - -NTSTATUS rpccli_bar_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx, - WERROR *result) -{ - struct rpccli_bar_state *state = tevent_req_data( - req, struct rpccli_bar_state); - NTSTATUS status; - - if (tevent_req_is_nterror(req, &status)) { - tevent_req_received(req); - return status; - } - - /* Steal possbile out parameters to the callers context */ - talloc_steal(mem_ctx, state->out_mem_ctx); - - /* Return result */ - *result = state->orig.out.result; - - tevent_req_received(req); - return NT_STATUS_OK; -} - -NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, +"NTSTATUS rpccli_bar(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, WERROR *werror) { diff --git a/pidl/tests/typelist.pl b/pidl/tests/typelist.pl index e99b016487..80ee868f9d 100755 --- a/pidl/tests/typelist.pl +++ b/pidl/tests/typelist.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 56; +use Test::More tests => 54; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -21,7 +21,6 @@ is("int32", expandAlias("int32")); is("uint32_t", mapScalarType("uint32")); is("void", mapScalarType("void")); is("uint64_t", mapScalarType("hyper")); -is("double", mapScalarType("double")); my $x = { TYPE => "ENUM", NAME => "foo", EXTRADATA => 1 }; addType($x); @@ -35,12 +34,6 @@ is_deeply(getType("uint16"), { TYPE => "TYPEDEF", DATA => { NAME => "uint16", TYPE => "SCALAR" }}); -is_deeply(getType("double"), { - NAME => "double", - BASEFILE => "<builtin>", - TYPE => "TYPEDEF", - DATA => { NAME => "double", TYPE => "SCALAR" }}); - is(0, typeIs("someUnknownType", "ENUM")); is(0, typeIs("foo", "ENUM")); addType({NAME => "mytypedef", TYPE => "TYPEDEF", DATA => { TYPE => "ENUM" }}); @@ -71,7 +64,7 @@ is(0, scalar_is_reference({TYPE => "STRUCT", NAME => "echo_foobar"})); is("uint8", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {enum8bit => 1}}})); is("uint32", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {v1_enum => 1}}})); -is("uint1632", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}})); +is("uint16", enum_type_fn({TYPE => "ENUM", PARENT=>{PROPERTIES => {}}})); is("uint8", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap8bit => 1}})); is("uint16", bitmap_type_fn({TYPE => "BITMAP", PROPERTIES => {bitmap16bit => 1}})); |