s3: increase the log level for missing PIDs on SIGCHLD
[Samba.git] / pidl / tests / samba3-cli.pl
blob27ab99dd347df795234824fd20e9a8f947d12757
1 #!/usr/bin/perl
2 # (C) 2007 Jelmer Vernooij <jelmer@samba.org>
3 # Published under the GNU General Public License
4 use strict;
5 use warnings;
7 use Test::More tests => 9;
8 use FindBin qw($RealBin);
9 use lib "$RealBin";
10 use Util;
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);
32 is($x->{res},
33 "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
34 TALLOC_CTX *mem_ctx)
36 \tstruct bar r;
37 \tNTSTATUS status;
39 \t/* In parameters */
41 \tif (DEBUGLEVEL >= 10) {
42 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
43 \t}
45 status = cli->dispatch(cli,
46 mem_ctx,
47 &ndr_table_foo,
48 NDR_BAR,
49 &r);
51 \tif (!NT_STATUS_IS_OK(status)) {
52 \t\treturn status;
53 \t}
55 \tif (DEBUGLEVEL >= 10) {
56 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
57 \t}
59 \tif (NT_STATUS_IS_ERR(status)) {
60 \t\treturn status;
61 \t}
63 \t/* Return variables */
65 \t/* Return result */
66 \treturn NT_STATUS_OK;
69 ");
71 $x = new Parse::Pidl::Samba3::ClientNDR();
73 $fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
74 $x->ParseFunction("foo", $fn);
75 is($x->{res},
76 "NTSTATUS rpccli_bar(struct rpc_pipe_client *cli,
77 TALLOC_CTX *mem_ctx,
78 WERROR *werror)
80 \tstruct bar r;
81 \tNTSTATUS status;
83 \t/* In parameters */
85 \tif (DEBUGLEVEL >= 10) {
86 \t\tNDR_PRINT_IN_DEBUG(bar, &r);
87 \t}
89 status = cli->dispatch(cli,
90 mem_ctx,
91 &ndr_table_foo,
92 NDR_BAR,
93 &r);
95 \tif (!NT_STATUS_IS_OK(status)) {
96 \t\treturn status;
97 \t}
99 \tif (DEBUGLEVEL >= 10) {
100 \t\tNDR_PRINT_OUT_DEBUG(bar, &r);
103 \tif (NT_STATUS_IS_ERR(status)) {
104 \t\treturn status;
107 \t/* Return variables */
109 \t/* Return result */
110 \tif (werror) {
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");