r6857: - Support [public] on functions
authorJelmer Vernooij <jelmer@samba.org>
Tue, 17 May 2005 13:19:40 +0000 (13:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:16:51 +0000 (13:16 -0500)
- 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.

source/build/pidl/ndr_header.pm
source/build/pidl/test.pm
source/build/pidl/tests/ndr_refptr.pl
source/script/tests/test_pidl.sh

index f40810a84d822921f8729d45589dd6dfd253da5f..0c6291fca7506fc88ed35240a359164a88989523 100644 (file)
@@ -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";
 }
 
index 9004d7c4c6f3e66ba66ecf71af653629dfe4da4e..d01a98bd2c3a5deb669a7e571ac55550e67d3472 100644 (file)
@@ -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;
        }
 
index 38efbed372290e48fa910bb8591a385481b677c5..ba8d543f0b73ead12144915f665a703cdb10a5de 100755 (executable)
@@ -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] */
+
+');
index 77f14ddcb9750b106b0518023be100455fecc04c..f5e731d37a29784a3819542055d0024613859b3b 100755 (executable)
@@ -1,2 +1,3 @@
 #!/bin/sh
 ./build/pidl/tests/ndr_simple.pl
+./build/pidl/tests/ndr_refptr.pl