summaryrefslogtreecommitdiffstats
path: root/pidl/tests/ndr_represent.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
commit8daa83a594a2e98f39d764422bfbdbc62c9efd44 (patch)
tree4099e8021376c7d8c05bdf8503093d80e9c7bad0 /pidl/tests/ndr_represent.pl
parentInitial commit. (diff)
downloadsamba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.tar.xz
samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.zip
Adding upstream version 2:4.20.0+dfsg.upstream/2%4.20.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pidl/tests/ndr_represent.pl')
-rwxr-xr-xpidl/tests/ndr_represent.pl72
1 files changed, 72 insertions, 0 deletions
diff --git a/pidl/tests/ndr_represent.pl b/pidl/tests/ndr_represent.pl
new file mode 100755
index 0000000..af9a92b
--- /dev/null
+++ b/pidl/tests/ndr_represent.pl
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+# NDR represent_as() / transmit_as() tests
+# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
+use strict;
+use warnings;
+
+use Test::More tests => 2 * 8;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util qw(test_samba4_ndr);
+
+test_samba4_ndr('represent_as-simple',
+'
+ void bla([in,represent_as(uint32)] uint8 x);
+',
+'
+ uint8_t expected[] = { 0x0D };
+ DATA_BLOB in_blob = { expected, 1 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
+ struct bla r;
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
+ return 1;
+
+ if (r.in.x != 13)
+ return 2;
+',
+'
+enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
+{
+ *to = from;
+ return NDR_ERR_SUCCESS;
+}
+
+enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
+{
+ *to = from;
+ return NDR_ERR_SUCCESS;
+}
+'
+);
+
+test_samba4_ndr('transmit_as-simple',
+'
+ void bla([in,transmit_as(uint32)] uint8 x);
+',
+'
+ uint8_t expected[] = { 0x0D };
+ DATA_BLOB in_blob = { expected, 1 };
+ struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
+ struct bla r;
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
+ return 1;
+
+ if (r.in.x != 13)
+ return 2;
+',
+'
+enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
+{
+ *to = from;
+ return NDR_ERR_SUCCESS;
+}
+
+enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
+{
+ *to = from;
+ return NDR_ERR_SUCCESS;
+}
+'
+);