xref: /freebsd/contrib/netbsd-tests/lib/libbluetooth/t_sdp_get.c (revision 9268022b74279434ed6300244e3f977e56a8ceb5)
1*57718be8SEnji Cooper /*	$NetBSD: t_sdp_get.c,v 1.2 2011/04/07 08:29:50 plunky Exp $	*/
2*57718be8SEnji Cooper 
3*57718be8SEnji Cooper /*-
4*57718be8SEnji Cooper  * Copyright (c) 2011 The NetBSD Foundation, Inc.
5*57718be8SEnji Cooper  * All rights reserved.
6*57718be8SEnji Cooper  *
7*57718be8SEnji Cooper  * This code is derived from software contributed to The NetBSD Foundation
8*57718be8SEnji Cooper  * by Iain Hibbert.
9*57718be8SEnji Cooper  *
10*57718be8SEnji Cooper  * Redistribution and use in source and binary forms, with or without
11*57718be8SEnji Cooper  * modification, are permitted provided that the following conditions
12*57718be8SEnji Cooper  * are met:
13*57718be8SEnji Cooper  * 1. Redistributions of source code must retain the above copyright
14*57718be8SEnji Cooper  *    notice, this list of conditions and the following disclaimer.
15*57718be8SEnji Cooper  * 2. Redistributions in binary form must reproduce the above copyright
16*57718be8SEnji Cooper  *    notice, this list of conditions and the following disclaimer in the
17*57718be8SEnji Cooper  *    documentation and/or other materials provided with the distribution.
18*57718be8SEnji Cooper  *
19*57718be8SEnji Cooper  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*57718be8SEnji Cooper  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*57718be8SEnji Cooper  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*57718be8SEnji Cooper  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*57718be8SEnji Cooper  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*57718be8SEnji Cooper  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*57718be8SEnji Cooper  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*57718be8SEnji Cooper  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*57718be8SEnji Cooper  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*57718be8SEnji Cooper  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*57718be8SEnji Cooper  * POSSIBILITY OF SUCH DAMAGE.
30*57718be8SEnji Cooper  */
31*57718be8SEnji Cooper 
32*57718be8SEnji Cooper #include <atf-c.h>
33*57718be8SEnji Cooper 
34*57718be8SEnji Cooper #include <limits.h>
35*57718be8SEnji Cooper #include <sdp.h>
36*57718be8SEnji Cooper #include <string.h>
37*57718be8SEnji Cooper 
38*57718be8SEnji Cooper ATF_TC(check_sdp_get_data);
39*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_data,tc)40*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_data, tc)
41*57718be8SEnji Cooper {
42*57718be8SEnji Cooper 
43*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_data results");
44*57718be8SEnji Cooper }
45*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_data,tc)46*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_data, tc)
47*57718be8SEnji Cooper {
48*57718be8SEnji Cooper 	uint8_t data[] = {
49*57718be8SEnji Cooper 		0x09, 0x00, 0x00,	// uint16	0x0000
50*57718be8SEnji Cooper 		0x35, 0x05,		// seq8(5)
51*57718be8SEnji Cooper 		0x19, 0x00, 0x00,	//   uuid16	0x0000
52*57718be8SEnji Cooper 		0x08, 0x00,		//   uint8	0x00
53*57718be8SEnji Cooper 		0x36, 0x00, 0x01,	// seq16(1)
54*57718be8SEnji Cooper 		0x19,			//   uint16	/* invalid */
55*57718be8SEnji Cooper 		0x25, 0x04, 0x54, 0x45,	// str8(4)	"TEST"
56*57718be8SEnji Cooper 		0x53, 0x54,
57*57718be8SEnji Cooper 	};
58*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
59*57718be8SEnji Cooper 	sdp_data_t value, seq;
60*57718be8SEnji Cooper 
61*57718be8SEnji Cooper 	/*
62*57718be8SEnji Cooper 	 * sdp_get_data constructs a new sdp_data_t containing
63*57718be8SEnji Cooper 	 * the next data element, advancing test if successful
64*57718be8SEnji Cooper 	 */
65*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));
66*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT16);
67*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 3);
68*57718be8SEnji Cooper 
69*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));
70*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
71*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 7);
72*57718be8SEnji Cooper 
73*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));
74*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ16);
75*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 4);
76*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_seq(&value, &seq), true);
77*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_data(&seq, &value), false);	/* invalid */
78*57718be8SEnji Cooper 
79*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));
80*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_STR8);
81*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 6);
82*57718be8SEnji Cooper 
83*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
84*57718be8SEnji Cooper }
85*57718be8SEnji Cooper 
86*57718be8SEnji Cooper ATF_TC(check_sdp_get_attr);
87*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_attr,tc)88*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_attr, tc)
89*57718be8SEnji Cooper {
90*57718be8SEnji Cooper 
91*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_attr results");
92*57718be8SEnji Cooper }
93*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_attr,tc)94*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_attr, tc)
95*57718be8SEnji Cooper {
96*57718be8SEnji Cooper 	uint8_t data[] = {
97*57718be8SEnji Cooper 		0x09, 0x00, 0x00,	// uint16	0x0000
98*57718be8SEnji Cooper 		0x35, 0x05,		// seq8(5)
99*57718be8SEnji Cooper 		0x19, 0x00, 0x00,	//   uuid16	0x0000
100*57718be8SEnji Cooper 		0x08, 0x00,		//   uint8	0x00
101*57718be8SEnji Cooper 		0x08, 0x00,		// uint8	0x00
102*57718be8SEnji Cooper 		0x09, 0x00, 0x01,	// uint16	0x0001
103*57718be8SEnji Cooper 		0x19, 0x12, 0x34,	// uuid16	0x1234
104*57718be8SEnji Cooper 	};
105*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
106*57718be8SEnji Cooper 	sdp_data_t value;
107*57718be8SEnji Cooper 	uint16_t attr;
108*57718be8SEnji Cooper 
109*57718be8SEnji Cooper 	/*
110*57718be8SEnji Cooper 	 * sdp_get_attr expects a UINT16 followed by any data item
111*57718be8SEnji Cooper 	 * and advances test if successful
112*57718be8SEnji Cooper 	 */
113*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
114*57718be8SEnji Cooper 	ATF_CHECK_EQ(attr, 0x0000);
115*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
116*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 7);
117*57718be8SEnji Cooper 
118*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_attr(&test, &attr, &value), false);
119*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));
120*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT8);
121*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 2);
122*57718be8SEnji Cooper 
123*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
124*57718be8SEnji Cooper 	ATF_CHECK_EQ(attr, 0x0001);
125*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UUID16);
126*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_size(&value), 3);
127*57718be8SEnji Cooper 
128*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
129*57718be8SEnji Cooper }
130*57718be8SEnji Cooper 
131*57718be8SEnji Cooper ATF_TC(check_sdp_get_uuid);
132*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_uuid,tc)133*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_uuid, tc)
134*57718be8SEnji Cooper {
135*57718be8SEnji Cooper 
136*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_uuid results");
137*57718be8SEnji Cooper }
138*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_uuid,tc)139*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_uuid, tc)
140*57718be8SEnji Cooper {
141*57718be8SEnji Cooper 	uint8_t data[] = {
142*57718be8SEnji Cooper 		0x19, 0x12, 0x34,	// uuid16	0x1234
143*57718be8SEnji Cooper 		0x1a, 0x11, 0x22, 0x33,	// uuid32	0x11223344
144*57718be8SEnji Cooper 		0x44,
145*57718be8SEnji Cooper 		0x00,			// nil
146*57718be8SEnji Cooper 		0x1c,			// uuid128	0x00112233-4444--5555-6666-778899aabbcc
147*57718be8SEnji Cooper 		0x00, 0x11, 0x22, 0x33,
148*57718be8SEnji Cooper 		0x44, 0x44, 0x55, 0x55,
149*57718be8SEnji Cooper 		0x66, 0x66, 0x77, 0x88,
150*57718be8SEnji Cooper 		0x99, 0xaa, 0xbb, 0xcc,
151*57718be8SEnji Cooper 	};
152*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
153*57718be8SEnji Cooper 	uuid_t u16 = {
154*57718be8SEnji Cooper 		0x00001234,
155*57718be8SEnji Cooper 		0x0000,
156*57718be8SEnji Cooper 		0x1000,
157*57718be8SEnji Cooper 		0x80,
158*57718be8SEnji Cooper 		0x00,
159*57718be8SEnji Cooper 		{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
160*57718be8SEnji Cooper 	};
161*57718be8SEnji Cooper 	uuid_t u32 = {
162*57718be8SEnji Cooper 		0x11223344,
163*57718be8SEnji Cooper 		0x0000,
164*57718be8SEnji Cooper 		0x1000,
165*57718be8SEnji Cooper 		0x80,
166*57718be8SEnji Cooper 		0x00,
167*57718be8SEnji Cooper 		{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
168*57718be8SEnji Cooper 	};
169*57718be8SEnji Cooper 	uuid_t u128 = {
170*57718be8SEnji Cooper 		0x00112233,
171*57718be8SEnji Cooper 		0x4444,
172*57718be8SEnji Cooper 		0x5555,
173*57718be8SEnji Cooper 		0x66,
174*57718be8SEnji Cooper 		0x66,
175*57718be8SEnji Cooper 		{ 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc }
176*57718be8SEnji Cooper 	};
177*57718be8SEnji Cooper 	sdp_data_t nil;
178*57718be8SEnji Cooper 	uuid_t value;
179*57718be8SEnji Cooper 
180*57718be8SEnji Cooper 	/*
181*57718be8SEnji Cooper 	 * sdp_get_uuid expects any UUID type returns the full uuid
182*57718be8SEnji Cooper 	 * advancing test if successful
183*57718be8SEnji Cooper 	 */
184*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uuid(&test, &value));
185*57718be8SEnji Cooper 	ATF_CHECK(uuid_equal(&value, &u16, NULL));
186*57718be8SEnji Cooper 
187*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uuid(&test, &value));
188*57718be8SEnji Cooper 	ATF_CHECK(uuid_equal(&value, &u32, NULL));
189*57718be8SEnji Cooper 
190*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_uuid(&test, &value), false);	/* not uuid */
191*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
192*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
193*57718be8SEnji Cooper 
194*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uuid(&test, &value));
195*57718be8SEnji Cooper 	ATF_CHECK(uuid_equal(&value, &u128, NULL));
196*57718be8SEnji Cooper 
197*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
198*57718be8SEnji Cooper }
199*57718be8SEnji Cooper 
200*57718be8SEnji Cooper ATF_TC(check_sdp_get_bool);
201*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_bool,tc)202*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_bool, tc)
203*57718be8SEnji Cooper {
204*57718be8SEnji Cooper 
205*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_bool results");
206*57718be8SEnji Cooper }
207*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_bool,tc)208*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_bool, tc)
209*57718be8SEnji Cooper {
210*57718be8SEnji Cooper 	uint8_t data[] = {
211*57718be8SEnji Cooper 		0x28, 0x00,	// bool		false
212*57718be8SEnji Cooper 		0x00,		// nil
213*57718be8SEnji Cooper 		0x28, 0x01,	// bool		true
214*57718be8SEnji Cooper 	};
215*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
216*57718be8SEnji Cooper 	sdp_data_t nil;
217*57718be8SEnji Cooper 	bool value;
218*57718be8SEnji Cooper 
219*57718be8SEnji Cooper 	/*
220*57718be8SEnji Cooper 	 * sdp_get_bool expects a BOOL type
221*57718be8SEnji Cooper 	 * advancing test if successful
222*57718be8SEnji Cooper 	 */
223*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_bool(&test, &value));
224*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, false);
225*57718be8SEnji Cooper 
226*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_bool(&test, &value), false);	/* not bool */
227*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
228*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
229*57718be8SEnji Cooper 
230*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_bool(&test, &value));
231*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, true);
232*57718be8SEnji Cooper 
233*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
234*57718be8SEnji Cooper }
235*57718be8SEnji Cooper 
236*57718be8SEnji Cooper ATF_TC(check_sdp_get_uint);
237*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_uint,tc)238*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_uint, tc)
239*57718be8SEnji Cooper {
240*57718be8SEnji Cooper 
241*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_uint results");
242*57718be8SEnji Cooper }
243*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_uint,tc)244*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_uint, tc)
245*57718be8SEnji Cooper {
246*57718be8SEnji Cooper 	uint8_t data[] = {
247*57718be8SEnji Cooper 		0x08, 0x00,		// uint8	0x00
248*57718be8SEnji Cooper 		0x08, 0xff,		// uint8	0xff
249*57718be8SEnji Cooper 		0x09, 0x01, 0x02,	// uint16	0x0102
250*57718be8SEnji Cooper 		0x09, 0xff, 0xff,	// uint16	0xffff
251*57718be8SEnji Cooper 		0x00,			// nil
252*57718be8SEnji Cooper 		0x0a, 0x01, 0x02, 0x03,	// uint32	0x01020304
253*57718be8SEnji Cooper 		0x04,
254*57718be8SEnji Cooper 		0x0a, 0xff, 0xff, 0xff,	// uint32	0xffffffff
255*57718be8SEnji Cooper 		0xff,
256*57718be8SEnji Cooper 		0x0b, 0x01, 0x02, 0x03,	// uint64	0x0102030405060708
257*57718be8SEnji Cooper 		0x04, 0x05, 0x06, 0x07,
258*57718be8SEnji Cooper 		0x08,
259*57718be8SEnji Cooper 		0x0b, 0xff, 0xff, 0xff,	// uint64	0xffffffffffffffff
260*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,
261*57718be8SEnji Cooper 		0xff,
262*57718be8SEnji Cooper 		0x0c, 0x00, 0x00, 0x00,	// uint128	0x00000000000000000000000000000000
263*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
264*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
265*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
266*57718be8SEnji Cooper 		0x00,
267*57718be8SEnji Cooper 		0x0c, 0x00, 0x00, 0x00,	// uint128	0x00000000000000010000000000000000
268*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
269*57718be8SEnji Cooper 		0x01, 0x00, 0x00, 0x00,
270*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
271*57718be8SEnji Cooper 		0x00,
272*57718be8SEnji Cooper 		0x0c, 0x00, 0x00, 0x00,	// uint128	0x0000000000000000ffffffffffffffff
273*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
274*57718be8SEnji Cooper 		0x00, 0xff, 0xff, 0xff,
275*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,
276*57718be8SEnji Cooper 		0xff,
277*57718be8SEnji Cooper 	};
278*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
279*57718be8SEnji Cooper 	sdp_data_t nil;
280*57718be8SEnji Cooper 	uintmax_t value;
281*57718be8SEnji Cooper 
282*57718be8SEnji Cooper 	/*
283*57718be8SEnji Cooper 	 * sdp_get_uint expects any UINT type, advancing test if successful
284*57718be8SEnji Cooper 	 */
285*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
286*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x00);
287*57718be8SEnji Cooper 
288*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
289*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, UINT8_MAX);
290*57718be8SEnji Cooper 
291*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
292*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x0102);
293*57718be8SEnji Cooper 
294*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
295*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, UINT16_MAX);
296*57718be8SEnji Cooper 
297*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false);	/* not uint */
298*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
299*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
300*57718be8SEnji Cooper 
301*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
302*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x01020304);
303*57718be8SEnji Cooper 
304*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
305*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, UINT32_MAX);
306*57718be8SEnji Cooper 
307*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
308*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x0102030405060708);
309*57718be8SEnji Cooper 
310*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
311*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, UINT64_MAX);
312*57718be8SEnji Cooper 
313*57718be8SEnji Cooper 	/*
314*57718be8SEnji Cooper 	 * expected failure is that we cannot decode UINT128 values larger than UINT64
315*57718be8SEnji Cooper 	 */
316*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
317*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x00000000000000000000000000000000);
318*57718be8SEnji Cooper 
319*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false);	/* overflow */
320*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
321*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_UINT128);
322*57718be8SEnji Cooper 
323*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_uint(&test, &value));
324*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, UINT64_MAX);
325*57718be8SEnji Cooper 
326*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
327*57718be8SEnji Cooper }
328*57718be8SEnji Cooper 
329*57718be8SEnji Cooper ATF_TC(check_sdp_get_int);
330*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_int,tc)331*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_int, tc)
332*57718be8SEnji Cooper {
333*57718be8SEnji Cooper 
334*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_int results");
335*57718be8SEnji Cooper }
336*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_int,tc)337*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_int, tc)
338*57718be8SEnji Cooper {
339*57718be8SEnji Cooper 	uint8_t data[] = {
340*57718be8SEnji Cooper 		0x10, 0x00,		// int8		0x00
341*57718be8SEnji Cooper 		0x10, 0x7f,		// int8		0x7f
342*57718be8SEnji Cooper 		0x10, 0x80,		// int8		0x80
343*57718be8SEnji Cooper 		0x11, 0x01, 0x02,	// int16	0x0102
344*57718be8SEnji Cooper 		0x11, 0x7f, 0xff,	// int16	0x7fff
345*57718be8SEnji Cooper 		0x11, 0x80, 0x00,	// int16	0x8000
346*57718be8SEnji Cooper 		0x00,			// nil
347*57718be8SEnji Cooper 		0x12, 0x01, 0x02, 0x03,	// int32	0x01020304
348*57718be8SEnji Cooper 		0x04,
349*57718be8SEnji Cooper 		0x12, 0x7f, 0xff, 0xff,	// int32	0x7fffffff
350*57718be8SEnji Cooper 		0xff,
351*57718be8SEnji Cooper 		0x12, 0x80, 0x00, 0x00,	// int32	0x80000000
352*57718be8SEnji Cooper 		0x00,
353*57718be8SEnji Cooper 		0x13, 0x01, 0x02, 0x03,	// int64	0x0102030405060708
354*57718be8SEnji Cooper 		0x04, 0x05, 0x06, 0x07,
355*57718be8SEnji Cooper 		0x08,
356*57718be8SEnji Cooper 		0x13, 0x7f, 0xff, 0xff,	// int64	0x7fffffffffffffff
357*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,
358*57718be8SEnji Cooper 		0xff,
359*57718be8SEnji Cooper 		0x13, 0x80, 0x00, 0x00,	// int64	0x8000000000000000
360*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
361*57718be8SEnji Cooper 		0x00,
362*57718be8SEnji Cooper 		0x14, 0x00, 0x00, 0x00,	// int128	0x00000000000000000000000000000000
363*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
364*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
365*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
366*57718be8SEnji Cooper 		0x00,
367*57718be8SEnji Cooper 		0x14, 0x00, 0x00, 0x00,	// int128	0x00000000000000007fffffffffffffff
368*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,	//			(INT64_MAX)
369*57718be8SEnji Cooper 		0x00, 0x7f, 0xff, 0xff,
370*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,
371*57718be8SEnji Cooper 		0xff,
372*57718be8SEnji Cooper 		0x14, 0x00, 0x00, 0x00,	// int128	0x00000000000000008000000000000000
373*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,	//			(INT64_MAX + 1)
374*57718be8SEnji Cooper 		0x00, 0x80, 0x00, 0x00,
375*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
376*57718be8SEnji Cooper 		0x00,
377*57718be8SEnji Cooper 		0x14, 0xff, 0xff, 0xff,	// int128	0xffffffffffffffff8000000000000000
378*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,	//			(INT64_MIN)
379*57718be8SEnji Cooper 		0xff, 0x80, 0x00, 0x00,
380*57718be8SEnji Cooper 		0x00, 0x00, 0x00, 0x00,
381*57718be8SEnji Cooper 		0x00,
382*57718be8SEnji Cooper 		0x14, 0xff, 0xff, 0xff,	// int128	0xffffffffffffffff7fffffffffffffff
383*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,	//			(INT64_MIN - 1)
384*57718be8SEnji Cooper 		0xff, 0x7f, 0xff, 0xff,
385*57718be8SEnji Cooper 		0xff, 0xff, 0xff, 0xff,
386*57718be8SEnji Cooper 		0xff,
387*57718be8SEnji Cooper 	};
388*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
389*57718be8SEnji Cooper 	sdp_data_t nil;
390*57718be8SEnji Cooper 	intmax_t value;
391*57718be8SEnji Cooper 
392*57718be8SEnji Cooper 	/*
393*57718be8SEnji Cooper 	 * sdp_get_int expects any INT type, advancing test if successful
394*57718be8SEnji Cooper 	 */
395*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
396*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0);
397*57718be8SEnji Cooper 
398*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
399*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT8_MAX);
400*57718be8SEnji Cooper 
401*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
402*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT8_MIN);
403*57718be8SEnji Cooper 
404*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
405*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x0102);
406*57718be8SEnji Cooper 
407*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
408*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT16_MAX);
409*57718be8SEnji Cooper 
410*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
411*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT16_MIN);
412*57718be8SEnji Cooper 
413*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false);	/* not int */
414*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
415*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
416*57718be8SEnji Cooper 
417*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
418*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x01020304);
419*57718be8SEnji Cooper 
420*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
421*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT32_MAX);
422*57718be8SEnji Cooper 
423*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
424*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT32_MIN);
425*57718be8SEnji Cooper 
426*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
427*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0x0102030405060708);
428*57718be8SEnji Cooper 
429*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
430*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT64_MAX);
431*57718be8SEnji Cooper 
432*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
433*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT64_MIN);
434*57718be8SEnji Cooper 
435*57718be8SEnji Cooper 	/*
436*57718be8SEnji Cooper 	 * expected failure is that we cannot decode INT128 values larger than INT64
437*57718be8SEnji Cooper 	 */
438*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
439*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, 0);
440*57718be8SEnji Cooper 
441*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
442*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT64_MAX);
443*57718be8SEnji Cooper 
444*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false);	/* overflow */
445*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
446*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
447*57718be8SEnji Cooper 
448*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_int(&test, &value));
449*57718be8SEnji Cooper 	ATF_CHECK_EQ(value, INT64_MIN);
450*57718be8SEnji Cooper 
451*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false);	/* underflow */
452*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
453*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
454*57718be8SEnji Cooper 
455*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
456*57718be8SEnji Cooper }
457*57718be8SEnji Cooper 
458*57718be8SEnji Cooper ATF_TC(check_sdp_get_seq);
459*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_seq,tc)460*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_seq, tc)
461*57718be8SEnji Cooper {
462*57718be8SEnji Cooper 
463*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_seq results");
464*57718be8SEnji Cooper }
465*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_seq,tc)466*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_seq, tc)
467*57718be8SEnji Cooper {
468*57718be8SEnji Cooper 	uint8_t data[] = {
469*57718be8SEnji Cooper 		0x35, 0x00,		// seq8(0)
470*57718be8SEnji Cooper 		0x00,			// nil
471*57718be8SEnji Cooper 		0x36, 0x00, 0x00,	// seq16(0)
472*57718be8SEnji Cooper 		0x37, 0x00, 0x00, 0x00,	// seq32(0)
473*57718be8SEnji Cooper 		0x00,
474*57718be8SEnji Cooper 	};
475*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
476*57718be8SEnji Cooper 	sdp_data_t value;
477*57718be8SEnji Cooper 
478*57718be8SEnji Cooper 	/*
479*57718be8SEnji Cooper 	 * sdp_get_seq expects a SEQ type
480*57718be8SEnji Cooper 	 * advancing test if successful
481*57718be8SEnji Cooper 	 */
482*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_seq(&test, &value));
483*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
484*57718be8SEnji Cooper 
485*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_seq(&test, &value), false);	/* not seq */
486*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));		/* (skip) */
487*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
488*57718be8SEnji Cooper 
489*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_seq(&test, &value));
490*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
491*57718be8SEnji Cooper 
492*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_seq(&test, &value));
493*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
494*57718be8SEnji Cooper 
495*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
496*57718be8SEnji Cooper }
497*57718be8SEnji Cooper 
498*57718be8SEnji Cooper ATF_TC(check_sdp_get_alt);
499*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_alt,tc)500*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_alt, tc)
501*57718be8SEnji Cooper {
502*57718be8SEnji Cooper 
503*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_alt results");
504*57718be8SEnji Cooper }
505*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_alt,tc)506*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_alt, tc)
507*57718be8SEnji Cooper {
508*57718be8SEnji Cooper 	uint8_t data[] = {
509*57718be8SEnji Cooper 		0x3d, 0x00,		// alt8(0)
510*57718be8SEnji Cooper 		0x00,			// nil
511*57718be8SEnji Cooper 		0x3e, 0x00, 0x00,	// alt16(0)
512*57718be8SEnji Cooper 		0x3f, 0x00, 0x00, 0x00,	// alt32(0)
513*57718be8SEnji Cooper 		0x00,
514*57718be8SEnji Cooper 	};
515*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
516*57718be8SEnji Cooper 	sdp_data_t value;
517*57718be8SEnji Cooper 
518*57718be8SEnji Cooper 	/*
519*57718be8SEnji Cooper 	 * sdp_get_alt expects a ALT type
520*57718be8SEnji Cooper 	 * advancing test if successful
521*57718be8SEnji Cooper 	 */
522*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_alt(&test, &value));
523*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
524*57718be8SEnji Cooper 
525*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_alt(&test, &value), false);	/* not alt */
526*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &value));		/* (skip) */
527*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
528*57718be8SEnji Cooper 
529*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_alt(&test, &value));
530*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
531*57718be8SEnji Cooper 
532*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_alt(&test, &value));
533*57718be8SEnji Cooper 	ATF_CHECK_EQ(value.next, value.end);
534*57718be8SEnji Cooper 
535*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
536*57718be8SEnji Cooper }
537*57718be8SEnji Cooper 
538*57718be8SEnji Cooper ATF_TC(check_sdp_get_str);
539*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_str,tc)540*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_str, tc)
541*57718be8SEnji Cooper {
542*57718be8SEnji Cooper 
543*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_str results");
544*57718be8SEnji Cooper }
545*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_str,tc)546*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_str, tc)
547*57718be8SEnji Cooper {
548*57718be8SEnji Cooper 	uint8_t data[] = {
549*57718be8SEnji Cooper 		0x25, 0x04, 0x53, 0x54, // str8(4)	"STR8"
550*57718be8SEnji Cooper 		0x52, 0x38,
551*57718be8SEnji Cooper 		0x00,			// nil
552*57718be8SEnji Cooper 		0x26, 0x00, 0x05, 0x53,	// str16(5)	"STR16"
553*57718be8SEnji Cooper 		0x54, 0x52, 0x31, 0x36,
554*57718be8SEnji Cooper 		0x27, 0x00, 0x00, 0x00,	// str32(5)	"STR32"
555*57718be8SEnji Cooper 		0x05, 0x53, 0x54, 0x52,
556*57718be8SEnji Cooper 		0x33, 0x32,
557*57718be8SEnji Cooper 	};
558*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
559*57718be8SEnji Cooper 	sdp_data_t nil;
560*57718be8SEnji Cooper 	char *str;
561*57718be8SEnji Cooper 	size_t len;
562*57718be8SEnji Cooper 
563*57718be8SEnji Cooper 	/*
564*57718be8SEnji Cooper 	 * sdp_get_str expects a STR type
565*57718be8SEnji Cooper 	 * advancing test if successful
566*57718be8SEnji Cooper 	 */
567*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_str(&test, &str, &len));
568*57718be8SEnji Cooper 	ATF_CHECK(len == 4 && strncmp(str, "STR8", 4) == 0);
569*57718be8SEnji Cooper 
570*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_str(&test, &str, &len), false);	/* not str */
571*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
572*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
573*57718be8SEnji Cooper 
574*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_str(&test, &str, &len));
575*57718be8SEnji Cooper 	ATF_CHECK(len == 5 && strncmp(str, "STR16", 5) == 0);
576*57718be8SEnji Cooper 
577*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_str(&test, &str, &len));
578*57718be8SEnji Cooper 	ATF_CHECK(len == 5 && strncmp(str, "STR32", 5) == 0);
579*57718be8SEnji Cooper 
580*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
581*57718be8SEnji Cooper }
582*57718be8SEnji Cooper 
583*57718be8SEnji Cooper ATF_TC(check_sdp_get_url);
584*57718be8SEnji Cooper 
ATF_TC_HEAD(check_sdp_get_url,tc)585*57718be8SEnji Cooper ATF_TC_HEAD(check_sdp_get_url, tc)
586*57718be8SEnji Cooper {
587*57718be8SEnji Cooper 
588*57718be8SEnji Cooper 	atf_tc_set_md_var(tc, "descr", "Test sdp_get_url results");
589*57718be8SEnji Cooper }
590*57718be8SEnji Cooper 
ATF_TC_BODY(check_sdp_get_url,tc)591*57718be8SEnji Cooper ATF_TC_BODY(check_sdp_get_url, tc)
592*57718be8SEnji Cooper {
593*57718be8SEnji Cooper 	uint8_t data[] = {
594*57718be8SEnji Cooper 		0x45, 0x04, 0x55, 0x52, // url8(4)	"URL8"
595*57718be8SEnji Cooper 		0x4c, 0x38,
596*57718be8SEnji Cooper 		0x00,			// nil
597*57718be8SEnji Cooper 		0x46, 0x00, 0x05, 0x55,	// url16(5)	"URL16"
598*57718be8SEnji Cooper 		0x52, 0x4c, 0x31, 0x36,
599*57718be8SEnji Cooper 		0x47, 0x00, 0x00, 0x00,	// url32(5)	"URL32"
600*57718be8SEnji Cooper 		0x05, 0x55, 0x52, 0x4c,
601*57718be8SEnji Cooper 		0x33, 0x32,
602*57718be8SEnji Cooper 	};
603*57718be8SEnji Cooper 	sdp_data_t test = { data, data + sizeof(data) };
604*57718be8SEnji Cooper 	sdp_data_t nil;
605*57718be8SEnji Cooper 	char *url;
606*57718be8SEnji Cooper 	size_t len;
607*57718be8SEnji Cooper 
608*57718be8SEnji Cooper 	/*
609*57718be8SEnji Cooper 	 * sdp_get_url expects a URL type
610*57718be8SEnji Cooper 	 * advancing test if successful
611*57718be8SEnji Cooper 	 */
612*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_url(&test, &url, &len));
613*57718be8SEnji Cooper 	ATF_CHECK(len == 4 && strncmp(url, "URL8", 4) == 0);
614*57718be8SEnji Cooper 
615*57718be8SEnji Cooper 	ATF_REQUIRE_EQ(sdp_get_url(&test, &url, &len), false);	/* not url */
616*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_data(&test, &nil));			/* (skip) */
617*57718be8SEnji Cooper 	ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
618*57718be8SEnji Cooper 
619*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_url(&test, &url, &len));
620*57718be8SEnji Cooper 	ATF_CHECK(len == 5 && strncmp(url, "URL16", 5) == 0);
621*57718be8SEnji Cooper 
622*57718be8SEnji Cooper 	ATF_REQUIRE(sdp_get_url(&test, &url, &len));
623*57718be8SEnji Cooper 	ATF_CHECK(len == 5 && strncmp(url, "URL32", 5) == 0);
624*57718be8SEnji Cooper 
625*57718be8SEnji Cooper 	ATF_CHECK_EQ(test.next, test.end);
626*57718be8SEnji Cooper }
627*57718be8SEnji Cooper 
ATF_TP_ADD_TCS(tp)628*57718be8SEnji Cooper ATF_TP_ADD_TCS(tp)
629*57718be8SEnji Cooper {
630*57718be8SEnji Cooper 
631*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_data);
632*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_attr);
633*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_uuid);
634*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_bool);
635*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_uint);
636*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_int);
637*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_seq);
638*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_alt);
639*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_str);
640*57718be8SEnji Cooper 	ATF_TP_ADD_TC(tp, check_sdp_get_url);
641*57718be8SEnji Cooper 
642*57718be8SEnji Cooper 	return atf_no_error();
643*57718be8SEnji Cooper }
644