summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-05-17 13:19:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:51 -0500
commitfe597fd1e28b92766e174249b10739fb2fe4a35f (patch)
treea5ff0ce5cea1d65c66d2ea3a3ad34ed85ad45d8b
parent5af7002c1de5d59626e68420b43526ef5ffe3f42 (diff)
downloadsamba-fe597fd1e28b92766e174249b10739fb2fe4a35f.tar.gz
samba-fe597fd1e28b92766e174249b10739fb2fe4a35f.tar.bz2
samba-fe597fd1e28b92766e174249b10739fb2fe4a35f.zip
r6857: - Support [public] on functions
- Add some more pidl tests based on ref_notes.txt We currently fail some tests because we don't default to "ref" for top-level pointers at the moment. We also fail some of the multi-level tests. (This used to be commit 187802f580d85e19ee9b7f07db931d0511f197bc)
-rw-r--r--source4/build/pidl/ndr_header.pm5
-rw-r--r--source4/build/pidl/test.pm2
-rwxr-xr-xsource4/build/pidl/tests/ndr_refptr.pl389
-rwxr-xr-xsource4/script/tests/test_pidl.sh1
4 files changed, 264 insertions, 133 deletions
diff --git a/source4/build/pidl/ndr_header.pm b/source4/build/pidl/ndr_header.pm
index f40810a84d..0c6291fca7 100644
--- a/source4/build/pidl/ndr_header.pm
+++ b/source4/build/pidl/ndr_header.pm
@@ -337,6 +337,11 @@ sub HeaderFnProto($$)
pidl "NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);\n";
pidl "struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);\n";
+ return unless util::has_property($fn, "public");
+
+ pidl "NTSTATUS ndr_push_$name(struct ndr_push *ndr, int flags, struct $name *r);\n";
+ pidl "NTSTATUS ndr_pull_$name(struct ndr_pull *ndr, int flags, struct $name *r);\n";
+
pidl "\n";
}
diff --git a/source4/build/pidl/test.pm b/source4/build/pidl/test.pm
index 9004d7c4c6..d01a98bd2c 100644
--- a/source4/build/pidl/test.pm
+++ b/source4/build/pidl/test.pm
@@ -117,7 +117,7 @@ sub test_idl($$$$)
my $ret = system("./$exe_filename");
if ($ret != 0) {
- print STDERR "$name failed with return value $ret\n";
+ print "failed with return value $ret\n";
return $ret;
}
diff --git a/source4/build/pidl/tests/ndr_refptr.pl b/source4/build/pidl/tests/ndr_refptr.pl
index 38efbed372..ba8d543f0b 100755
--- a/source4/build/pidl/tests/ndr_refptr.pl
+++ b/source4/build/pidl/tests/ndr_refptr.pl
@@ -26,22 +26,28 @@ Test::test_idl("noptr-push", \%settings,
struct echo_TestRef r;
r.in.foo.x = v;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
+ fprintf(stderr, "push failed\n");
return 1;
+ }
- if (ndr->offset != 2)
+ if (ndr->offset != 2) {
+ fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
return 2;
+ }
- if (ndr->data[0] != 13 || ndr->data[1] != 0)
+ if (ndr->data[0] != 13 || ndr->data[1] != 0) {
+ fprintf(stderr, "Data incorrect\n");
return 3;
+ }
');
Test::test_idl("ptr-embedded-push", \%settings,
' typedef struct {
- short *x;
+ uint16 *x;
} xstruct;
- uint16 echo_TestRef([in] xstruct foo);
+ [public] uint16 echo_TestRef([in] xstruct foo);
',
'
uint16_t v = 13;
@@ -49,7 +55,7 @@ Test::test_idl("ptr-embedded-push", \%settings,
struct echo_TestRef r;
r.in.foo.x = &v;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 6)
@@ -65,17 +71,17 @@ Test::test_idl("ptr-embedded-push", \%settings,
Test::test_idl("ptr-embedded-push-null", \%settings,
' typedef struct {
- short *x;
+ uint16 *x;
} xstruct;
- uint16 echo_TestRef([in] xstruct foo);
+ [public] 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)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 4)
@@ -89,10 +95,10 @@ Test::test_idl("ptr-embedded-push-null", \%settings,
Test::test_idl("refptr-embedded-push", \%settings,
'
typedef struct {
- [ref] short *x;
+ [ref] uint16 *x;
} xstruct;
- uint16 echo_TestRef([in] xstruct foo);
+ [public] uint16 echo_TestRef([in] xstruct foo);
',
'
uint16_t v = 13;
@@ -100,7 +106,7 @@ Test::test_idl("refptr-embedded-push", \%settings,
struct echo_TestRef r;
r.in.foo.x = &v;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 6)
@@ -117,17 +123,17 @@ Test::test_idl("refptr-embedded-push", \%settings,
Test::test_idl("refptr-embedded-push-null", \%settings,
'
typedef struct {
- [ref] short *x;
+ [ref] uint16 *x;
} xstruct;
- uint16 echo_TestRef([in] xstruct foo);
+ [public] 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)))
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
/* Windows gives [client runtime error 0x6f4] */
');
@@ -135,10 +141,10 @@ Test::test_idl("refptr-embedded-push-null", \%settings,
Test::test_idl("ptr-top-push", \%settings,
'
typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in] xstruct *foo);
+ [public] uint16 echo_TestRef([in] xstruct *foo);
',
'
struct ndr_push *ndr = ndr_push_init();
@@ -147,7 +153,7 @@ Test::test_idl("ptr-top-push", \%settings,
s.x = 13;
r.in.foo = &s;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 2)
@@ -160,17 +166,17 @@ Test::test_idl("ptr-top-push", \%settings,
Test::test_idl("ptr-top-push-null", \%settings,
'
typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in] xstruct *foo);
+ [public] 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)))
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
/* Windows gives [client runtime error 0x6f4] */
@@ -180,10 +186,10 @@ Test::test_idl("ptr-top-push-null", \%settings,
Test::test_idl("refptr-top-push", \%settings,
'
typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in,ref] xstruct *foo);
+ [public] uint16 echo_TestRef([in,ref] xstruct *foo);
',
'
struct ndr_push *ndr = ndr_push_init();
@@ -192,7 +198,7 @@ Test::test_idl("refptr-top-push", \%settings,
s.x = 13;
r.in.foo = &s;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 2)
@@ -205,17 +211,17 @@ Test::test_idl("refptr-top-push", \%settings,
Test::test_idl("refptr-top-push-null", \%settings,
'
typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in,ref] xstruct *foo);
+ [public] 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)))
+ if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
/* Windows gives [client runtime error 0x6f4] */
@@ -224,10 +230,10 @@ Test::test_idl("refptr-top-push-null", \%settings,
Test::test_idl("uniqueptr-top-push", \%settings,
' typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in,unique] xstruct *foo);
+ [public] uint16 echo_TestRef([in,unique] xstruct *foo);
',
'
struct ndr_push *ndr = ndr_push_init();
@@ -236,7 +242,7 @@ Test::test_idl("uniqueptr-top-push", \%settings,
s.x = 13;
r.in.foo = &s;
- if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, ndr_flags, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 6)
@@ -252,17 +258,17 @@ Test::test_idl("uniqueptr-top-push", \%settings,
Test::test_idl("uniqueptr-top-push-null", \%settings,
' typedef struct {
- short x;
+ uint16 x;
} xstruct;
- uint16 echo_TestRef([in,unique] xstruct *foo);
+ [public] 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)))
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
return 1;
if (ndr->offset != 4)
@@ -274,102 +280,221 @@ Test::test_idl("uniqueptr-top-push-null", \%settings,
');
-#----------------------------------------------------
-# 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]
+Test::test_idl("ptr-top-out-pull", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct xstruct s;
+ struct echo_TestRef r;
+
+ r.out.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ if (!r.out.foo)
+ return 2;
+
+ if (r.out.foo->x != 13)
+ return 3;
+');
+
+Test::test_idl("ptr-top-out-pull-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct echo_TestRef r;
+
+ r.out.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Test::test_idl("refptr-top-out-pull", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out,ref] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct xstruct s;
+ struct echo_TestRef r;
+
+ r.out.foo = &s;
+
+ if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ if (!r.out.foo)
+ return 2;
+
+ if (r.out.foo->x != 13)
+ return 3;
+');
+
+Test::test_idl("refptr-top-out-pull-null", \%settings,
+'
+ typedef struct {
+ uint16 x;
+ } xstruct;
+
+ [public] void echo_TestRef([out,ref] xstruct *foo);
+',
+'
+ uint8_t data[] = { 0x0D, 0x00 };
+ DATA_BLOB b = { data, 2 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
+ struct echo_TestRef r;
+
+ r.out.foo = NULL;
+
+ if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+');
+
+
+Test::test_idl("ptr-top-push-double", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 13;
+ uint16_t *pv = &v;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &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] != 0x0D || ndr->data[5] != 0x00)
+ return 4;
+');
+
+Test::test_idl("ptr-top-push-double-sndnull", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t *pv = NULL;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &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("ptr-top-push-double-fstnull", \%settings,
+'
+ [public] void echo_TestRef([in] uint16 **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_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+
+');
+
+
+Test::test_idl("refptr-top-push-double", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t v = 13;
+ uint16_t *pv = &v;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &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] != 0x0D || ndr->data[5] != 0x00)
+ return 4;
+');
+
+Test::test_idl("refptr-top-push-double-sndnull", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **foo);
+',
+' struct ndr_push *ndr = ndr_push_init();
+ struct echo_TestRef r;
+ uint16_t *pv = NULL;
+ r.in.foo = &pv;
+
+ if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &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-top-push-double-fstnull", \%settings,
+'
+ [public] void echo_TestRef([in,ref] uint16 **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_IN, &r)))
+ return 1;
+
+ /* Windows gives [client runtime error 0x6f4] */
+
+');
diff --git a/source4/script/tests/test_pidl.sh b/source4/script/tests/test_pidl.sh
index 77f14ddcb9..f5e731d37a 100755
--- a/source4/script/tests/test_pidl.sh
+++ b/source4/script/tests/test_pidl.sh
@@ -1,2 +1,3 @@
#!/bin/sh
./build/pidl/tests/ndr_simple.pl
+./build/pidl/tests/ndr_refptr.pl