summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-05-17 13:50:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:51 -0500
commit9d56a6d8f86a2285231d1707635ce8a5bb996b1a (patch)
treea0cc41e088ff1cc9f03f5ca1b620f9080a7b7972 /source4/build/pidl
parentfe597fd1e28b92766e174249b10739fb2fe4a35f (diff)
downloadsamba-9d56a6d8f86a2285231d1707635ce8a5bb996b1a.tar.gz
samba-9d56a6d8f86a2285231d1707635ce8a5bb996b1a.tar.bz2
samba-9d56a6d8f86a2285231d1707635ce8a5bb996b1a.zip
r6859: Add ndr_align tests, use environment variables ($CC, $CFLAGS, $LDFLAGS)
where possible. (This used to be commit 077f4105aceba99a7ac4de21a20bb758fcc01203)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/test.pm19
-rwxr-xr-xsource4/build/pidl/tests/ndr_align.pl39
-rwxr-xr-xsource4/build/pidl/tests/ndr_simple.pl2
3 files changed, 51 insertions, 9 deletions
diff --git a/source4/build/pidl/test.pm b/source4/build/pidl/test.pm
index d01a98bd2c..a7e3a839be 100644
--- a/source4/build/pidl/test.pm
+++ b/source4/build/pidl/test.pm
@@ -8,6 +8,11 @@ use strict;
use util;
my $idl_path = "./build/pidl/pidl.pl";
+my $cc = $ENV{CC};
+my @cflags = split / /, $ENV{CFLAGS};
+my @ldflags = split / /, $ENV{LDFLAGS};
+
+$cc = "cc" if ($cc eq "");
sub generate_cfile($$$)
{
@@ -30,7 +35,6 @@ sub generate_cfile($$$)
int main(int argc, char **argv)
{
TALLOC_CTX *mem_ctx = talloc_init(NULL);
- int ndr_flags = 0;
';
print OUT $fragment;
print OUT "\treturn 0;\n}\n";
@@ -76,16 +80,14 @@ sub compile_cfile($)
{
my ($filename) = @_;
- print "Compiling C file $filename\n";
-
- return system("cc", '-I.', '-Iinclude', '-c', $filename);
+ return system($cc, @cflags, '-I.', '-Iinclude', '-c', $filename);
}
sub link_files($$)
{
my ($exe_name,$objs) = @_;
- return system("cc", '-I.', '-Iinclude', '-Lbin', '-lrpc', '-o', $exe_name, @$objs);
+ return system($cc, @ldflags, '-I.', '-Iinclude', '-Lbin', '-lrpc', '-o', $exe_name, @$objs);
}
sub test_idl($$$$)
@@ -109,9 +111,10 @@ sub test_idl($$$$)
my @srcs = ($c_filename);
push (@srcs, @{$settings->{'ExtraFiles'}});
-# foreach (@srcs) {
-# return -1 if (compile_cfile($_) == -1);
-# }
+ foreach (@srcs) {
+ next unless /\.c$/;
+ return -1 if (compile_cfile($_) == -1);
+ }
return -1 if (link_files($exe_filename, \@srcs) == -1);
diff --git a/source4/build/pidl/tests/ndr_align.pl b/source4/build/pidl/tests/ndr_align.pl
new file mode 100755
index 0000000000..5947c2998f
--- /dev/null
+++ b/source4/build/pidl/tests/ndr_align.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+# NDR alignment tests
+# (C) 2005 Jelmer Vernooij. Published under the GNU GPL
+use strict;
+
+use FindBin qw($RealBin);
+use lib "$RealBin/..";
+use test;
+
+my %settings = (
+ 'IDL-Arguments' => ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'],
+ 'IncludeFiles' => ['ndr_test.h'],
+ 'ExtraFiles' => ['ndr_test.c'],
+);
+
+Test::test_idl('align-uint8-uint16', \%settings,
+'
+ typedef [public] struct {
+ uint8 x;
+ uint16 y;
+ } bla;
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct bla r;
+ uint8_t expected[] = { 0x0D, 0x00, 0xbe, 0xef };
+ DATA_BLOB expected_blob = { expected, 4 };
+ DATA_BLOB result_blob;
+ r.x = 13;
+ r.y = 0xbeef;
+
+ if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
+ return 1;
+
+ result_blob = ndr_push_blob(ndr);
+
+ if (!data_blob_equal(&result_blob, &expected_blob))
+ return 2;
+');
diff --git a/source4/build/pidl/tests/ndr_simple.pl b/source4/build/pidl/tests/ndr_simple.pl
index 1c0268375e..c3b55ac98c 100755
--- a/source4/build/pidl/tests/ndr_simple.pl
+++ b/source4/build/pidl/tests/ndr_simple.pl
@@ -32,7 +32,7 @@ Test::test_idl(
b.length = 1;
ndr = ndr_pull_init_blob(&b, mem_ctx);
- if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, ndr_flags, &result)))
+ if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, NDR_SCALARS, &result)))
return 1;
if (result != 0x02)