1 4b33cdd0 2015-11-30 stephen.d package p9p
3 4b33cdd0 2015-11-30 stephen.d import (
5 4b33cdd0 2015-11-30 stephen.d "errors"
6 4b33cdd0 2015-11-30 stephen.d "reflect"
7 4b33cdd0 2015-11-30 stephen.d "testing"
11 4b33cdd0 2015-11-30 stephen.d func TestEncodeDecode(t *testing.T) {
12 4b33cdd0 2015-11-30 stephen.d codec := NewCodec()
13 4b33cdd0 2015-11-30 stephen.d for _, testcase := range []struct {
14 4b33cdd0 2015-11-30 stephen.d description string
15 4b33cdd0 2015-11-30 stephen.d target interface{}
16 4b33cdd0 2015-11-30 stephen.d marshaled []byte
19 4b33cdd0 2015-11-30 stephen.d description: "uint8",
20 4b33cdd0 2015-11-30 stephen.d target: uint8('U'),
21 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{0x55},
24 4b33cdd0 2015-11-30 stephen.d description: "uint16",
25 4b33cdd0 2015-11-30 stephen.d target: uint16(0x5544),
26 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{0x44, 0x55},
29 4b33cdd0 2015-11-30 stephen.d description: "string",
30 4b33cdd0 2015-11-30 stephen.d target: "asdf",
31 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{0x4, 0x0, 0x61, 0x73, 0x64, 0x66},
34 15c991ff 2016-11-16 noreply description: "StringSlice",
35 4b33cdd0 2015-11-30 stephen.d target: []string{"asdf", "qwer", "zxcv"},
36 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
37 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, // len(target)
38 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x61, 0x73, 0x64, 0x66,
39 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x71, 0x77, 0x65, 0x72,
40 e6a3ceb5 2022-11-26 op 0x4, 0x0, 0x7a, 0x78, 0x63, 0x76,
44 4b33cdd0 2015-11-30 stephen.d description: "Qid",
45 4b33cdd0 2015-11-30 stephen.d target: Qid{
46 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
47 4b33cdd0 2015-11-30 stephen.d Version: 0x10203040,
48 e6a3ceb5 2022-11-26 op Path: 0x1020304050607080,
50 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
51 4b33cdd0 2015-11-30 stephen.d byte(QTDIR), // qtype
52 4b33cdd0 2015-11-30 stephen.d 0x40, 0x30, 0x20, 0x10, // version
53 4b33cdd0 2015-11-30 stephen.d 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, // path
58 15c991ff 2016-11-16 noreply description: "TversionFcall",
59 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
60 4b33cdd0 2015-11-30 stephen.d Type: Tversion,
61 4b33cdd0 2015-11-30 stephen.d Tag: 2255,
62 4b33cdd0 2015-11-30 stephen.d Message: MessageTversion{
63 4b33cdd0 2015-11-30 stephen.d MSize: uint32(1024),
64 4b33cdd0 2015-11-30 stephen.d Version: "9PTEST",
67 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
68 4b33cdd0 2015-11-30 stephen.d 0x64, 0xcf, 0x8, 0x0, 0x4, 0x0, 0x0,
69 e6a3ceb5 2022-11-26 op 0x6, 0x0, 0x39, 0x50, 0x54, 0x45, 0x53, 0x54,
73 15c991ff 2016-11-16 noreply description: "RversionFcall",
74 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
75 4b33cdd0 2015-11-30 stephen.d Type: Rversion,
76 4b33cdd0 2015-11-30 stephen.d Tag: 2255,
77 4b33cdd0 2015-11-30 stephen.d Message: MessageRversion{
78 4b33cdd0 2015-11-30 stephen.d MSize: uint32(1024),
79 4b33cdd0 2015-11-30 stephen.d Version: "9PTEST",
82 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
83 4b33cdd0 2015-11-30 stephen.d 0x65, 0xcf, 0x8, 0x0, 0x4, 0x0, 0x0,
84 e6a3ceb5 2022-11-26 op 0x6, 0x0, 0x39, 0x50, 0x54, 0x45, 0x53, 0x54,
88 15c991ff 2016-11-16 noreply description: "TwalkFcall",
89 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
90 4b33cdd0 2015-11-30 stephen.d Type: Twalk,
91 4b33cdd0 2015-11-30 stephen.d Tag: 5666,
92 4b33cdd0 2015-11-30 stephen.d Message: MessageTwalk{
93 4b33cdd0 2015-11-30 stephen.d Fid: 1010,
94 4b33cdd0 2015-11-30 stephen.d Newfid: 1011,
95 4b33cdd0 2015-11-30 stephen.d Wnames: []string{"a", "b", "c"},
98 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
99 4b33cdd0 2015-11-30 stephen.d 0x6e, 0x22, 0x16, 0xf2, 0x3, 0x0, 0x0, 0xf3, 0x3, 0x0, 0x0,
100 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, // len(wnames)
101 4b33cdd0 2015-11-30 stephen.d 0x1, 0x0, 0x61, // "a"
102 4b33cdd0 2015-11-30 stephen.d 0x1, 0x0, 0x62, // "b"
103 e6a3ceb5 2022-11-26 op 0x1, 0x0, 0x63, // "c"
107 15c991ff 2016-11-16 noreply description: "RwalkFcall",
108 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
109 4b33cdd0 2015-11-30 stephen.d Type: Rwalk,
110 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
111 4b33cdd0 2015-11-30 stephen.d Message: MessageRwalk{
112 4b33cdd0 2015-11-30 stephen.d Qids: []Qid{
114 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
115 4b33cdd0 2015-11-30 stephen.d Path: 1111,
116 4b33cdd0 2015-11-30 stephen.d Version: 11112,
119 e6a3ceb5 2022-11-26 op Type: QTFILE,
120 4b33cdd0 2015-11-30 stephen.d Version: 1112,
126 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
127 4b33cdd0 2015-11-30 stephen.d 0x6f, 0xb4, 0x15,
128 4b33cdd0 2015-11-30 stephen.d 0x2, 0x0,
129 4b33cdd0 2015-11-30 stephen.d 0x80, 0x68, 0x2b, 0x0, 0x0, 0x57, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
130 e6a3ceb5 2022-11-26 op 0x0, 0x58, 0x4, 0x0, 0x0, 0x6a, 0x2b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
134 15c991ff 2016-11-16 noreply description: "EmptyRreadFcall",
135 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
136 15c991ff 2016-11-16 noreply Type: Rread,
137 15c991ff 2016-11-16 noreply Tag: 5556,
138 15c991ff 2016-11-16 noreply Message: MessageRread{},
140 15c991ff 2016-11-16 noreply marshaled: []byte{
141 15c991ff 2016-11-16 noreply 0x75, 0xb4, 0x15,
142 e6a3ceb5 2022-11-26 op 0x0, 0x0, 0x0, 0x0,
146 15c991ff 2016-11-16 noreply description: "EmptyTwriteFcall",
147 15c991ff 2016-11-16 noreply target: &Fcall{
148 15c991ff 2016-11-16 noreply Type: Twrite,
149 15c991ff 2016-11-16 noreply Tag: 5556,
150 15c991ff 2016-11-16 noreply Message: MessageTwrite{},
152 15c991ff 2016-11-16 noreply marshaled: []byte{
153 15c991ff 2016-11-16 noreply byte(Twrite), 0xb4, 0x15,
154 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0,
155 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
156 e6a3ceb5 2022-11-26 op 0x0, 0x0, 0x0, 0x0,
160 15c991ff 2016-11-16 noreply description: "RreadFcall",
161 15c991ff 2016-11-16 noreply target: &Fcall{
162 4b33cdd0 2015-11-30 stephen.d Type: Rread,
163 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
164 4b33cdd0 2015-11-30 stephen.d Message: MessageRread{
165 4b33cdd0 2015-11-30 stephen.d Data: []byte("a lot of byte data"),
168 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
169 4b33cdd0 2015-11-30 stephen.d 0x75, 0xb4, 0x15,
170 4b33cdd0 2015-11-30 stephen.d 0x12, 0x0, 0x0, 0x0,
171 e6a3ceb5 2022-11-26 op 0x61, 0x20, 0x6c, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61,
175 15c991ff 2016-11-16 noreply description: "RstatFcall",
176 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
177 4b33cdd0 2015-11-30 stephen.d Type: Rstat,
178 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
179 4b33cdd0 2015-11-30 stephen.d Message: MessageRstat{
180 4b33cdd0 2015-11-30 stephen.d Stat: Dir{
181 4b33cdd0 2015-11-30 stephen.d Type: ^uint16(0),
182 4b33cdd0 2015-11-30 stephen.d Dev: ^uint32(0),
183 4b33cdd0 2015-11-30 stephen.d Qid: Qid{
184 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
185 4b33cdd0 2015-11-30 stephen.d Version: ^uint32(0),
186 4b33cdd0 2015-11-30 stephen.d Path: ^uint64(0),
188 4b33cdd0 2015-11-30 stephen.d Mode: DMDIR | DMREAD,
189 4b33cdd0 2015-11-30 stephen.d AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
190 4b33cdd0 2015-11-30 stephen.d ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
191 4b33cdd0 2015-11-30 stephen.d Length: ^uint64(0),
192 4b33cdd0 2015-11-30 stephen.d Name: "somedir",
193 4b33cdd0 2015-11-30 stephen.d UID: "uid",
194 4b33cdd0 2015-11-30 stephen.d GID: "gid",
195 4b33cdd0 2015-11-30 stephen.d MUID: "muid",
199 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
200 4b33cdd0 2015-11-30 stephen.d 0x7d, 0xb4, 0x15,
201 4b33cdd0 2015-11-30 stephen.d 0x42, 0x0, // TODO(stevvooe): Include Dir size. Not straightforward.
202 4b33cdd0 2015-11-30 stephen.d 0x40, 0x0, // TODO(stevvooe): Include Dir size. Not straightforward.
203 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, // type
204 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, // dev
205 4b33cdd0 2015-11-30 stephen.d 0x80, 0xff, 0xff, 0xff, 0xff, // qid.type, qid.version
206 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
207 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x0, 0x80, // mode
208 4b33cdd0 2015-11-30 stephen.d 0x25, 0x98, 0xb8, 0x43, // atime
209 4b33cdd0 2015-11-30 stephen.d 0x25, 0x98, 0xb8, 0x43, // mtime
210 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // length
211 4b33cdd0 2015-11-30 stephen.d 0x7, 0x0, 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x69, 0x72,
212 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, 0x75, 0x69, 0x64, // uid
213 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, 0x67, 0x69, 0x64, // gid
214 e6a3ceb5 2022-11-26 op 0x4, 0x0, 0x6d, 0x75, 0x69, 0x64, // muid
218 15c991ff 2016-11-16 noreply description: "DirSlice",
219 961194b3 2015-12-04 stevvooe target: []Dir{
221 961194b3 2015-12-04 stevvooe Type: uint16(0),
222 961194b3 2015-12-04 stevvooe Dev: uint32(0),
223 961194b3 2015-12-04 stevvooe Qid: Qid{
224 961194b3 2015-12-04 stevvooe Type: QTDIR,
225 961194b3 2015-12-04 stevvooe Version: uint32(0),
226 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
228 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
229 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
230 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
231 961194b3 2015-12-04 stevvooe Length: 0x88,
232 961194b3 2015-12-04 stevvooe Name: ".",
233 961194b3 2015-12-04 stevvooe UID: "501",
234 961194b3 2015-12-04 stevvooe GID: "20",
235 961194b3 2015-12-04 stevvooe MUID: "none",
238 961194b3 2015-12-04 stevvooe Type: uint16(0),
239 961194b3 2015-12-04 stevvooe Dev: uint32(0),
240 961194b3 2015-12-04 stevvooe Qid: Qid{
241 961194b3 2015-12-04 stevvooe Type: QTDIR,
242 961194b3 2015-12-04 stevvooe Version: uint32(0),
243 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
245 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
246 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
247 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
248 961194b3 2015-12-04 stevvooe Length: 0x63e,
249 961194b3 2015-12-04 stevvooe Name: "..",
250 961194b3 2015-12-04 stevvooe UID: "501",
251 961194b3 2015-12-04 stevvooe GID: "20",
252 961194b3 2015-12-04 stevvooe MUID: "none",
255 961194b3 2015-12-04 stevvooe Type: uint16(0),
256 961194b3 2015-12-04 stevvooe Dev: uint32(0),
257 961194b3 2015-12-04 stevvooe Qid: Qid{
258 961194b3 2015-12-04 stevvooe Type: QTDIR,
259 961194b3 2015-12-04 stevvooe Version: uint32(0),
260 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
262 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
263 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
264 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
265 961194b3 2015-12-04 stevvooe Length: 0x44,
266 961194b3 2015-12-04 stevvooe Name: "hello",
267 961194b3 2015-12-04 stevvooe UID: "501",
268 961194b3 2015-12-04 stevvooe GID: "20",
269 961194b3 2015-12-04 stevvooe MUID: "none",
272 961194b3 2015-12-04 stevvooe Type: uint16(0),
273 961194b3 2015-12-04 stevvooe Dev: uint32(0),
274 961194b3 2015-12-04 stevvooe Qid: Qid{
275 961194b3 2015-12-04 stevvooe Type: QTDIR,
276 961194b3 2015-12-04 stevvooe Version: uint32(0),
277 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
279 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
280 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
281 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
282 961194b3 2015-12-04 stevvooe Length: 0x44,
283 961194b3 2015-12-04 stevvooe Name: "there",
284 961194b3 2015-12-04 stevvooe UID: "501",
285 961194b3 2015-12-04 stevvooe GID: "20",
286 961194b3 2015-12-04 stevvooe MUID: "none",
289 961194b3 2015-12-04 stevvooe marshaled: []byte{
290 961194b3 2015-12-04 stevvooe 0x39, 0x0, // size
291 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
292 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
293 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
294 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
295 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
296 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
297 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
298 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
299 961194b3 2015-12-04 stevvooe 0x88, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
300 961194b3 2015-12-04 stevvooe 0x1, 0x0,
301 961194b3 2015-12-04 stevvooe 0x2e, // .
302 961194b3 2015-12-04 stevvooe 0x3, 0x0,
303 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
304 961194b3 2015-12-04 stevvooe 0x2, 0x0,
305 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
306 961194b3 2015-12-04 stevvooe 0x4, 0x0,
307 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
309 961194b3 2015-12-04 stevvooe 0x3a, 0x0,
310 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
311 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
312 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
313 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
314 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
315 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
316 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
317 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
318 961194b3 2015-12-04 stevvooe 0x3e, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
319 961194b3 2015-12-04 stevvooe 0x2, 0x0,
320 961194b3 2015-12-04 stevvooe 0x2e, 0x2e, // ..
321 961194b3 2015-12-04 stevvooe 0x3, 0x0,
322 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
323 961194b3 2015-12-04 stevvooe 0x2, 0x0,
324 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
325 961194b3 2015-12-04 stevvooe 0x4, 0x0,
326 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
328 961194b3 2015-12-04 stevvooe 0x3d, 0x0,
329 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
330 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
331 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
332 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
333 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.Path
334 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
335 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
336 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
337 961194b3 2015-12-04 stevvooe 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
338 961194b3 2015-12-04 stevvooe 0x5, 0x0,
339 961194b3 2015-12-04 stevvooe 0x68, 0x65, 0x6c, 0x6c, 0x6f, // hello
340 961194b3 2015-12-04 stevvooe 0x3, 0x0,
341 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
342 961194b3 2015-12-04 stevvooe 0x2, 0x0,
343 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
344 961194b3 2015-12-04 stevvooe 0x4, 0x0,
345 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
347 961194b3 2015-12-04 stevvooe 0x3d, 0x0,
348 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
349 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
350 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
351 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, //qid.vers
352 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
353 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
354 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
355 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
356 961194b3 2015-12-04 stevvooe 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
357 961194b3 2015-12-04 stevvooe 0x5, 0x0,
358 961194b3 2015-12-04 stevvooe 0x74, 0x68, 0x65, 0x72, 0x65, // there
359 961194b3 2015-12-04 stevvooe 0x3, 0x0,
360 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
361 961194b3 2015-12-04 stevvooe 0x2, 0x0,
362 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
363 961194b3 2015-12-04 stevvooe 0x4, 0x0,
364 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
368 15c991ff 2016-11-16 noreply description: "RerrorFcall",
369 4b33cdd0 2015-11-30 stephen.d target: newErrorFcall(5556, errors.New("A serious error")),
370 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
371 4b33cdd0 2015-11-30 stephen.d 0x6b, // Rerror
372 4b33cdd0 2015-11-30 stephen.d 0xb4, 0x15, // Tag
373 4b33cdd0 2015-11-30 stephen.d 0xf, 0x0, // String size.
374 e6a3ceb5 2022-11-26 op 0x41, 0x20, 0x73, 0x65, 0x72, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72,
379 15c991ff 2016-11-16 noreply t.Run(testcase.description, func(t *testing.T) {
380 15c991ff 2016-11-16 noreply p, err := codec.Marshal(testcase.target)
381 15c991ff 2016-11-16 noreply if err != nil {
382 15c991ff 2016-11-16 noreply t.Fatalf("error writing fcall: %v", err)
385 15c991ff 2016-11-16 noreply if !bytes.Equal(p, testcase.marshaled) {
386 15c991ff 2016-11-16 noreply t.Fatalf("unexpected bytes for fcall: \n%#v != \n%#v", p, testcase.marshaled)
389 15c991ff 2016-11-16 noreply if size9p(testcase.target) == 0 {
390 15c991ff 2016-11-16 noreply t.Fatalf("size of target should never be zero")
393 15c991ff 2016-11-16 noreply // check that size9p is working correctly
394 15c991ff 2016-11-16 noreply if int(size9p(testcase.target)) != len(testcase.marshaled) {
395 15c991ff 2016-11-16 noreply t.Fatalf("size not correct: %v != %v", int(size9p(testcase.target)), len(testcase.marshaled))
398 15c991ff 2016-11-16 noreply var v interface{}
399 15c991ff 2016-11-16 noreply targetType := reflect.TypeOf(testcase.target)
401 15c991ff 2016-11-16 noreply if targetType.Kind() == reflect.Ptr {
402 15c991ff 2016-11-16 noreply v = reflect.New(targetType.Elem()).Interface()
403 15c991ff 2016-11-16 noreply } else {
404 15c991ff 2016-11-16 noreply v = reflect.New(targetType).Interface()
407 15c991ff 2016-11-16 noreply if err := codec.Unmarshal(p, v); err != nil {
408 15c991ff 2016-11-16 noreply t.Fatalf("error reading: %v", err)
411 15c991ff 2016-11-16 noreply if targetType.Kind() != reflect.Ptr {
412 15c991ff 2016-11-16 noreply v = reflect.Indirect(reflect.ValueOf(v)).Interface()
415 15c991ff 2016-11-16 noreply if !reflect.DeepEqual(v, testcase.target) {
416 15c991ff 2016-11-16 noreply t.Fatalf("not equal: %v != %v (\n%#v\n%#v\n)",
417 15c991ff 2016-11-16 noreply v, testcase.target,
418 15c991ff 2016-11-16 noreply v, testcase.target)