summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-05-17 12:17:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:51 -0500
commit5af7002c1de5d59626e68420b43526ef5ffe3f42 (patch)
tree3ff17a01bbf292f44a76ad997ed63e157be2e5c2 /source4/build
parent764d199ca1819a5fe17614bfa2f1295364ac695f (diff)
downloadsamba-5af7002c1de5d59626e68420b43526ef5ffe3f42.tar.gz
samba-5af7002c1de5d59626e68420b43526ef5ffe3f42.tar.bz2
samba-5af7002c1de5d59626e68420b43526ef5ffe3f42.zip
r6856: Add a couple of tests that test for the behaviour described in
tridge's ref_notes.txt document. (This used to be commit 04196e0aff10846ec69a9c35e61517bb7f856386)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/test.pm3
-rwxr-xr-xsource4/build/pidl/tests/ndr_refptr.pl375
2 files changed, 377 insertions, 1 deletions
diff --git a/source4/build/pidl/test.pm b/source4/build/pidl/test.pm
index ba86d8eb10..9004d7c4c6 100644
--- a/source4/build/pidl/test.pm
+++ b/source4/build/pidl/test.pm
@@ -20,7 +20,7 @@ sub generate_cfile($$$)
print OUT '
/* This file was autogenerated. All changes made will be lost! */
#include "include/includes.h"
- ';
+';
foreach (@$incfiles) {
print OUT "#include \"$_\"\n";
@@ -118,6 +118,7 @@ sub test_idl($$$$)
my $ret = system("./$exe_filename");
if ($ret != 0) {
print STDERR "$name failed with return value $ret\n";
+ return $ret;
}
print "Ok\n";
diff --git a/source4/build/pidl/tests/ndr_refptr.pl b/source4/build/pidl/tests/ndr_refptr.pl
new file mode 100755
index 0000000000..38efbed372
--- /dev/null
+++ b/source4/build/pidl/tests/ndr_refptr.pl
@@ -0,0 +1,375 @@
+#!/usr/bin/perl
+# Simple tests for pidl's handling of ref pointers, based
+# on tridge's ref_notes.txt
+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("noptr-push", \%settings,
+' typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ uint16_t v = 13;
+ struct echo_TestRef r;
+ r.in.foo.x = v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 2)
+ return 2;
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ return 3;
+');
+
+Test::test_idl("ptr-embedded-push", \%settings,
+' typedef struct {
+ short *x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ uint16_t v = 13;
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = &v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Test::test_idl("ptr-embedded-push-null", \%settings,
+' typedef struct {
+ short *x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+Test::test_idl("refptr-embedded-push", \%settings,
+'
+ typedef struct {
+ [ref] short *x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ uint16_t v = 13;
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = &v;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Test::test_idl("refptr-embedded-push-null", \%settings,
+'
+ typedef struct {
+ [ref] short *x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo.x = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+Test::test_idl("ptr-top-push", \%settings,
+'
+ typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 2)
+ return 2;
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ return 3;
+');
+
+Test::test_idl("ptr-top-push-null", \%settings,
+'
+ typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Test::test_idl("refptr-top-push", \%settings,
+'
+ typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in,ref] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 2)
+ return 2;
+
+ if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ return 3;
+');
+
+Test::test_idl("refptr-top-push-null", \%settings,
+'
+ typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in,ref] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Test::test_idl("uniqueptr-top-push", \%settings,
+' typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in,unique] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ struct xstruct s;
+ s.x = 13;
+ r.in.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 6)
+ return 2;
+
+ if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
+ ndr->data[2] == 0 && ndr->data[3] == 0)
+ return 3;
+
+ if (ndr->data[4] != 13 || ndr->data[5] != 0)
+ return 4;
+');
+
+Test::test_idl("uniqueptr-top-push-null", \%settings,
+' typedef struct {
+ short x;
+ } xstruct;
+
+ uint16 echo_TestRef([in,unique] xstruct *foo);
+',
+'
+ struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ r.in.foo = NULL;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ return 1;
+
+ if (ndr->offset != 4)
+ return 2;
+
+ if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
+ ndr->data[2] != 0 || ndr->data[3] != 0)
+ return 3;
+');
+
+
+#----------------------------------------------------
+# typedef struct {
+# short x;
+# } xstruct;
+#
+# uint16 echo_TestRef([out] xstruct foo);
+#
+# [idl compiler error]
+#
+#----------------------------------------------------
+# typedef struct {
+# short x;
+# } xstruct;
+#
+# void echo_TestRef([out] xstruct *foo);
+#
+# xstruct r;
+# echo_TestRef(&r);
+# r.x -> 13;
+#
+# [0D 00]
+#
+#
+# echo_TestRef(NULL);
+#
+# [client runtime error 0x6f4]
+#
+#----------------------------------------------------
+# typedef struct {
+# short x;
+# } xstruct;
+#
+# void echo_TestRef([out,ref] xstruct *foo);
+#
+# xstruct r;
+# echo_TestRef(&r);
+# r.x -> 13;
+#
+# [0D 00]
+#
+#
+# echo_TestRef(NULL);
+#
+# [client runtime error 0x6f4]
+#
+#----------------------------------------------------
+# typedef struct {
+# short x;
+# } xstruct;
+#
+# void echo_TestRef([out,unique] xstruct *foo);
+#
+# [idl compiler error]
+#
+#
+#----------------------------------------------------
+# void echo_TestRef([in] short **foo);
+#
+# short v = 13;
+# short *pv = &v;
+#
+# echo_TestRef(&pv);
+#
+# [PP PP PP PP 0D 00]
+#
+#
+# short *pv = NULL;
+#
+# echo_TestRef(&pv);
+#
+# [00 00 00 00]
+#
+#
+# echo_TestRef(NULL);
+#
+# [client runtime error 0x6f4]
+#
+#
+#----------------------------------------------------
+# void echo_TestRef([in,ref] short **foo);
+#
+# short v = 13;
+# short *pv = &v;
+#
+# echo_TestRef(&pv);
+#
+# [PP PP PP PP 0D 00]
+#
+#
+# short *pv = NULL;
+#
+# echo_TestRef(&pv);
+#
+# [00 00 00 00]
+#
+#
+# echo_TestRef(NULL);
+#
+# [client runtime error 0x6f4]