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 e6a3ceb5 2022-11-26 op 0x4, 0x0, 0x7a, 0x78, 0x63, 0x76,
41 e6a3ceb5 2022-11-26 op },
42 4b33cdd0 2015-11-30 stephen.d },
43 4b33cdd0 2015-11-30 stephen.d {
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,
49 e6a3ceb5 2022-11-26 op },
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
54 4b33cdd0 2015-11-30 stephen.d },
55 4b33cdd0 2015-11-30 stephen.d },
56 4b33cdd0 2015-11-30 stephen.d // Dir
57 4b33cdd0 2015-11-30 stephen.d {
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",
65 4b33cdd0 2015-11-30 stephen.d },
66 4b33cdd0 2015-11-30 stephen.d },
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,
70 e6a3ceb5 2022-11-26 op },
71 4b33cdd0 2015-11-30 stephen.d },
72 4b33cdd0 2015-11-30 stephen.d {
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",
80 4b33cdd0 2015-11-30 stephen.d },
81 4b33cdd0 2015-11-30 stephen.d },
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,
85 e6a3ceb5 2022-11-26 op },
86 4b33cdd0 2015-11-30 stephen.d },
87 4b33cdd0 2015-11-30 stephen.d {
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"},
96 4b33cdd0 2015-11-30 stephen.d },
97 4b33cdd0 2015-11-30 stephen.d },
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"
104 e6a3ceb5 2022-11-26 op },
105 4b33cdd0 2015-11-30 stephen.d },
106 4b33cdd0 2015-11-30 stephen.d {
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{
113 e6a3ceb5 2022-11-26 op {
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,
117 4b33cdd0 2015-11-30 stephen.d },
118 e6a3ceb5 2022-11-26 op {
119 e6a3ceb5 2022-11-26 op Type: QTFILE,
120 4b33cdd0 2015-11-30 stephen.d Version: 1112,
121 e6a3ceb5 2022-11-26 op Path: 11114,
122 e6a3ceb5 2022-11-26 op },
123 4b33cdd0 2015-11-30 stephen.d },
124 4b33cdd0 2015-11-30 stephen.d },
125 4b33cdd0 2015-11-30 stephen.d },
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,
131 e6a3ceb5 2022-11-26 op },
132 4b33cdd0 2015-11-30 stephen.d },
133 4b33cdd0 2015-11-30 stephen.d {
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{},
139 15c991ff 2016-11-16 noreply },
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,
143 e6a3ceb5 2022-11-26 op },
144 15c991ff 2016-11-16 noreply },
145 15c991ff 2016-11-16 noreply {
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{},
151 15c991ff 2016-11-16 noreply },
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,
157 e6a3ceb5 2022-11-26 op },
158 15c991ff 2016-11-16 noreply },
159 15c991ff 2016-11-16 noreply {
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"),
166 4b33cdd0 2015-11-30 stephen.d },
167 4b33cdd0 2015-11-30 stephen.d },
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,
172 e6a3ceb5 2022-11-26 op },
173 4b33cdd0 2015-11-30 stephen.d },
174 4b33cdd0 2015-11-30 stephen.d {
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),
187 4b33cdd0 2015-11-30 stephen.d },
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",
196 4b33cdd0 2015-11-30 stephen.d },
197 4b33cdd0 2015-11-30 stephen.d },
198 4b33cdd0 2015-11-30 stephen.d },
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
215 e6a3ceb5 2022-11-26 op },
216 961194b3 2015-12-04 stevvooe },
217 961194b3 2015-12-04 stevvooe {
218 15c991ff 2016-11-16 noreply description: "DirSlice",
219 961194b3 2015-12-04 stevvooe target: []Dir{
220 961194b3 2015-12-04 stevvooe {
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),
227 961194b3 2015-12-04 stevvooe },
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",
236 961194b3 2015-12-04 stevvooe },
237 961194b3 2015-12-04 stevvooe {
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),
244 961194b3 2015-12-04 stevvooe },
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",
253 961194b3 2015-12-04 stevvooe },
254 961194b3 2015-12-04 stevvooe {
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),
261 961194b3 2015-12-04 stevvooe },
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",
270 961194b3 2015-12-04 stevvooe },
271 961194b3 2015-12-04 stevvooe {
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),
278 961194b3 2015-12-04 stevvooe },
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",
287 961194b3 2015-12-04 stevvooe },
288 961194b3 2015-12-04 stevvooe },
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
308 961194b3 2015-12-04 stevvooe
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
327 961194b3 2015-12-04 stevvooe
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
346 961194b3 2015-12-04 stevvooe
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
365 961194b3 2015-12-04 stevvooe },
366 4b33cdd0 2015-11-30 stephen.d },
367 4b33cdd0 2015-11-30 stephen.d {
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,
375 e6a3ceb5 2022-11-26 op },
376 4b33cdd0 2015-11-30 stephen.d },
377 4b33cdd0 2015-11-30 stephen.d } {
378 4b33cdd0 2015-11-30 stephen.d
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)
383 15c991ff 2016-11-16 noreply }
384 4b33cdd0 2015-11-30 stephen.d
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)
387 15c991ff 2016-11-16 noreply }
388 4b33cdd0 2015-11-30 stephen.d
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")
391 15c991ff 2016-11-16 noreply }
392 4b33cdd0 2015-11-30 stephen.d
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))
396 15c991ff 2016-11-16 noreply }
397 4b33cdd0 2015-11-30 stephen.d
398 15c991ff 2016-11-16 noreply var v interface{}
399 15c991ff 2016-11-16 noreply targetType := reflect.TypeOf(testcase.target)
400 4b33cdd0 2015-11-30 stephen.d
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()
405 15c991ff 2016-11-16 noreply }
406 4b33cdd0 2015-11-30 stephen.d
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)
409 15c991ff 2016-11-16 noreply }
410 4b33cdd0 2015-11-30 stephen.d
411 15c991ff 2016-11-16 noreply if targetType.Kind() != reflect.Ptr {
412 15c991ff 2016-11-16 noreply v = reflect.Indirect(reflect.ValueOf(v)).Interface()
413 15c991ff 2016-11-16 noreply }
414 4b33cdd0 2015-11-30 stephen.d
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)
419 15c991ff 2016-11-16 noreply }
420 15c991ff 2016-11-16 noreply })
421 4b33cdd0 2015-11-30 stephen.d }
422 4b33cdd0 2015-11-30 stephen.d }