2 # (C) 2007 Jelmer Vernooij <jelmer@samba.org>
3 # Published under the GNU General Public License
7 use Test
::More tests
=> 9;
8 use FindBin
qw($RealBin);
11 use Parse::Pidl::Util qw(MyDumper);
12 use Parse
::Pidl
::Samba3
::ClientNDR
qw(ParseFunction ParseOutputArgument);
13 use Parse
::Pidl
::Samba4
::Header
qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
15 # Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
16 my $fn = { ELEMENTS
=> [ { DIRECTION
=> ["in"], NAME
=> "foo" } ] };
17 is_deeply
({ "foo" => "r.in.foo" }, GenerateFunctionInEnv
($fn, "r."));
18 is_deeply
({ "foo" => "r.in.foo" }, GenerateFunctionOutEnv
($fn, "r."));
20 $fn = { ELEMENTS
=> [ { DIRECTION
=> ["out", "in"], NAME
=> "foo" } ] };
21 is_deeply
({ "foo" => "r.in.foo" }, GenerateFunctionInEnv
($fn, "r."));
22 is_deeply
({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv
($fn, "r."));
24 $fn = { ELEMENTS
=> [ { DIRECTION
=> ["out"], NAME
=> "foo" } ] };
25 is_deeply
({ }, GenerateFunctionInEnv
($fn, "r."));
26 is_deeply
({ "foo" => "r.out.foo" }, GenerateFunctionOutEnv
($fn, "r."));
28 my $x = new Parse
::Pidl
::Samba3
::ClientNDR
();
30 $fn = { NAME
=> "bar", ELEMENTS
=> [ ] };
31 $x->ParseFunction("foo", $fn);
33 "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
41 \tif (DEBUGLEVEL >= 10) {
42 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
45 status = cli->dispatch(cli,
51 \tif (!NT_STATUS_IS_OK(status)) {
55 \tif (DEBUGLEVEL >= 10) {
56 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
59 \tif (NT_STATUS_IS_ERR(status)) {
63 \t/* Return variables */
66 \treturn NT_STATUS_OK;
71 $x = new Parse
::Pidl
::Samba3
::ClientNDR
();
73 $fn = { NAME
=> "bar", ELEMENTS
=> [ ], RETURN_TYPE
=> "WERROR" };
74 $x->ParseFunction("foo", $fn);
76 "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
85 \tif (DEBUGLEVEL >= 10) {
86 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
89 status = cli->dispatch(cli,
95 \tif (!NT_STATUS_IS_OK(status)) {
99 \tif (DEBUGLEVEL >= 10) {
100 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
103 \tif (NT_STATUS_IS_ERR(status)) {
107 \t/* Return variables */
109 \t/* Return result */
111 \t\t*werror = r.out.result;
114 \treturn werror_to_ntstatus(r.out.result);
119 $x = new Parse
::Pidl
::Samba3
::ClientNDR
();
121 $fn = { NAME
=> "bar", ELEMENTS
=> [ ], RETURN_TYPE
=> "WERROR" };
122 my $e = { NAME
=> "foo", ORIGINAL
=> { FILE
=> "f", LINE
=> -1 },
123 LEVELS
=> [ { TYPE
=> "ARRAY", SIZE_IS
=> "mysize" }, { TYPE
=> "DATA", DATA_TYPE
=> "int" } ]};
125 $x->ParseOutputArgument($fn, $e);
126 is
($x->{res
}, "memcpy(foo, r.out.foo, (mysize) * sizeof(*foo));\n");