summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm6
-rw-r--r--source4/pidl/tests/Util.pm41
-rwxr-xr-xsource4/pidl/tests/ndr_align.pl7
-rwxr-xr-xsource4/pidl/tests/ndr_refptr.pl47
4 files changed, 53 insertions, 48 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index b1aec5cc5d..a709abba10 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -317,8 +317,10 @@ sub find_largest_alignment($)
if ($e->{POINTERS}) {
$a = 4;
- } elsif (has_property($e, "subcontext")){
+ } elsif (has_property($e, "subcontext")) {
$a = 1;
+ } elsif (has_property($e, "represent_as")) {
+ $a = align_type($e->{PROPERTIES}->{represent_as});
} else {
$a = align_type($e->{TYPE});
}
@@ -793,6 +795,8 @@ my %property_list = (
"case" => ["ELEMENT"],
"default" => ["ELEMENT"],
+ "represent_as" => ["ELEMENT"],
+
# subcontext
"subcontext" => ["ELEMENT"],
"subcontext_size" => ["ELEMENT"],
diff --git a/source4/pidl/tests/Util.pm b/source4/pidl/tests/Util.pm
index 37177cc730..3e0f214854 100644
--- a/source4/pidl/tests/Util.pm
+++ b/source4/pidl/tests/Util.pm
@@ -15,9 +15,6 @@ use Parse::Pidl::IDL;
use Parse::Pidl::NDR;
use Parse::Pidl::Samba4::NDR::Parser;
use Parse::Pidl::Samba4::Header;
-use Parse::Pidl::Samba4 qw(is_intree);
-
-my $sanecc = 0;
# Generate a Samba4 parser for an IDL fragment and run it with a specified
# piece of code to check whether the parser works as expected
@@ -37,13 +34,8 @@ sub test_samba4_ndr($$$)
SKIP: {
- my $link = is_intree() && 0; # FIXME
-
skip "no samba environment available, skipping compilation", 3
- if not is_intree();
-
- skip "no sane C compiler, skipping compilation", 3
- if not $sanecc;
+ if (system("pkg-config --exists dcerpc ndr") != 0);
my $test_data_prefix = $ENV{TEST_DATA_PREFIX};
@@ -54,15 +46,15 @@ SKIP: {
$outfile = "test-$name";
}
- #my $cflags = $ENV{CFLAGS};
- my $cflags = "-Iinclude -Ilib -I.";
+ my $cflags = `pkg-config --libs --cflags dcerpc ndr`;
- if (is_intree() and $link) {
- open CC, "|cc -x c -o $outfile $cflags -";
- } elsif (is_intree()) {
- open CC, "|cc -x c -c -o $outfile $cflags -";
- }
- print CC "#include \"includes.h\"\n";
+ open CC, "|cc -x c - -o $outfile $cflags";
+ print CC "#define uint_t unsigned int\n";
+ print CC "#define _GNU_SOURCE\n";
+ print CC "#include <stdint.h>\n";
+ print CC "#include <stdlib.h>\n";
+ print CC "#include <stdio.h>\n";
+ print CC "#include <stdarg.h>\n";
print CC $header;
print CC $ndrheader;
print CC $ndrparser;
@@ -79,23 +71,14 @@ SKIP: {
ok(-f $outfile, "($name) compile");
- unless ($link) {
- skip "no shared libraries of Samba available yet, can't run test", 2;
- unlink($outfile);
- }
+ my $ret = system("./$outfile", ()) >> 8;
+ print "# return code: $ret\n" if ($ret != 0);
- ok(system($outfile), "($name) run");
+ ok($ret == 0, "($name) run");
ok(unlink($outfile), "($name) remove");
}
}
-my $outfile = "test"; # FIXME: Somewhat more unique name
-
-# Test whether CC is sane. The real 'fix' here would be using the
-# Samba build system, but unfortunately, we have no way of hooking into that
-# yet so we're running CC directly for now
-$sanecc = 1 if system('echo "main() {}"'." | cc -I. -x c -c - -o $outfile") == 0;
-
1;
diff --git a/source4/pidl/tests/ndr_align.pl b/source4/pidl/tests/ndr_align.pl
index 7ca180cf20..55a86861ca 100755
--- a/source4/pidl/tests/ndr_align.pl
+++ b/source4/pidl/tests/ndr_align.pl
@@ -113,6 +113,10 @@ test_samba4_ndr('noalignflag-uint8-uint16',
return 2;
');
+SKIP: {
+
+skip "align-blob-align2 is known to fail", 8;
+
test_samba4_ndr('align-blob-align2',
'
typedef [public] struct {
@@ -137,6 +141,9 @@ test_samba4_ndr('align-blob-align2',
result_blob = ndr_push_blob(ndr);
+ printf("%02x%02x%02x%02x\n", result_blob.data[0], result_blob.data[1], result_blob.data[2], result_blob.data[3]);
+
if (!data_blob_equal(&result_blob, &expected_blob))
return 2;
');
+}
diff --git a/source4/pidl/tests/ndr_refptr.pl b/source4/pidl/tests/ndr_refptr.pl
index 0fd573d51e..6940586f01 100755
--- a/source4/pidl/tests/ndr_refptr.pl
+++ b/source4/pidl/tests/ndr_refptr.pl
@@ -5,7 +5,7 @@
# Published under the GNU General Public License.
use strict;
-use Test::More tests => 21 * 8;
+use Test::More tests => 22 * 8;
use FindBin qw($RealBin);
use lib "$RealBin/../lib";
use lib "$RealBin";
@@ -402,6 +402,9 @@ test_samba4_ndr("ptr-top-push-double",
return 4;
');
+SKIP: {
+ skip "ptr-top-push-double-sndnull is known to fail", 8;
+
test_samba4_ndr("ptr-top-push-double-sndnull",
'
[public] void echo_TestRef([in] uint16 **foo);
@@ -421,6 +424,7 @@ test_samba4_ndr("ptr-top-push-double-sndnull",
ndr->data[2] != 0 || ndr->data[3] != 0)
return 3;
');
+}
test_samba4_ndr("ptr-top-push-double-fstnull",
'
@@ -462,6 +466,10 @@ test_samba4_ndr("refptr-top-push-double",
return 4;
');
+SKIP: {
+
+ skip "refptr-top-push-double-sndnull is known to fail", 8;
+
test_samba4_ndr("refptr-top-push-double-sndnull",
'
[public] void echo_TestRef([in,ref] uint16 **foo);
@@ -481,6 +489,7 @@ test_samba4_ndr("refptr-top-push-double-sndnull",
ndr->data[2] != 0 || ndr->data[3] != 0)
return 3;
');
+}
test_samba4_ndr("refptr-top-push-double-fstnull",
'
@@ -497,20 +506,22 @@ test_samba4_ndr("refptr-top-push-double-fstnull",
');
-#FIXME: Not supported yet
-#test_samba4_ndr("ignore-ptr",
-#'
-# [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
-#',
-#' struct ndr_push *ndr = ndr_push_init();
-# struct echo_TestRef r;
-# uint16_t v = 10;
-# r.in.foo = &v;
-# r.in.bar = &v;
-#
-# if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
-# return 1;
-#
-# if (ndr->offset != 4)
-# return 2;
-#');
+SKIP: {
+ skip "ignore-ptrs are not supported yet", 8;
+test_samba4_ndr("ignore-ptr",
+'
+ [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 10;
+ r.in.foo = &v;
+ r.in.bar = &v;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+');
+}