summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-24 23:32:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:42 -0500
commit68ef82aac72c351f6e166b92bbb4573e8bcdbc86 (patch)
treeb4a7b5518eb5f525f17990b240f121a62283ec29 /source4/pidl/tests
parentebfbb2a7abe33e47af48d69164c37f4c24b7f8ed (diff)
downloadsamba-68ef82aac72c351f6e166b92bbb4573e8bcdbc86.tar.gz
samba-68ef82aac72c351f6e166b92bbb4573e8bcdbc86.tar.bz2
samba-68ef82aac72c351f6e166b92bbb4573e8bcdbc86.zip
r12464: Add simple IDL parsing tests for pidl using the standard perl
testing framework (Test::Simple, distributed with perl itself). Run these tests from 'make test' (This used to be commit 975d8816db6697dab828941b69a740e3a0a2c272)
Diffstat (limited to 'source4/pidl/tests')
-rwxr-xr-xsource4/pidl/tests/ndr_align.pl8
-rwxr-xr-xsource4/pidl/tests/ndr_alloc.pl16
-rwxr-xr-xsource4/pidl/tests/ndr_array.pl7
-rwxr-xr-xsource4/pidl/tests/ndr_refptr.pl7
-rwxr-xr-xsource4/pidl/tests/ndr_simple.pl68
-rwxr-xr-xsource4/pidl/tests/ndr_string.pl8
-rwxr-xr-xsource4/pidl/tests/parse_idl.pl57
7 files changed, 100 insertions, 71 deletions
diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl
index da994224eb..073ce5ce2f 100755
--- a/source4/pidl/tests/ndr_align.pl
+++ b/source4/pidl/tests/ndr_align.pl
@@ -3,13 +3,7 @@
# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
use strict;
-use Parse::Pidl::Test;
-
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
+use Test::Simple tests => 1;
Parse::Pidl::Test::test_idl('align-uint8-uint16', \%settings,
'
diff --git a/source4/pidl/tests/ndr_alloc.pl b/source4/pidl/tests/ndr_alloc.pl
index 4f6eddbfb9..4786d96971 100755
--- a/source4/pidl/tests/ndr_alloc.pl
+++ b/source4/pidl/tests/ndr_alloc.pl
@@ -3,12 +3,7 @@
# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
use strict;
-use Parse::Pidl::Test;
-
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
+use Test::Simple tests => 1;
# Check that an outgoing scalar pointer is allocated correctly
@@ -39,14 +34,9 @@ Parse::Pidl::Test::test_idl("alloc-scalar", \%settings,
# Check that an outgoing buffer pointer is allocated correctly
Parse::Pidl::Test::test_idl("alloc-buffer", \%settings,
'
- typedef struct {
- uint8 data;
- } blie;
+ typedef struct { uint8 data; } blie;
+ typedef struct { blie *x; } bla;
- typedef struct {
- blie *x;
- } bla;
-
[public] void TestAlloc([in] bla foo);
','
uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
diff --git a/source4/pidl/tests/ndr_array.pl b/source4/pidl/tests/ndr_array.pl
index d486308339..ad313949c5 100755
--- a/source4/pidl/tests/ndr_array.pl
+++ b/source4/pidl/tests/ndr_array.pl
@@ -4,12 +4,7 @@
# Published under the GNU General Public License
use strict;
-use Parse::Pidl::Test;
-
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
+use Test::Simple tests => 1;
Parse::Pidl::Test::test_idl(
# Name
diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl
index 8344661ad3..46d74f9b1e 100755
--- a/source4/pidl/tests/ndr_refptr.pl
+++ b/source4/pidl/tests/ndr_refptr.pl
@@ -5,12 +5,7 @@
# Published under the GNU General Public License.
use strict;
-use Parse::Pidl::Test;
-
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
+use Test::Simple tests => 1;
Parse::Pidl::Test::test_idl("noptr-push", \%settings,
' typedef struct {
diff --git a/source4/pidl/tests/ndr_simple.pl b/source4/pidl/tests/ndr_simple.pl
index 2c2c910a56..96e213ede9 100755
--- a/source4/pidl/tests/ndr_simple.pl
+++ b/source4/pidl/tests/ndr_simple.pl
@@ -4,41 +4,45 @@
# Published under the GNU General Public License
use strict;
-use Parse::Pidl::Test;
+use Test::Simple tests => 4;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
use Parse::Pidl::IDL;
use Parse::Pidl::NDR;
-use Parse::Pidl::Samba::NDR;
+use Parse::Pidl::Samba4::NDR::Parser;
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
-
-my $pidl = Parse::Pidl::IDL::parse_string('void Test();');
+my $pidl = Parse::Pidl::IDL::parse_string(
+"interface test { void Test(); }; ", "<test>");
+ok (defined($pidl));
my $pndr = Parse::Pidl::NDR::Parse($pidl);
+ok(defined($pndr));
+my ($header,$parser) = Parse::Pidl::Samba4::NDR::Parser($pndr);
+ok(defined($header));
+ok(defined($parser));
-Parse::Pidl::Test::test_idl(
- # Name
- 'UInt8',
-
- # Settings
- \%settings,
-
-
- # C Test
- '
- uint8_t data[] = { 0x02 };
- uint8_t result;
- DATA_BLOB b;
- struct ndr_pull *ndr;
-
- b.data = data;
- b.length = 1;
- ndr = ndr_pull_init_blob(&b, mem_ctx);
-
- if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, NDR_SCALARS, &result)))
- return 1;
- if (result != 0x02)
- return 2;
-');
+#Parse::Pidl::Test::test_idl(
+# # Name
+# 'UInt8',
+#
+# # Settings
+# \%settings,
+#
+#
+# # C Test
+# '
+# uint8_t data[] = { 0x02 };
+# uint8_t result;
+# DATA_BLOB b;
+# struct ndr_pull *ndr;
+#
+# b.data = data;
+# b.length = 1;
+# ndr = ndr_pull_init_blob(&b, mem_ctx);
+#
+# if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, NDR_SCALARS, &result)))
+# return 1;
+#
+# if (result != 0x02)
+# return 2;
+#');
diff --git a/source4/pidl/tests/ndr_string.pl b/source4/pidl/tests/ndr_string.pl
index ad8db912d7..6ece73fb4d 100755
--- a/source4/pidl/tests/ndr_string.pl
+++ b/source4/pidl/tests/ndr_string.pl
@@ -4,13 +4,7 @@
# Published under the GNU General Public License
use strict;
-use Parse::Pidl::Test;
-
-my %settings = Parse::Pidl::Test::GetSettings(@ARGV);
-
-$settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
-$settings{'IncludeFiles'} = ['ndr_test.h'];
-$settings{'ExtraFiles'} = ['ndr_test.c'];
+use Test::Simple tests => 1;
Parse::Pidl::Test::test_idl("string-pull-empty", \%settings,
' [public] void TestString([in,flag(STR_ASCII|LIBNDR_FLAG_STR_SIZE4)] string data);',
diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl
new file mode 100755
index 0000000000..d4b680d055
--- /dev/null
+++ b/source4/pidl/tests/parse_idl.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# Some simple tests for pidls parsing routines
+# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+use strict;
+
+use Test::Simple tests => 26;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+use Parse::Pidl::IDL;
+use Parse::Pidl::NDR;
+
+sub testok($$)
+{
+ my ($name, $data) = @_;
+
+ my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
+
+ ok (defined($pidl), $name);
+ return $pidl
+}
+
+sub testfail($$)
+{
+ my ($name, $data) = @_;
+
+ my $pidl = Parse::Pidl::IDL::parse_string($data, "<$name>");
+
+ ok ((not defined $pidl), $name);
+}
+
+testok "test1", "interface test { void Test(); }; ";
+testok "voidtest", "interface test { int Testx(void); }; ";
+testfail "voidtest", "interface test { Test(); }; ";
+testok "argtest", "interface test { int Test(int a, long b, uint32 c); }; ";
+testok "array1", "interface test { int Test(int a[]); };";
+testok "array2", "interface test { int Test(int a[2]); };";
+testok "array3", "interface test { int Test(int a[b]); };";
+testfail "array4", "interface test { int Test(int[] a); };";
+testok "ptr1", "interface test { int Test(int *a); };";
+testok "ptr2", "interface test { int Test(int **a); };";
+testok "ptr3", "interface test { int Test(int ***a); };";
+testfail "empty1", "interface test { };";
+testfail "empty2", "";
+testok "attr1", "[uuid(\"myuuid\"),attr] interface test { int Test(int ***a); };";
+testok "attr2", "interface test { [public] int Test(); };";
+testok "multfn", "interface test { int test1(); int test2(); };";
+testok "multif", "interface test { int test1(); }; interface test2 { int test2(); };";
+testok "tdstruct1", "interface test { typedef struct { } foo; };";
+testok "tdstruct2", "interface test { typedef struct { int a; } foo; };";
+testok "tdstruct3", "interface test { typedef struct { int a; int b; } foo; };";
+testfail "tdstruct4", "interface test { typedef struct { int a, int b; } foo; };";
+testok "tdunion1", "interface test { typedef union { } a; };";
+testok "tdunion2", "interface test { typedef union { int a; } a; };";
+testok "typedef1", "interface test { typedef int a; };";
+testfail "typedef2", "interface test { typedef x; };";
+testok "tdenum1", "interface test { typedef enum { A=1, B=2, C} a; };";