line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# NDR alignment tests |
3
|
|
|
|
|
|
|
# (C) 2005 Jelmer Vernooij. Published under the GNU GPL |
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1220
|
use Test::More tests => 5 * 8; |
|
1
|
|
|
|
|
23534
|
|
|
1
|
|
|
|
|
11
|
|
7
|
1
|
|
|
1
|
|
2156
|
use FindBin qw($RealBin); |
|
1
|
|
|
|
|
1757
|
|
|
1
|
|
|
|
|
136
|
|
8
|
1
|
|
|
1
|
|
787
|
use lib "$RealBin/../lib"; |
|
1
|
|
|
|
|
737
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
161
|
use lib "$RealBin"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
593
|
use Util qw(test_samba4_ndr); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
test_samba4_ndr('align-uint8-uint16', |
13
|
|
|
|
|
|
|
' |
14
|
|
|
|
|
|
|
typedef [public] struct { |
15
|
|
|
|
|
|
|
uint8 x; |
16
|
|
|
|
|
|
|
uint16 y; |
17
|
|
|
|
|
|
|
} bla; |
18
|
|
|
|
|
|
|
', |
19
|
|
|
|
|
|
|
' |
20
|
|
|
|
|
|
|
struct ndr_push *ndr = ndr_push_init(); |
21
|
|
|
|
|
|
|
struct bla r; |
22
|
|
|
|
|
|
|
uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe }; |
23
|
|
|
|
|
|
|
DATA_BLOB expected_blob = { expected, 4 }; |
24
|
|
|
|
|
|
|
DATA_BLOB result_blob; |
25
|
|
|
|
|
|
|
r.x = 13; |
26
|
|
|
|
|
|
|
r.y = 0xbeef; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) |
29
|
|
|
|
|
|
|
return 1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
result_blob = ndr_push_blob(ndr); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if (!data_blob_equal(&result_blob, &expected_blob)) |
34
|
|
|
|
|
|
|
return 2; |
35
|
|
|
|
|
|
|
'); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
test_samba4_ndr('align-uint8-uint32', |
38
|
|
|
|
|
|
|
' |
39
|
|
|
|
|
|
|
typedef [public] struct { |
40
|
|
|
|
|
|
|
uint8 x; |
41
|
|
|
|
|
|
|
uint32 y; |
42
|
|
|
|
|
|
|
} bla; |
43
|
|
|
|
|
|
|
', |
44
|
|
|
|
|
|
|
' |
45
|
|
|
|
|
|
|
struct ndr_push *ndr = ndr_push_init(); |
46
|
|
|
|
|
|
|
struct bla r; |
47
|
|
|
|
|
|
|
uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe }; |
48
|
|
|
|
|
|
|
DATA_BLOB expected_blob = { expected, 8 }; |
49
|
|
|
|
|
|
|
DATA_BLOB result_blob; |
50
|
|
|
|
|
|
|
r.x = 13; |
51
|
|
|
|
|
|
|
r.y = 0xbeefbeef; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) |
54
|
|
|
|
|
|
|
return 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
result_blob = ndr_push_blob(ndr); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if (!data_blob_equal(&result_blob, &expected_blob)) |
59
|
|
|
|
|
|
|
return 2; |
60
|
|
|
|
|
|
|
'); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
test_samba4_ndr('align-uint8-hyper', |
64
|
|
|
|
|
|
|
' |
65
|
|
|
|
|
|
|
typedef [public] struct { |
66
|
|
|
|
|
|
|
uint8 x; |
67
|
|
|
|
|
|
|
hyper y; |
68
|
|
|
|
|
|
|
} bla; |
69
|
|
|
|
|
|
|
', |
70
|
|
|
|
|
|
|
' |
71
|
|
|
|
|
|
|
struct ndr_push *ndr = ndr_push_init(); |
72
|
|
|
|
|
|
|
struct bla r; |
73
|
|
|
|
|
|
|
uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
74
|
|
|
|
|
|
|
0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe }; |
75
|
|
|
|
|
|
|
DATA_BLOB expected_blob = { expected, 16 }; |
76
|
|
|
|
|
|
|
DATA_BLOB result_blob; |
77
|
|
|
|
|
|
|
r.x = 13; |
78
|
|
|
|
|
|
|
r.y = 0xbeefbeefbeefbeef; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) |
81
|
|
|
|
|
|
|
return 1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
result_blob = ndr_push_blob(ndr); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
if (!data_blob_equal(&result_blob, &expected_blob)) |
86
|
|
|
|
|
|
|
return 2; |
87
|
|
|
|
|
|
|
'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
test_samba4_ndr('noalignflag-uint8-uint16', |
90
|
|
|
|
|
|
|
' |
91
|
|
|
|
|
|
|
typedef [public] struct { |
92
|
|
|
|
|
|
|
uint8 x; |
93
|
|
|
|
|
|
|
uint16 y; |
94
|
|
|
|
|
|
|
} bla; |
95
|
|
|
|
|
|
|
', |
96
|
|
|
|
|
|
|
' |
97
|
|
|
|
|
|
|
struct ndr_push *ndr = ndr_push_init(); |
98
|
|
|
|
|
|
|
struct bla r; |
99
|
|
|
|
|
|
|
uint8_t expected[] = { 0x0D, 0xef, 0xbe }; |
100
|
|
|
|
|
|
|
DATA_BLOB expected_blob = { expected, 3 }; |
101
|
|
|
|
|
|
|
DATA_BLOB result_blob; |
102
|
|
|
|
|
|
|
ndr->flags |= LIBNDR_FLAG_NOALIGN; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
r.x = 13; |
105
|
|
|
|
|
|
|
r.y = 0xbeef; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) |
108
|
|
|
|
|
|
|
return 1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
result_blob = ndr_push_blob(ndr); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
if (!data_blob_equal(&result_blob, &expected_blob)) |
113
|
|
|
|
|
|
|
return 2; |
114
|
|
|
|
|
|
|
'); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
test_samba4_ndr('align-blob-align2', |
117
|
|
|
|
|
|
|
' |
118
|
|
|
|
|
|
|
typedef [public] struct { |
119
|
|
|
|
|
|
|
uint8 x; |
120
|
|
|
|
|
|
|
[flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data; |
121
|
|
|
|
|
|
|
} bla; |
122
|
|
|
|
|
|
|
', |
123
|
|
|
|
|
|
|
' |
124
|
|
|
|
|
|
|
struct ndr_push *ndr = ndr_push_init(); |
125
|
|
|
|
|
|
|
struct bla r; |
126
|
|
|
|
|
|
|
uint8_t data[] = { 0x01, 0x02 }; |
127
|
|
|
|
|
|
|
uint8_t expected[] = { 0x0D, 0x00, 0x01, 0x02 }; |
128
|
|
|
|
|
|
|
DATA_BLOB expected_blob = { expected, 4 }; |
129
|
|
|
|
|
|
|
DATA_BLOB result_blob; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
r.x = 13; |
132
|
|
|
|
|
|
|
r.data.data = data; |
133
|
|
|
|
|
|
|
r.data.length = 2; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) |
136
|
|
|
|
|
|
|
return 1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
result_blob = ndr_push_blob(ndr); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
if (!data_blob_equal(&result_blob, &expected_blob)) |
141
|
|
|
|
|
|
|
return 2; |
142
|
|
|
|
|
|
|
'); |