summaryrefslogtreecommitdiff
path: root/source4/pidl/tests
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-02-18 16:21:28 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:48:32 -0500
commit8cf122c2d2a0913fd9a7c55032c549598844111c (patch)
treef2e5612d40c043d0c3a2a755fecac9ee8af16d48 /source4/pidl/tests
parent069f0cc15bfe6ba38950d8b5a0b2befb74aa397e (diff)
downloadsamba-8cf122c2d2a0913fd9a7c55032c549598844111c.tar.gz
samba-8cf122c2d2a0913fd9a7c55032c549598844111c.tar.bz2
samba-8cf122c2d2a0913fd9a7c55032c549598844111c.zip
r21430: Support tagged types without typedef. This means:
struct foo { ... }; in IDL will now work. This is the first step towards nested types and using typedefs for partial types (such as "typedef int *bar;"), a requirement for complex uses of represent_as(). (This used to be commit a716aa70f0c90898e6fcf57d63a2cf4c40e7d4df)
Diffstat (limited to 'source4/pidl/tests')
-rw-r--r--source4/pidl/tests/Util.pm1
-rwxr-xr-xsource4/pidl/tests/header.pl4
-rwxr-xr-xsource4/pidl/tests/ndr_deprecations.pl2
-rwxr-xr-xsource4/pidl/tests/ndr_tagtype.pl12
-rwxr-xr-xsource4/pidl/tests/parse_idl.pl6
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl14
6 files changed, 16 insertions, 23 deletions
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
index a406b868e1..a65cd89c55 100644
--- a/source4/pidl/tests/Util.pm
+++ b/source4/pidl/tests/Util.pm
@@ -91,7 +91,6 @@ SKIP: {
my $cmd = "$cc $cflags -x c - -o $outfile $flags $ldflags";
$cmd =~ s/\n//g;
- print "$cmd\n";
open CC, "|$cmd";
print CC "#define uint_t unsigned int\n";
print CC "#define _GNU_SOURCE\n";
diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl
index b7c0b285f3..3dae33ae6c 100755
--- a/source4/pidl/tests/header.pl
+++ b/source4/pidl/tests/header.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 10;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -34,3 +34,5 @@ like(parse_idl("interface x { void foo ([out] uint32 x); };"),
like(parse_idl("interface x { void foo ([in,out] uint32 x); };"),
qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn in,out arg works");
like(parse_idl("interface x { void foo (uint32 x); };"), qr/struct foo.*{.*struct\s+{\s+uint32_t x;\s+} in;\s+struct\s+{\s+uint32_t x;\s+} out;.*};/sm, "fn with no props implies in,out");
+like(parse_idl("interface p { struct x { int y; }; };"),
+ qr/struct x.*{.*int32_t y;.*}.*;/sm, "interface member generated properly");
diff --git a/source4/pidl/tests/ndr_deprecations.pl b/source4/pidl/tests/ndr_deprecations.pl
index 89738e42f6..86828e5982 100755
--- a/source4/pidl/tests/ndr_deprecations.pl
+++ b/source4/pidl/tests/ndr_deprecations.pl
@@ -24,5 +24,3 @@ my $e = {
test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n",
sub { ValidElement($e); });
-
-
diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl
index a7f7d0490a..067fa096b4 100755
--- a/source4/pidl/tests/ndr_tagtype.pl
+++ b/source4/pidl/tests/ndr_tagtype.pl
@@ -8,15 +8,7 @@ use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_samba4_ndr);
-SKIP: {
- skip "Tagged types without typedef are not supported yet", 8;
-
-test_samba4_ndr('struct-notypedef',
-'
- struct bla {
- uint8 x;
- };
-',
+test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ',
'
struct ndr_push *ndr = ndr_push_init_ctx(NULL);
struct bla r;
@@ -33,5 +25,3 @@ test_samba4_ndr('struct-notypedef',
if (!data_blob_equal(&result_blob, &expected_blob))
return 2;
');
-
-}
diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl
index 859c2b4e46..265ac7a2bd 100755
--- a/source4/pidl/tests/parse_idl.pl
+++ b/source4/pidl/tests/parse_idl.pl
@@ -4,7 +4,7 @@
# Published under the GNU General Public License
use strict;
-use Test::More tests => 59 * 2;
+use Test::More tests => 62 * 2;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_errors);
@@ -83,8 +83,12 @@ testok "nested1", "interface test { struct x { struct { int a; } z; }; };";
testok "nested2", "interface test { struct x { struct y { int a; } z; }; };";
testok "bitmap1", "interface test { bitmap x { a=1 }; };";
testok "unsigned", "interface test { struct x { unsigned short y; }; };";
+testok "struct-property", "interface test { [public] struct x { short y; }; };";
testok "signed", "interface test { struct x { signed short y; }; };";
testok "declarg", "interface test { void test(struct { int x; } a); };";
+testok "structarg", "interface test { void test(struct a b); };";
+testfail "structargmissing", "interface test { void test(struct a); };",
+ "<structargmissing>:0: Syntax error near ')'\n";
testok "structqual", "interface test { struct x { struct y z; }; };";
testok "unionqual", "interface test { struct x { union y z; }; };";
testok "enumqual", "interface test { struct x { enum y z; }; };";
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index 1f859db788..50b0bd269f 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -11,7 +11,7 @@ use Util;
use Parse::Pidl::Util qw(MyDumper);
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
- EnvSubstituteValue NeededFunction NeededElement NeededTypedef);
+ EnvSubstituteValue NeededFunction NeededElement NeededType);
my $output;
sub print_fn($) { my $x = shift; $output.=$x; }
@@ -202,19 +202,19 @@ is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
# public structs are always needed
$needed = {};
-NeededTypedef({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
+NeededType({ NAME => "bla", DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
$needed);
is_deeply($needed, { });
$needed = {};
-NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
+NeededType({ PROPERTIES => { public => 1 }, NAME => "bla",
DATA => { TYPE => "STRUCT", ELEMENTS => [] } },
$needed);
is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1 });
# make sure types for elements are set too
$needed = {};
-NeededTypedef({ PROPERTIES => { public => 1 }, NAME => "bla",
+NeededType({ PROPERTIES => { public => 1 }, NAME => "bla",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed);
@@ -222,7 +222,7 @@ is_deeply($needed, { pull_bla => 1, print_bla => 1, push_bla => 1,
pull_bar => 1, print_bar => 1, push_bar => 1});
$needed = {};
-NeededTypedef({ PROPERTIES => { gensize => 1}, NAME => "bla",
+NeededType({ PROPERTIES => { gensize => 1}, NAME => "bla",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed);
@@ -230,14 +230,14 @@ is_deeply($needed, { ndr_size_bla => 1 });
# make sure types for elements are set too
$needed = { pull_bla => 1 };
-NeededTypedef({ NAME => "bla",
+NeededType({ NAME => "bla",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed);
is_deeply($needed, { pull_bla => 1, pull_bar => 1 });
$needed = {};
-NeededTypedef({ PROPERTIES => { public => 1},
+NeededType({ PROPERTIES => { public => 1},
NAME => "bla",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } },