summaryrefslogtreecommitdiff
path: root/source4/pidl/tests/ndr_represent.pl
blob: b5ee312668077d7fc60dfe0d0ade46e765333464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
# NDR represent_as() / transmit_as() tests
# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
use strict;

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);
	struct bla r;

	if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
		return 1;

	if (r.in.x != 13)
		return 2;
',
'
#include <libcli/util/ntstatus.h>

NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
	*to = from;
	return NT_STATUS_OK;
}

NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
{
	*to = from;
	return NT_STATUS_OK;
}
'
);

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);
	struct bla r;

	if (!NT_STATUS_IS_OK(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
		return 1;

	if (r.in.x != 13)
		return 2;
',
'
#include <libcli/util/ntstatus.h>

NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
	*to = from;
	return NT_STATUS_OK;
}

NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
{
	*to = from;
	return NT_STATUS_OK;
}
'
);