summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build')
-rwxr-xr-xsource4/build/pidl/pidl.pl7
-rw-r--r--source4/build/pidl/test.pm128
-rwxr-xr-xsource4/build/pidl/tests/ndr_simple.pl40
3 files changed, 173 insertions, 2 deletions
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl
index 1d6b45172a..b80832dd99 100755
--- a/source4/build/pidl/pidl.pl
+++ b/source4/build/pidl/pidl.pl
@@ -45,6 +45,7 @@ my($opt_swig) = 0;
my($opt_dcom_proxy) = 0;
my($opt_com_header) = 0;
my($opt_odl) = 0;
+my($opt_quiet) = 0;
my($opt_output);
my $idl_parser = new idl;
@@ -86,6 +87,7 @@ sub ShowHelp()
--odl accept ODL input
--dcom-proxy create DCOM proxy (implies --odl)
--com-header create header for COM interfaces (implies --odl)
+ --quiet be quiet
\n";
exit(0);
}
@@ -107,7 +109,8 @@ GetOptions (
'keep' => \$opt_keep,
'swig' => \$opt_swig,
'dcom-proxy' => \$opt_dcom_proxy,
- 'com-header' => \$opt_com_header
+ 'com-header' => \$opt_com_header,
+ 'quiet' => \$opt_quiet
);
if ($opt_help) {
@@ -131,7 +134,7 @@ sub process_file($)
my($pidl_file) = util::ChangeExtension($output, ".pidl");
- print "Compiling $idl_file\n";
+ unless ($opt_quiet) { print "Compiling $idl_file\n"; }
if ($opt_parse) {
$pidl = IdlParse($idl_file);
diff --git a/source4/build/pidl/test.pm b/source4/build/pidl/test.pm
new file mode 100644
index 0000000000..ba86d8eb10
--- /dev/null
+++ b/source4/build/pidl/test.pm
@@ -0,0 +1,128 @@
+# Simple system for running tests against pidl
+# (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU General Public License
+
+package Test;
+
+use strict;
+use util;
+
+my $idl_path = "./build/pidl/pidl.pl";
+
+sub generate_cfile($$$)
+{
+ my ($filename, $fragment, $incfiles) = @_;
+
+ unless (open (OUT, ">$filename")) {
+ print STDERR "Unable to open $filename\n";
+ return -1;
+ }
+ print OUT '
+/* This file was autogenerated. All changes made will be lost! */
+#include "include/includes.h"
+ ';
+
+ foreach (@$incfiles) {
+ print OUT "#include \"$_\"\n";
+ }
+
+ print OUT '
+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";
+ close OUT;
+
+ return 0;
+}
+
+sub generate_idlfile($$)
+{
+ my ($filename,$fragment) = @_;
+
+ unless (open(OUT, ">$filename")) {
+ print STDERR "Unable to open $filename\n";
+ return -1;
+ }
+
+ print OUT '
+[uuid("1-2-3-4-5")] interface test_if
+{
+';
+ print OUT $fragment;
+ print OUT "\n}\n";
+ close OUT;
+
+ return 0;
+}
+
+sub compile_idl($$)
+{
+ my ($filename,$idlargs) = @_;
+
+ my @args = @$idlargs;
+ push (@args, $filename);
+
+ unless (system($idl_path, @args) == 0) {
+ print STDERR "Error compiling IDL file $filename: $!\n";
+ return -1;
+ }
+}
+
+sub compile_cfile($)
+{
+ my ($filename) = @_;
+
+ print "Compiling C file $filename\n";
+
+ return system("cc", '-I.', '-Iinclude', '-c', $filename);
+}
+
+sub link_files($$)
+{
+ my ($exe_name,$objs) = @_;
+
+ return system("cc", '-I.', '-Iinclude', '-Lbin', '-lrpc', '-o', $exe_name, @$objs);
+}
+
+sub test_idl($$$$)
+{
+ my ($name,$settings,$idl,$c) = @_;
+
+ $| = 1;
+
+ print "Running test $name... ";
+
+ my $c_filename = $name."_test.c";
+ my $idl_filename = $name."_idl.idl";
+ my $exe_filename = $name."_exe";
+
+ return -1 if (generate_cfile($c_filename, $c, $settings->{IncludeFiles}) == -1);
+
+ return -1 if (generate_idlfile($idl_filename, $idl) == -1);
+
+ return -1 if (compile_idl($idl_filename, $settings->{'IDL-Arguments'}) == -1);
+
+ my @srcs = ($c_filename);
+ push (@srcs, @{$settings->{'ExtraFiles'}});
+
+# foreach (@srcs) {
+# return -1 if (compile_cfile($_) == -1);
+# }
+
+ return -1 if (link_files($exe_filename, \@srcs) == -1);
+
+ my $ret = system("./$exe_filename");
+ if ($ret != 0) {
+ print STDERR "$name failed with return value $ret\n";
+ }
+
+ print "Ok\n";
+
+ return $ret;
+}
+
+1;
diff --git a/source4/build/pidl/tests/ndr_simple.pl b/source4/build/pidl/tests/ndr_simple.pl
new file mode 100755
index 0000000000..1c0268375e
--- /dev/null
+++ b/source4/build/pidl/tests/ndr_simple.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+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(
+ # Name
+ 'UInt8',
+
+ # Settings
+ \%settings,
+
+ # IDL
+ 'void Test();',
+
+ # C Test
+ '
+ uint8_t data[] = { 0x02 };
+ uint8_t result;
+ DATA_BLOB b;
+ struct ndr_pull *ndr;
+
+ b.data = data;
+ b.length = 1;
+ ndr = ndr_pull_init_blob(&b, mem_ctx);
+
+ if (NT_STATUS_IS_ERR(ndr_pull_uint8(ndr, ndr_flags, &result)))
+ return 1;
+
+ if (result != 0x02)
+ return 2;
+');