summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/pidl/lib/Parse/Pidl.pm2
-rw-r--r--source4/pidl/tests/Util.pm41
-rwxr-xr-xsource4/pidl/tests/ndr_compat.pl27
-rwxr-xr-xsource4/pidl/tests/test_util.pl22
4 files changed, 90 insertions, 2 deletions
diff --git a/source4/pidl/lib/Parse/Pidl.pm b/source4/pidl/lib/Parse/Pidl.pm
index 249bcd9f20..a6fc4867c3 100644
--- a/source4/pidl/lib/Parse/Pidl.pm
+++ b/source4/pidl/lib/Parse/Pidl.pm
@@ -9,7 +9,7 @@ package Parse::Pidl;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(warning error fatal);
+@EXPORT_OK = qw(warning error fatal);
use strict;
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
index d8ae30f3c3..fdd3c421f6 100644
--- a/source4/pidl/tests/Util.pm
+++ b/source4/pidl/tests/Util.pm
@@ -6,10 +6,28 @@ package Util;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(test_samba4_ndr);
+@EXPORT = qw(test_samba4_ndr test_warnings test_errors);
use strict;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+
+use Parse::Pidl;
+my $warnings = "";
+sub Parse::Pidl::warning($$)
+{
+ my ($e, $l) = @_;
+ $warnings .= "$e->{FILE}:$e->{LINE}: $l\n";
+};
+
+my $errors = "";
+sub Parse::Pidl::error($$)
+{
+ my ($e, $l) = @_;
+ $errors .= "$e->{FILE}:$e->{LINE}: $l\n";
+};
+
use Test::More;
use Parse::Pidl::IDL;
use Parse::Pidl::NDR;
@@ -84,4 +102,25 @@ SKIP: {
}
}
+sub test_warnings($$)
+{
+ my ($exp, $code) = @_;
+
+ $warnings = "";
+
+ $code->();
+
+ is($warnings, $exp);
+}
+
+
+sub test_errors($$)
+{
+ my ($exp, $code) = @_;
+ $errors = "";
+ $code->();
+
+ is($errors, $exp);
+}
+
1;
diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl
new file mode 100755
index 0000000000..735d929e27
--- /dev/null
+++ b/source4/pidl/tests/ndr_compat.pl
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use Test::More tests => 3;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util;
+use Parse::Pidl;
+use Parse::Pidl::IDL;
+
+sub parse_idl($)
+{
+ my $idl = shift;
+ my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", "nofile");
+ Parse::Pidl::NDR::Parse($pidl);
+}
+
+test_warnings("", sub {parse_idl("void x();"); });
+test_warnings("nofile:0: top-level [out] pointer `x' is not a [ref] pointer\n", sub {parse_idl("void x([out,unique] int *x);"); });
+
+test_warnings("nofile:0: pointer_default_top() is a pidl extension and should not be used\n", sub {
+ my $pidl = Parse::Pidl::IDL::parse_string("[pointer_default_top(unique)] interface echo { void x(); }; ", "nofile");
+ Parse::Pidl::NDR::Parse($pidl);
+});
+
diff --git a/source4/pidl/tests/test_util.pl b/source4/pidl/tests/test_util.pl
new file mode 100755
index 0000000000..e6133727af
--- /dev/null
+++ b/source4/pidl/tests/test_util.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use Test::More tests => 6;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+use lib "$RealBin";
+use Util qw(test_warnings test_errors);
+use Parse::Pidl qw(warning error);
+
+test_warnings("", sub {});
+
+test_warnings("x:1: msg\n", sub { warning({FILE => "x", LINE => 1}, "msg"); });
+test_warnings("", sub {});
+
+test_errors("", sub {});
+
+test_errors("x:1: msg\n", sub { error({FILE => "x", LINE => 1}, "msg"); });
+test_errors("", sub {});
+