summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-04-22 15:59:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:23 -0500
commitcc5ad07d84df94f8f2bc16fcb8015f1cf843c1e3 (patch)
tree5cc908a4bbd3c6294a1044dc79ffc7edad30cfdd /source4/pidl/tests
parentb0d209087939c0de765349c80a22884b956f3f0f (diff)
downloadsamba-cc5ad07d84df94f8f2bc16fcb8015f1cf843c1e3.tar.gz
samba-cc5ad07d84df94f8f2bc16fcb8015f1cf843c1e3.tar.bz2
samba-cc5ad07d84df94f8f2bc16fcb8015f1cf843c1e3.zip
r22462: Fix test suite for ndr parser without using 'our'
(This used to be commit d491e60c70de8d78c333b317a143919c1a68c6d9)
Diffstat (limited to 'source4/pidl/tests')
-rw-r--r--source4/pidl/tests/Util.pm3
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl33
2 files changed, 19 insertions, 17 deletions
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
index a65cd89c55..48a08b5749 100644
--- a/source4/pidl/tests/Util.pm
+++ b/source4/pidl/tests/Util.pm
@@ -54,7 +54,8 @@ sub test_samba4_ndr
ok(defined($header), "($name) generate generic header");
my $pndr = Parse::Pidl::NDR::Parse($pidl);
ok(defined($pndr), "($name) generate NDR tree");
- my ($ndrheader,$ndrparser) = Parse::Pidl::Samba4::NDR::Parser::Parse($pndr, undef, undef);
+ my $generator = new Parse::Pidl::Samba4::NDR::Parser();
+ my ($ndrheader,$ndrparser) = $generator->Parse($pndr, undef, undef);
ok(defined($ndrparser), "($name) generate NDR parser");
ok(defined($ndrheader), "($name) generate NDR header");
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index cf79cd006f..05c3c1c0df 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -8,10 +8,11 @@ use Test::More tests => 41;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
+use strict;
use Parse::Pidl::Util qw(MyDumper);
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
- EnvSubstituteValue NeededFunction NeededElement NeededType $res
+ EnvSubstituteValue NeededFunction NeededElement NeededType
NeededInterface TypeFunctionName ParseElementPrint);
my $output;
@@ -260,21 +261,21 @@ is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1,
ndr_pull_bar => 1, ndr_push_bar => 1,
ndr_bar_to_rep => 1, ndr_rep_to_bar => 1});
-$res = "";
-Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({
+my $generator = new Parse::Pidl::Samba4::NDR::Parser();
+$generator->ParseStructPush({
NAME => "mystruct",
TYPE => "STRUCT",
PROPERTIES => {},
ALIGN => 4,
ELEMENTS => [ ]}, "x");
-is($res, "if (ndr_flags & NDR_SCALARS) {
+is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
}
if (ndr_flags & NDR_BUFFERS) {
}
");
-$res = "";
+$generator = new Parse::Pidl::Samba4::NDR::Parser();
my $e = {
NAME => "el1",
TYPE => "mytype",
@@ -283,14 +284,14 @@ my $e = {
LEVELS => [
{ LEVEL_INDEX => 0, TYPE => "DATA", DATA_TYPE => "mytype" }
] };
-Parse::Pidl::Samba4::NDR::Parser::ParseStructPush({
+$generator->ParseStructPush({
NAME => "mystruct",
TYPE => "STRUCT",
PROPERTIES => {},
ALIGN => 4,
SURROUNDING_ELEMENT => $e,
ELEMENTS => [ $e ]}, "x");
-is($res, "if (ndr_flags & NDR_SCALARS) {
+is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
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));
@@ -305,21 +306,21 @@ is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef
is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar");
# check noprint works
-$res = "";
-ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
+$generator = new Parse::Pidl::Samba4::NDR::Parser();
+$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
PROPERTIES => { noprint => 1},
LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt"} ]}, "var", { "x" => "r->foobar" } );
-is($res, "");
+is($generator->{res}, "");
-$res = "";
-ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
+$generator = new Parse::Pidl::Samba4::NDR::Parser();
+$generator->ParseElementPrint({ NAME => "x", TYPE => "rt", REPRESENTATION_TYPE => "rt",
PROPERTIES => {},
LEVELS => [ { TYPE => "DATA", DATA_TYPE => "rt" }]}, "var", { "x" => "r->foobar" } );
-is($res, "ndr_print_rt(ndr, \"x\", &var);\n");
+is($generator->{res}, "ndr_print_rt(ndr, \"x\", &var);\n");
# make sure that a print function for an element with value() set works
-$res = "";
-ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32",
+$generator = new Parse::Pidl::Samba4::NDR::Parser();
+$generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TYPE => "uint32",
PROPERTIES => { value => "23" },
LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } );
-is($res, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n");
+is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n");