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($$$)
{
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";
{
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($$$$)
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);
--- /dev/null
+#!/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;
+');