r6859: Add ndr_align tests, use environment variables ($CC, $CFLAGS, $LDFLAGS)
authorJelmer Vernooij <jelmer@samba.org>
Tue, 17 May 2005 13:50:47 +0000 (13:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:16:51 +0000 (13:16 -0500)
where possible.

source/build/pidl/test.pm
source/build/pidl/tests/ndr_align.pl [new file with mode: 0755]
source/build/pidl/tests/ndr_simple.pl
source/script/tests/test_pidl.sh

index d01a98bd2c3a5deb669a7e571ac55550e67d3472..a7e3a839be51bd5b5113adc07cd48e4c0f4d5964 100644 (file)
@@ -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/source/build/pidl/tests/ndr_align.pl b/source/build/pidl/tests/ndr_align.pl
new file mode 100755 (executable)
index 0000000..5947c29
--- /dev/null
@@ -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;
+');
index 1c0268375ec64ef3751e7f7f2378cf184475192a..c3b55ac98c4b1e013a1cb1d0256c6e333367c567 100755 (executable)
@@ -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) 
index f5e731d37a29784a3819542055d0024613859b3b..81d443a307f7bba923e7a16a3374b2b9e22ec73f 100755 (executable)
@@ -1,3 +1,4 @@
 #!/bin/sh
 ./build/pidl/tests/ndr_simple.pl
+./build/pidl/tests/ndr_align.pl
 ./build/pidl/tests/ndr_refptr.pl