Blame


1 4b33cdd0 2015-11-30 stephen.d package p9p
2 4b33cdd0 2015-11-30 stephen.d
3 4b33cdd0 2015-11-30 stephen.d import (
4 4b33cdd0 2015-11-30 stephen.d "bytes"
5 4b33cdd0 2015-11-30 stephen.d "errors"
6 4b33cdd0 2015-11-30 stephen.d "reflect"
7 4b33cdd0 2015-11-30 stephen.d "testing"
8 4b33cdd0 2015-11-30 stephen.d "time"
9 4b33cdd0 2015-11-30 stephen.d )
10 4b33cdd0 2015-11-30 stephen.d
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
17 4b33cdd0 2015-11-30 stephen.d }{
18 4b33cdd0 2015-11-30 stephen.d {
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},
22 4b33cdd0 2015-11-30 stephen.d },
23 4b33cdd0 2015-11-30 stephen.d {
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},
27 4b33cdd0 2015-11-30 stephen.d },
28 4b33cdd0 2015-11-30 stephen.d {
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},
32 4b33cdd0 2015-11-30 stephen.d },
33 4b33cdd0 2015-11-30 stephen.d {
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 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x7a, 0x78, 0x63, 0x76},
41 4b33cdd0 2015-11-30 stephen.d },
42 4b33cdd0 2015-11-30 stephen.d {
43 4b33cdd0 2015-11-30 stephen.d description: "Qid",
44 4b33cdd0 2015-11-30 stephen.d target: Qid{
45 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
46 4b33cdd0 2015-11-30 stephen.d Version: 0x10203040,
47 4b33cdd0 2015-11-30 stephen.d Path: 0x1020304050607080},
48 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
49 4b33cdd0 2015-11-30 stephen.d byte(QTDIR), // qtype
50 4b33cdd0 2015-11-30 stephen.d 0x40, 0x30, 0x20, 0x10, // version
51 4b33cdd0 2015-11-30 stephen.d 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, // path
52 4b33cdd0 2015-11-30 stephen.d },
53 4b33cdd0 2015-11-30 stephen.d },
54 4b33cdd0 2015-11-30 stephen.d // Dir
55 4b33cdd0 2015-11-30 stephen.d {
56 15c991ff 2016-11-16 noreply description: "TversionFcall",
57 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
58 4b33cdd0 2015-11-30 stephen.d Type: Tversion,
59 4b33cdd0 2015-11-30 stephen.d Tag: 2255,
60 4b33cdd0 2015-11-30 stephen.d Message: MessageTversion{
61 4b33cdd0 2015-11-30 stephen.d MSize: uint32(1024),
62 4b33cdd0 2015-11-30 stephen.d Version: "9PTEST",
63 4b33cdd0 2015-11-30 stephen.d },
64 4b33cdd0 2015-11-30 stephen.d },
65 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
66 4b33cdd0 2015-11-30 stephen.d 0x64, 0xcf, 0x8, 0x0, 0x4, 0x0, 0x0,
67 4b33cdd0 2015-11-30 stephen.d 0x6, 0x0, 0x39, 0x50, 0x54, 0x45, 0x53, 0x54},
68 4b33cdd0 2015-11-30 stephen.d },
69 4b33cdd0 2015-11-30 stephen.d {
70 15c991ff 2016-11-16 noreply description: "RversionFcall",
71 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
72 4b33cdd0 2015-11-30 stephen.d Type: Rversion,
73 4b33cdd0 2015-11-30 stephen.d Tag: 2255,
74 4b33cdd0 2015-11-30 stephen.d Message: MessageRversion{
75 4b33cdd0 2015-11-30 stephen.d MSize: uint32(1024),
76 4b33cdd0 2015-11-30 stephen.d Version: "9PTEST",
77 4b33cdd0 2015-11-30 stephen.d },
78 4b33cdd0 2015-11-30 stephen.d },
79 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
80 4b33cdd0 2015-11-30 stephen.d 0x65, 0xcf, 0x8, 0x0, 0x4, 0x0, 0x0,
81 4b33cdd0 2015-11-30 stephen.d 0x6, 0x0, 0x39, 0x50, 0x54, 0x45, 0x53, 0x54},
82 4b33cdd0 2015-11-30 stephen.d },
83 4b33cdd0 2015-11-30 stephen.d {
84 15c991ff 2016-11-16 noreply description: "TwalkFcall",
85 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
86 4b33cdd0 2015-11-30 stephen.d Type: Twalk,
87 4b33cdd0 2015-11-30 stephen.d Tag: 5666,
88 4b33cdd0 2015-11-30 stephen.d Message: MessageTwalk{
89 4b33cdd0 2015-11-30 stephen.d Fid: 1010,
90 4b33cdd0 2015-11-30 stephen.d Newfid: 1011,
91 4b33cdd0 2015-11-30 stephen.d Wnames: []string{"a", "b", "c"},
92 4b33cdd0 2015-11-30 stephen.d },
93 4b33cdd0 2015-11-30 stephen.d },
94 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
95 4b33cdd0 2015-11-30 stephen.d 0x6e, 0x22, 0x16, 0xf2, 0x3, 0x0, 0x0, 0xf3, 0x3, 0x0, 0x0,
96 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, // len(wnames)
97 4b33cdd0 2015-11-30 stephen.d 0x1, 0x0, 0x61, // "a"
98 4b33cdd0 2015-11-30 stephen.d 0x1, 0x0, 0x62, // "b"
99 4b33cdd0 2015-11-30 stephen.d 0x1, 0x0, 0x63}, // "c"
100 4b33cdd0 2015-11-30 stephen.d },
101 4b33cdd0 2015-11-30 stephen.d {
102 15c991ff 2016-11-16 noreply description: "RwalkFcall",
103 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
104 4b33cdd0 2015-11-30 stephen.d Type: Rwalk,
105 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
106 4b33cdd0 2015-11-30 stephen.d Message: MessageRwalk{
107 4b33cdd0 2015-11-30 stephen.d Qids: []Qid{
108 4b33cdd0 2015-11-30 stephen.d Qid{
109 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
110 4b33cdd0 2015-11-30 stephen.d Path: 1111,
111 4b33cdd0 2015-11-30 stephen.d Version: 11112,
112 4b33cdd0 2015-11-30 stephen.d },
113 4b33cdd0 2015-11-30 stephen.d Qid{Type: QTFILE,
114 4b33cdd0 2015-11-30 stephen.d Version: 1112,
115 4b33cdd0 2015-11-30 stephen.d Path: 11114},
116 4b33cdd0 2015-11-30 stephen.d },
117 4b33cdd0 2015-11-30 stephen.d },
118 4b33cdd0 2015-11-30 stephen.d },
119 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
120 4b33cdd0 2015-11-30 stephen.d 0x6f, 0xb4, 0x15,
121 4b33cdd0 2015-11-30 stephen.d 0x2, 0x0,
122 4b33cdd0 2015-11-30 stephen.d 0x80, 0x68, 0x2b, 0x0, 0x0, 0x57, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
123 4b33cdd0 2015-11-30 stephen.d 0x0, 0x58, 0x4, 0x0, 0x0, 0x6a, 0x2b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
124 4b33cdd0 2015-11-30 stephen.d },
125 4b33cdd0 2015-11-30 stephen.d {
126 15c991ff 2016-11-16 noreply description: "EmptyRreadFcall",
127 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
128 15c991ff 2016-11-16 noreply Type: Rread,
129 15c991ff 2016-11-16 noreply Tag: 5556,
130 15c991ff 2016-11-16 noreply Message: MessageRread{},
131 15c991ff 2016-11-16 noreply },
132 15c991ff 2016-11-16 noreply marshaled: []byte{
133 15c991ff 2016-11-16 noreply 0x75, 0xb4, 0x15,
134 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0},
135 15c991ff 2016-11-16 noreply },
136 15c991ff 2016-11-16 noreply {
137 15c991ff 2016-11-16 noreply description: "EmptyTwriteFcall",
138 15c991ff 2016-11-16 noreply target: &Fcall{
139 15c991ff 2016-11-16 noreply Type: Twrite,
140 15c991ff 2016-11-16 noreply Tag: 5556,
141 15c991ff 2016-11-16 noreply Message: MessageTwrite{},
142 15c991ff 2016-11-16 noreply },
143 15c991ff 2016-11-16 noreply marshaled: []byte{
144 15c991ff 2016-11-16 noreply byte(Twrite), 0xb4, 0x15,
145 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0,
146 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
147 15c991ff 2016-11-16 noreply 0x0, 0x0, 0x0, 0x0},
148 15c991ff 2016-11-16 noreply },
149 15c991ff 2016-11-16 noreply {
150 15c991ff 2016-11-16 noreply description: "RreadFcall",
151 15c991ff 2016-11-16 noreply target: &Fcall{
152 4b33cdd0 2015-11-30 stephen.d Type: Rread,
153 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
154 4b33cdd0 2015-11-30 stephen.d Message: MessageRread{
155 4b33cdd0 2015-11-30 stephen.d Data: []byte("a lot of byte data"),
156 4b33cdd0 2015-11-30 stephen.d },
157 4b33cdd0 2015-11-30 stephen.d },
158 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
159 4b33cdd0 2015-11-30 stephen.d 0x75, 0xb4, 0x15,
160 4b33cdd0 2015-11-30 stephen.d 0x12, 0x0, 0x0, 0x0,
161 4b33cdd0 2015-11-30 stephen.d 0x61, 0x20, 0x6c, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x62, 0x79, 0x74, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61},
162 4b33cdd0 2015-11-30 stephen.d },
163 4b33cdd0 2015-11-30 stephen.d {
164 15c991ff 2016-11-16 noreply description: "RstatFcall",
165 4b33cdd0 2015-11-30 stephen.d target: &Fcall{
166 4b33cdd0 2015-11-30 stephen.d Type: Rstat,
167 4b33cdd0 2015-11-30 stephen.d Tag: 5556,
168 4b33cdd0 2015-11-30 stephen.d Message: MessageRstat{
169 4b33cdd0 2015-11-30 stephen.d Stat: Dir{
170 4b33cdd0 2015-11-30 stephen.d Type: ^uint16(0),
171 4b33cdd0 2015-11-30 stephen.d Dev: ^uint32(0),
172 4b33cdd0 2015-11-30 stephen.d Qid: Qid{
173 4b33cdd0 2015-11-30 stephen.d Type: QTDIR,
174 4b33cdd0 2015-11-30 stephen.d Version: ^uint32(0),
175 4b33cdd0 2015-11-30 stephen.d Path: ^uint64(0),
176 4b33cdd0 2015-11-30 stephen.d },
177 4b33cdd0 2015-11-30 stephen.d Mode: DMDIR | DMREAD,
178 4b33cdd0 2015-11-30 stephen.d AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
179 4b33cdd0 2015-11-30 stephen.d ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
180 4b33cdd0 2015-11-30 stephen.d Length: ^uint64(0),
181 4b33cdd0 2015-11-30 stephen.d Name: "somedir",
182 4b33cdd0 2015-11-30 stephen.d UID: "uid",
183 4b33cdd0 2015-11-30 stephen.d GID: "gid",
184 4b33cdd0 2015-11-30 stephen.d MUID: "muid",
185 4b33cdd0 2015-11-30 stephen.d },
186 4b33cdd0 2015-11-30 stephen.d },
187 4b33cdd0 2015-11-30 stephen.d },
188 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
189 4b33cdd0 2015-11-30 stephen.d 0x7d, 0xb4, 0x15,
190 4b33cdd0 2015-11-30 stephen.d 0x42, 0x0, // TODO(stevvooe): Include Dir size. Not straightforward.
191 4b33cdd0 2015-11-30 stephen.d 0x40, 0x0, // TODO(stevvooe): Include Dir size. Not straightforward.
192 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, // type
193 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, // dev
194 4b33cdd0 2015-11-30 stephen.d 0x80, 0xff, 0xff, 0xff, 0xff, // qid.type, qid.version
195 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
196 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x0, 0x80, // mode
197 4b33cdd0 2015-11-30 stephen.d 0x25, 0x98, 0xb8, 0x43, // atime
198 4b33cdd0 2015-11-30 stephen.d 0x25, 0x98, 0xb8, 0x43, // mtime
199 4b33cdd0 2015-11-30 stephen.d 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // length
200 4b33cdd0 2015-11-30 stephen.d 0x7, 0x0, 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x69, 0x72,
201 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, 0x75, 0x69, 0x64, // uid
202 4b33cdd0 2015-11-30 stephen.d 0x3, 0x0, 0x67, 0x69, 0x64, // gid
203 4b33cdd0 2015-11-30 stephen.d 0x4, 0x0, 0x6d, 0x75, 0x69, 0x64}, // muid
204 961194b3 2015-12-04 stevvooe },
205 961194b3 2015-12-04 stevvooe {
206 15c991ff 2016-11-16 noreply description: "DirSlice",
207 961194b3 2015-12-04 stevvooe target: []Dir{
208 961194b3 2015-12-04 stevvooe {
209 961194b3 2015-12-04 stevvooe Type: uint16(0),
210 961194b3 2015-12-04 stevvooe Dev: uint32(0),
211 961194b3 2015-12-04 stevvooe Qid: Qid{
212 961194b3 2015-12-04 stevvooe Type: QTDIR,
213 961194b3 2015-12-04 stevvooe Version: uint32(0),
214 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
215 961194b3 2015-12-04 stevvooe },
216 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
217 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
218 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
219 961194b3 2015-12-04 stevvooe Length: 0x88,
220 961194b3 2015-12-04 stevvooe Name: ".",
221 961194b3 2015-12-04 stevvooe UID: "501",
222 961194b3 2015-12-04 stevvooe GID: "20",
223 961194b3 2015-12-04 stevvooe MUID: "none",
224 961194b3 2015-12-04 stevvooe },
225 961194b3 2015-12-04 stevvooe {
226 961194b3 2015-12-04 stevvooe Type: uint16(0),
227 961194b3 2015-12-04 stevvooe Dev: uint32(0),
228 961194b3 2015-12-04 stevvooe Qid: Qid{
229 961194b3 2015-12-04 stevvooe Type: QTDIR,
230 961194b3 2015-12-04 stevvooe Version: uint32(0),
231 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
232 961194b3 2015-12-04 stevvooe },
233 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
234 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
235 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
236 961194b3 2015-12-04 stevvooe Length: 0x63e,
237 961194b3 2015-12-04 stevvooe Name: "..",
238 961194b3 2015-12-04 stevvooe UID: "501",
239 961194b3 2015-12-04 stevvooe GID: "20",
240 961194b3 2015-12-04 stevvooe MUID: "none",
241 961194b3 2015-12-04 stevvooe },
242 961194b3 2015-12-04 stevvooe {
243 961194b3 2015-12-04 stevvooe Type: uint16(0),
244 961194b3 2015-12-04 stevvooe Dev: uint32(0),
245 961194b3 2015-12-04 stevvooe Qid: Qid{
246 961194b3 2015-12-04 stevvooe Type: QTDIR,
247 961194b3 2015-12-04 stevvooe Version: uint32(0),
248 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
249 961194b3 2015-12-04 stevvooe },
250 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
251 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
252 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
253 961194b3 2015-12-04 stevvooe Length: 0x44,
254 961194b3 2015-12-04 stevvooe Name: "hello",
255 961194b3 2015-12-04 stevvooe UID: "501",
256 961194b3 2015-12-04 stevvooe GID: "20",
257 961194b3 2015-12-04 stevvooe MUID: "none",
258 961194b3 2015-12-04 stevvooe },
259 961194b3 2015-12-04 stevvooe {
260 961194b3 2015-12-04 stevvooe Type: uint16(0),
261 961194b3 2015-12-04 stevvooe Dev: uint32(0),
262 961194b3 2015-12-04 stevvooe Qid: Qid{
263 961194b3 2015-12-04 stevvooe Type: QTDIR,
264 961194b3 2015-12-04 stevvooe Version: uint32(0),
265 961194b3 2015-12-04 stevvooe Path: ^uint64(0),
266 961194b3 2015-12-04 stevvooe },
267 961194b3 2015-12-04 stevvooe Mode: DMDIR | DMREAD,
268 961194b3 2015-12-04 stevvooe AccessTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
269 961194b3 2015-12-04 stevvooe ModTime: time.Date(2006, 01, 02, 03, 04, 05, 0, time.UTC),
270 961194b3 2015-12-04 stevvooe Length: 0x44,
271 961194b3 2015-12-04 stevvooe Name: "there",
272 961194b3 2015-12-04 stevvooe UID: "501",
273 961194b3 2015-12-04 stevvooe GID: "20",
274 961194b3 2015-12-04 stevvooe MUID: "none",
275 961194b3 2015-12-04 stevvooe },
276 961194b3 2015-12-04 stevvooe },
277 961194b3 2015-12-04 stevvooe marshaled: []byte{
278 961194b3 2015-12-04 stevvooe 0x39, 0x0, // size
279 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
280 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
281 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
282 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
283 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
284 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
285 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
286 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
287 961194b3 2015-12-04 stevvooe 0x88, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
288 961194b3 2015-12-04 stevvooe 0x1, 0x0,
289 961194b3 2015-12-04 stevvooe 0x2e, // .
290 961194b3 2015-12-04 stevvooe 0x3, 0x0,
291 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
292 961194b3 2015-12-04 stevvooe 0x2, 0x0,
293 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
294 961194b3 2015-12-04 stevvooe 0x4, 0x0,
295 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
296 961194b3 2015-12-04 stevvooe
297 961194b3 2015-12-04 stevvooe 0x3a, 0x0,
298 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
299 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
300 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
301 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
302 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
303 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
304 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
305 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
306 961194b3 2015-12-04 stevvooe 0x3e, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
307 961194b3 2015-12-04 stevvooe 0x2, 0x0,
308 961194b3 2015-12-04 stevvooe 0x2e, 0x2e, // ..
309 961194b3 2015-12-04 stevvooe 0x3, 0x0,
310 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
311 961194b3 2015-12-04 stevvooe 0x2, 0x0,
312 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
313 961194b3 2015-12-04 stevvooe 0x4, 0x0,
314 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
315 961194b3 2015-12-04 stevvooe
316 961194b3 2015-12-04 stevvooe 0x3d, 0x0,
317 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
318 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
319 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
320 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // qid.vers
321 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.Path
322 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
323 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
324 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
325 961194b3 2015-12-04 stevvooe 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
326 961194b3 2015-12-04 stevvooe 0x5, 0x0,
327 961194b3 2015-12-04 stevvooe 0x68, 0x65, 0x6c, 0x6c, 0x6f, // hello
328 961194b3 2015-12-04 stevvooe 0x3, 0x0,
329 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
330 961194b3 2015-12-04 stevvooe 0x2, 0x0,
331 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
332 961194b3 2015-12-04 stevvooe 0x4, 0x0,
333 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
334 961194b3 2015-12-04 stevvooe
335 961194b3 2015-12-04 stevvooe 0x3d, 0x0,
336 961194b3 2015-12-04 stevvooe 0x0, 0x0, // type
337 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, // dev
338 961194b3 2015-12-04 stevvooe 0x80, // qid.type == QTDIR
339 961194b3 2015-12-04 stevvooe 0x0, 0x0, 0x0, 0x0, //qid.vers
340 961194b3 2015-12-04 stevvooe 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // qid.path
341 961194b3 2015-12-04 stevvooe 0x4, 0x0, 0x0, 0x80, // mode
342 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // atime
343 961194b3 2015-12-04 stevvooe 0x25, 0x98, 0xb8, 0x43, // mtime
344 961194b3 2015-12-04 stevvooe 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // length
345 961194b3 2015-12-04 stevvooe 0x5, 0x0,
346 961194b3 2015-12-04 stevvooe 0x74, 0x68, 0x65, 0x72, 0x65, // there
347 961194b3 2015-12-04 stevvooe 0x3, 0x0,
348 961194b3 2015-12-04 stevvooe 0x35, 0x30, 0x31, // 501
349 961194b3 2015-12-04 stevvooe 0x2, 0x0,
350 961194b3 2015-12-04 stevvooe 0x32, 0x30, // 20
351 961194b3 2015-12-04 stevvooe 0x4, 0x0,
352 961194b3 2015-12-04 stevvooe 0x6e, 0x6f, 0x6e, 0x65, // none
353 961194b3 2015-12-04 stevvooe },
354 4b33cdd0 2015-11-30 stephen.d },
355 4b33cdd0 2015-11-30 stephen.d {
356 15c991ff 2016-11-16 noreply description: "RerrorFcall",
357 4b33cdd0 2015-11-30 stephen.d target: newErrorFcall(5556, errors.New("A serious error")),
358 4b33cdd0 2015-11-30 stephen.d marshaled: []byte{
359 4b33cdd0 2015-11-30 stephen.d 0x6b, // Rerror
360 4b33cdd0 2015-11-30 stephen.d 0xb4, 0x15, // Tag
361 4b33cdd0 2015-11-30 stephen.d 0xf, 0x0, // String size.
362 4b33cdd0 2015-11-30 stephen.d 0x41, 0x20, 0x73, 0x65, 0x72, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72},
363 4b33cdd0 2015-11-30 stephen.d },
364 4b33cdd0 2015-11-30 stephen.d } {
365 4b33cdd0 2015-11-30 stephen.d
366 15c991ff 2016-11-16 noreply t.Run(testcase.description, func(t *testing.T) {
367 15c991ff 2016-11-16 noreply p, err := codec.Marshal(testcase.target)
368 15c991ff 2016-11-16 noreply if err != nil {
369 15c991ff 2016-11-16 noreply t.Fatalf("error writing fcall: %v", err)
370 15c991ff 2016-11-16 noreply }
371 4b33cdd0 2015-11-30 stephen.d
372 15c991ff 2016-11-16 noreply if !bytes.Equal(p, testcase.marshaled) {
373 15c991ff 2016-11-16 noreply t.Fatalf("unexpected bytes for fcall: \n%#v != \n%#v", p, testcase.marshaled)
374 15c991ff 2016-11-16 noreply }
375 4b33cdd0 2015-11-30 stephen.d
376 15c991ff 2016-11-16 noreply if size9p(testcase.target) == 0 {
377 15c991ff 2016-11-16 noreply t.Fatalf("size of target should never be zero")
378 15c991ff 2016-11-16 noreply }
379 4b33cdd0 2015-11-30 stephen.d
380 15c991ff 2016-11-16 noreply // check that size9p is working correctly
381 15c991ff 2016-11-16 noreply if int(size9p(testcase.target)) != len(testcase.marshaled) {
382 15c991ff 2016-11-16 noreply t.Fatalf("size not correct: %v != %v", int(size9p(testcase.target)), len(testcase.marshaled))
383 15c991ff 2016-11-16 noreply }
384 4b33cdd0 2015-11-30 stephen.d
385 15c991ff 2016-11-16 noreply var v interface{}
386 15c991ff 2016-11-16 noreply targetType := reflect.TypeOf(testcase.target)
387 4b33cdd0 2015-11-30 stephen.d
388 15c991ff 2016-11-16 noreply if targetType.Kind() == reflect.Ptr {
389 15c991ff 2016-11-16 noreply v = reflect.New(targetType.Elem()).Interface()
390 15c991ff 2016-11-16 noreply } else {
391 15c991ff 2016-11-16 noreply v = reflect.New(targetType).Interface()
392 15c991ff 2016-11-16 noreply }
393 4b33cdd0 2015-11-30 stephen.d
394 15c991ff 2016-11-16 noreply if err := codec.Unmarshal(p, v); err != nil {
395 15c991ff 2016-11-16 noreply t.Fatalf("error reading: %v", err)
396 15c991ff 2016-11-16 noreply }
397 4b33cdd0 2015-11-30 stephen.d
398 15c991ff 2016-11-16 noreply if targetType.Kind() != reflect.Ptr {
399 15c991ff 2016-11-16 noreply v = reflect.Indirect(reflect.ValueOf(v)).Interface()
400 15c991ff 2016-11-16 noreply }
401 4b33cdd0 2015-11-30 stephen.d
402 15c991ff 2016-11-16 noreply if !reflect.DeepEqual(v, testcase.target) {
403 15c991ff 2016-11-16 noreply t.Fatalf("not equal: %v != %v (\n%#v\n%#v\n)",
404 15c991ff 2016-11-16 noreply v, testcase.target,
405 15c991ff 2016-11-16 noreply v, testcase.target)
406 15c991ff 2016-11-16 noreply }
407 15c991ff 2016-11-16 noreply })
408 4b33cdd0 2015-11-30 stephen.d }
409 4b33cdd0 2015-11-30 stephen.d }