t_usbhid.c revision 1.3
1/*	$NetBSD: t_usbhid.c,v 1.3 2016/01/01 22:59:12 jakllsch Exp $	*/
2
3/*
4 * Copyright (c) 2016 Jonathan A. Kollasch
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__RCSID("$NetBSD: t_usbhid.c,v 1.3 2016/01/01 22:59:12 jakllsch Exp $");
31
32#include <atf-c.h>
33
34#include <inttypes.h>
35#include <usbhid.h>
36#include <string.h>
37
38#include <stdio.h>
39#include <stdlib.h>
40
41#include <limits.h>
42
43ATF_TC(check_hid_logical_range);
44ATF_TC(check_hid_physical_range);
45ATF_TC(check_hid_usage);
46ATF_TC(check_hid_get_data);
47ATF_TC(check_hid_set_data);
48
49static const uint8_t range_test_report_descriptor[] = {
50	0x0b, 0x03, 0x00, 0x00, 0xff,	// Usage
51	0x75, 0x20,			// Report Size
52	0x95, 0x01,			// Report Count
53	0x17, 0x00, 0x00, 0x00, 0x80,	// Logical Minimum
54	0x27, 0xff, 0xff, 0xff, 0x7f,	// Logical Maximum
55	0x37, 0x00, 0x00, 0x00, 0x80,	// Physical Minimum
56	0x47, 0xff, 0xff, 0xff, 0x7f,	// Physical Maximum
57	0x81, 0x00,			// Input
58
59	0x0b, 0x02, 0x00, 0x00, 0xff,	// Usage
60	0x75, 0x10,			// Report Size
61	0x95, 0x01,			// Report Count
62	0x16, 0x00, 0x80,		// Logical Minimum
63	0x26, 0xff, 0x7f,		// Logical Maximum
64	0x36, 0x00, 0x80,		// Physical Minimum
65	0x46, 0xff, 0x7f,		// Physical Maximum
66	0x81, 0x00,			// Input
67
68	0x0b, 0x01, 0x00, 0x00, 0xff,	// Usage
69	0x75, 0x08,			// Report Size
70	0x95, 0x01,			// Report Count
71	0x15, 0x80,			// Logical Minimum
72	0x25, 0x7f,			// Logical Maximum
73	0x35, 0x80,			// Physical Minimum
74	0x45, 0x7f,			// Physical Maximum
75	0x81, 0x00,			// Input
76};
77
78static const uint8_t unsigned_range_test_report_descriptor[] = {
79	0x0b, 0x13, 0x00, 0x00, 0xff,	// Usage
80	0x75, 0x20,			// Report Size
81	0x95, 0x01,			// Report Count
82	0x17, 0x00, 0x00, 0x00, 0x00,	// Logical Minimum
83	0x27, 0xff, 0xff, 0xff, 0xff,	// Logical Maximum
84	0x37, 0x00, 0x00, 0x00, 0x00,	// Physical Minimum
85	0x47, 0xff, 0xff, 0xff, 0xff,	// Physical Maximum
86	0x81, 0x00,			// Input
87
88	0x0b, 0x12, 0x00, 0x00, 0xff,	// Usage
89	0x75, 0x10,			// Report Size
90	0x95, 0x01,			// Report Count
91	0x16, 0x00, 0x00,		// Logical Minimum
92	0x26, 0xff, 0xff,		// Logical Maximum
93	0x36, 0x00, 0x00,		// Physical Minimum
94	0x46, 0xff, 0xff,		// Physical Maximum
95	0x81, 0x00,			// Input
96
97	0x0b, 0x11, 0x00, 0x00, 0xff,	// Usage
98	0x75, 0x08,			// Report Size
99	0x95, 0x01,			// Report Count
100	0x15, 0x00,			// Logical Minimum
101	0x25, 0xff,			// Logical Maximum
102	0x35, 0x00,			// Physical Minimum
103	0x45, 0xff,			// Physical Maximum
104	0x81, 0x00,			// Input
105};
106
107static const uint8_t range_test_minimum_report[7] = {
108	0x00, 0x00, 0x00, 0x80,
109	0x00, 0x80,
110	0x80,
111};
112
113static const uint8_t unsigned_range_test_minimum_report[7] = {
114	0x00, 0x00, 0x00, 0x00,
115	0x00, 0x00,
116	0x00,
117};
118
119static const uint8_t range_test_maximum_report[7] = {
120	0xff, 0xff, 0xff, 0x7f,
121	0xff, 0x7f,
122	0x7f,
123};
124
125static const uint8_t unsigned_range_test_maximum_report[7] = {
126	0xff, 0xff, 0xff, 0xff,
127	0xff, 0xff,
128	0xff,
129};
130
131static const uint8_t range_test_positive_one_report[7] = {
132	0x01, 0x00, 0x00, 0x00,
133	0x01, 0x00,
134	0x01,
135};
136
137static const uint8_t unsigned_range_test_positive_one_report[7] = {
138	0x01, 0x00, 0x00, 0x00,
139	0x01, 0x00,
140	0x01,
141};
142
143static const uint8_t range_test_negative_one_report[7] = {
144	0xff, 0xff, 0xff, 0xff,
145	0xff, 0xff,
146	0xff,
147};
148
149static const uint8_t unsigned_range_test_negative_one_report[7] = {
150	0xfe, 0xff, 0xff, 0xff,
151	0xfe, 0xff,
152	0xfe,
153};
154
155ATF_TC_HEAD(check_hid_usage, tc)
156{
157
158	atf_tc_set_md_var(tc, "descr", "Test libusbhid usage.c");
159}
160
161ATF_TC_BODY(check_hid_usage, tc)
162{
163	char usages_path[PATH_MAX];
164
165	(void)strlcpy(usages_path, atf_tc_get_config_var(tc, "srcdir"),
166	    sizeof(usages_path));
167	(void)strlcat(usages_path, "/test_usb_hid_usages",
168	    sizeof(usages_path));
169
170	atf_tc_expect_fail("hid_parse_*() fails because it doesn't use "
171	    "scanf()");
172
173	hid_init(usages_path);
174
175	ATF_CHECK_STREQ("t_usbhid_page", hid_usage_page(0xff1b));
176	ATF_CHECK_EQ((uint32_t)hid_parse_usage_page("t_usbhid_page"), 0xff1b);
177
178	ATF_CHECK_STREQ("t_usbhid_usage", hid_usage_in_page(0xff1bff2a));
179	ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
180	    "t_usbhid_page:t_usbhid_usage"), 0xff1bff2a);
181
182	ATF_CHECK_STREQ("Quick_zephyrs_blow_vexing_daft_Jim_",
183	    hid_usage_page(0xff2a));
184	ATF_CHECK_EQ((uint32_t)hid_parse_usage_page(
185	    "Quick_zephyrs_blow_vexing_daft_Jim_"), 0xff2a);
186
187	ATF_CHECK_STREQ("Usage_ID_Zero_%", hid_usage_in_page(0xff2a0000));
188	ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
189	    "Quick_zephyrs_blow_vexing_daft_Jim_:Usage_ID_Zero_%"),
190	    0xff2a0000);
191
192	//ATF_CHECK_STREQ("Usage_ID_0_%", hid_usage_in_page(0xff2a0000));
193	ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
194	    "Quick_zephyrs_blow_vexing_daft_Jim_:Usage_ID_0_%"), 0xff2a0000);
195
196	ATF_CHECK_STREQ("Usage_ID_65535_%", hid_usage_in_page(0xff2affff));
197	ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
198	    "Quick_zephyrs_blow_vexing_daft_Jim_:Usage_ID_65535_%"),
199	    0xff2affff);
200}
201
202#define MYd_ATF_CHECK_EQ(d, v) \
203	ATF_CHECK_EQ_MSG(d, v, "== %d", (d))
204
205#define MYu_ATF_CHECK_EQ(d, v) \
206	ATF_CHECK_EQ_MSG(d, v, "== %u", (d))
207
208ATF_TC_HEAD(check_hid_logical_range, tc)
209{
210
211	atf_tc_set_md_var(tc, "descr", "Test hid_get_item "
212	    "Logical Minimum/Maximum results");
213}
214
215ATF_TC_BODY(check_hid_logical_range, tc)
216{
217	report_desc_t hrd;
218	hid_item_t hi;
219
220	atf_tc_expect_fail("only the 32-bit opcode works, "
221	    "8 and 16-bit is broken");
222
223	ATF_REQUIRE((hrd = hid_use_report_desc(range_test_report_descriptor,
224	    __arraycount(range_test_report_descriptor))) != NULL);
225	ATF_REQUIRE(hid_locate(hrd, 0xff000001U, hid_input, &hi,
226	    NO_REPORT_ID) > 0);
227	MYd_ATF_CHECK_EQ(hi.logical_minimum, -128);
228	MYd_ATF_CHECK_EQ(hi.logical_maximum, 127);
229	ATF_REQUIRE(hid_locate(hrd, 0xff000002U, hid_input, &hi,
230	    NO_REPORT_ID) > 0);
231	MYd_ATF_CHECK_EQ(hi.logical_minimum, -32768);
232	MYd_ATF_CHECK_EQ(hi.logical_maximum, 32767);
233	ATF_REQUIRE(hid_locate(hrd, 0xff000003U, hid_input, &hi,
234	    NO_REPORT_ID) > 0);
235	MYd_ATF_CHECK_EQ(hi.logical_minimum, -2147483648);
236	MYd_ATF_CHECK_EQ(hi.logical_maximum, 2147483647);
237
238	hid_dispose_report_desc(hrd);
239	hrd = NULL;
240
241	ATF_REQUIRE((hrd = hid_use_report_desc(
242	    unsigned_range_test_report_descriptor,
243	    __arraycount(unsigned_range_test_report_descriptor))) != NULL);
244
245	ATF_REQUIRE(hid_locate(hrd, 0xff000011U, hid_input, &hi,
246	    NO_REPORT_ID) > 0);
247	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_minimum, 0);
248	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_maximum, 255);
249	ATF_REQUIRE(hid_locate(hrd, 0xff000012U, hid_input, &hi,
250	    NO_REPORT_ID) > 0);
251	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_minimum, 0);
252	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_maximum, 65535);
253	ATF_REQUIRE(hid_locate(hrd, 0xff000013U, hid_input, &hi,
254	    NO_REPORT_ID) > 0);
255	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_minimum, 0);
256	MYu_ATF_CHECK_EQ((uint32_t)hi.logical_maximum, 4294967295);
257
258	hid_dispose_report_desc(hrd);
259	hrd = NULL;
260}
261
262ATF_TC_HEAD(check_hid_physical_range, tc)
263{
264
265	atf_tc_set_md_var(tc, "descr", "Test hid_get_item "
266	    "Physical Minimum/Maximum results");
267}
268
269ATF_TC_BODY(check_hid_physical_range, tc)
270{
271	report_desc_t hrd;
272	hid_item_t hi;
273
274	atf_tc_expect_fail("only the 32-bit opcode works, "
275	    "8 and 16-bit is broken");
276
277	ATF_REQUIRE((hrd = hid_use_report_desc(range_test_report_descriptor,
278	    __arraycount(range_test_report_descriptor))) != NULL);
279	ATF_REQUIRE(hid_locate(hrd, 0xff000001U, hid_input, &hi,
280	    NO_REPORT_ID) > 0);
281	MYd_ATF_CHECK_EQ(hi.physical_minimum, -128);
282	MYd_ATF_CHECK_EQ(hi.physical_maximum, 127);
283	ATF_REQUIRE(hid_locate(hrd, 0xff000002U, hid_input, &hi,
284	    NO_REPORT_ID) > 0);
285	MYd_ATF_CHECK_EQ(hi.physical_minimum, -32768);
286	MYd_ATF_CHECK_EQ(hi.physical_maximum, 32767);
287	ATF_REQUIRE(hid_locate(hrd, 0xff000003U, hid_input, &hi,
288	    NO_REPORT_ID) > 0);
289	MYd_ATF_CHECK_EQ(hi.physical_minimum, -2147483648);
290	MYd_ATF_CHECK_EQ(hi.physical_maximum, 2147483647);
291
292	hid_dispose_report_desc(hrd);
293	hrd = NULL;
294
295	ATF_REQUIRE((hrd = hid_use_report_desc(
296	    unsigned_range_test_report_descriptor,
297	    __arraycount(unsigned_range_test_report_descriptor))) != NULL);
298
299	ATF_REQUIRE(hid_locate(hrd, 0xff000011U, hid_input, &hi,
300	    NO_REPORT_ID) > 0);
301	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_minimum, 0);
302	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_maximum, 255);
303	ATF_REQUIRE(hid_locate(hrd, 0xff000012U, hid_input, &hi,
304	    NO_REPORT_ID) > 0);
305	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_minimum, 0);
306	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_maximum, 65535);
307	ATF_REQUIRE(hid_locate(hrd, 0xff000013U, hid_input, &hi,
308	    NO_REPORT_ID) > 0);
309	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_minimum, 0);
310	MYu_ATF_CHECK_EQ((uint32_t)hi.physical_maximum, 4294967295);
311
312	hid_dispose_report_desc(hrd);
313	hrd = NULL;
314}
315
316ATF_TC_HEAD(check_hid_get_data, tc)
317{
318
319	atf_tc_set_md_var(tc, "descr", "Test hid_get_data results");
320}
321
322ATF_TC_BODY(check_hid_get_data, tc)
323{
324	report_desc_t hrd;
325	hid_item_t hi;
326	int32_t data;
327	uint32_t udat;
328
329	ATF_REQUIRE((hrd = hid_use_report_desc(
330	    range_test_report_descriptor,
331	    __arraycount(range_test_report_descriptor))) != NULL);
332
333	ATF_REQUIRE(hid_locate(hrd, 0xff000001U, hid_input, &hi,
334	    NO_REPORT_ID) > 0);
335	data = hid_get_data(range_test_minimum_report, &hi);
336	MYd_ATF_CHECK_EQ(data, -128);
337	data = hid_get_data(range_test_negative_one_report, &hi);
338	MYd_ATF_CHECK_EQ(data, -1);
339	data = hid_get_data(range_test_positive_one_report, &hi);
340	MYd_ATF_CHECK_EQ(data, 1);
341	data = hid_get_data(range_test_maximum_report, &hi);
342	MYd_ATF_CHECK_EQ(data, 127);
343
344	ATF_REQUIRE(hid_locate(hrd, 0xff000002U, hid_input, &hi,
345	    NO_REPORT_ID) > 0);
346	data = hid_get_data(range_test_minimum_report, &hi);
347	MYd_ATF_CHECK_EQ(data, -32768);
348	data = hid_get_data(range_test_negative_one_report, &hi);
349	MYd_ATF_CHECK_EQ(data, -1);
350	data = hid_get_data(range_test_positive_one_report, &hi);
351	MYd_ATF_CHECK_EQ(data, 1);
352	data = hid_get_data(range_test_maximum_report, &hi);
353	MYd_ATF_CHECK_EQ(data, 32767);
354
355	ATF_REQUIRE(hid_locate(hrd, 0xff000003U, hid_input, &hi,
356	    NO_REPORT_ID) > 0);
357	data = hid_get_data(range_test_minimum_report, &hi);
358	MYd_ATF_CHECK_EQ(data, -2147483648);
359	data = hid_get_data(range_test_negative_one_report, &hi);
360	MYd_ATF_CHECK_EQ(data, -1);
361	data = hid_get_data(range_test_positive_one_report, &hi);
362	MYd_ATF_CHECK_EQ(data, 1);
363	data = hid_get_data(range_test_maximum_report, &hi);
364	MYd_ATF_CHECK_EQ(data, 2147483647);
365
366	hid_dispose_report_desc(hrd);
367	hrd = NULL;
368
369	ATF_REQUIRE((hrd = hid_use_report_desc(
370	    unsigned_range_test_report_descriptor,
371	    __arraycount(unsigned_range_test_report_descriptor))) != NULL);
372	ATF_REQUIRE(hid_locate(hrd, 0xff000011U, hid_input, &hi,
373	    NO_REPORT_ID) > 0);
374	udat = hid_get_data(unsigned_range_test_minimum_report, &hi);
375	MYu_ATF_CHECK_EQ(udat, 0);
376	udat = hid_get_data(unsigned_range_test_positive_one_report, &hi);
377	MYu_ATF_CHECK_EQ(udat, 1);
378	udat = hid_get_data(unsigned_range_test_negative_one_report, &hi);
379	MYu_ATF_CHECK_EQ(udat, 254);
380	udat = hid_get_data(unsigned_range_test_maximum_report, &hi);
381	MYu_ATF_CHECK_EQ(udat, 255);
382
383	ATF_REQUIRE(hid_locate(hrd, 0xff000012U, hid_input, &hi,
384	    NO_REPORT_ID) > 0);
385	udat = hid_get_data(unsigned_range_test_minimum_report, &hi);
386	MYu_ATF_CHECK_EQ(udat, 0);
387	udat = hid_get_data(unsigned_range_test_positive_one_report, &hi);
388	MYu_ATF_CHECK_EQ(udat, 1);
389	udat = hid_get_data(unsigned_range_test_negative_one_report, &hi);
390	MYu_ATF_CHECK_EQ(udat, 65534);
391	udat = hid_get_data(unsigned_range_test_maximum_report, &hi);
392	MYu_ATF_CHECK_EQ(udat, 65535);
393
394	ATF_REQUIRE(hid_locate(hrd, 0xff000013U, hid_input, &hi,
395	    NO_REPORT_ID) > 0);
396	udat = hid_get_data(unsigned_range_test_minimum_report, &hi);
397	MYu_ATF_CHECK_EQ(udat, 0);
398	udat = hid_get_data(unsigned_range_test_positive_one_report, &hi);
399	MYu_ATF_CHECK_EQ(udat, 1);
400	udat = hid_get_data(unsigned_range_test_negative_one_report, &hi);
401	MYu_ATF_CHECK_EQ(udat, 4294967294);
402	udat = hid_get_data(unsigned_range_test_maximum_report, &hi);
403	MYu_ATF_CHECK_EQ(udat, 4294967295);
404
405	hid_dispose_report_desc(hrd);
406	hrd = NULL;
407}
408
409ATF_TC_HEAD(check_hid_set_data, tc)
410{
411
412	atf_tc_set_md_var(tc, "descr", "Test hid_set_data results");
413}
414
415ATF_TC_BODY(check_hid_set_data, tc)
416{
417	report_desc_t hrd;
418	hid_item_t hi;
419	uint8_t test_data_minimum[7];
420	uint8_t test_data_negative_one[7];
421	uint8_t test_data_positive_one[7];
422	uint8_t test_data_maximum[7];
423
424	ATF_REQUIRE((hrd = hid_use_report_desc(
425	    range_test_report_descriptor,
426	    __arraycount(range_test_report_descriptor))) != NULL);
427	ATF_REQUIRE(hid_locate(hrd, 0xff000001U, hid_input, &hi,
428	    NO_REPORT_ID) > 0);
429	hid_set_data(test_data_minimum, &hi, -128);
430	hid_set_data(test_data_negative_one, &hi, -1);
431	hid_set_data(test_data_positive_one, &hi, 1);
432	hid_set_data(test_data_maximum, &hi, 127);
433	ATF_REQUIRE(hid_locate(hrd, 0xff000002U, hid_input, &hi,
434	    NO_REPORT_ID) > 0);
435	hid_set_data(test_data_minimum, &hi, -32768);
436	hid_set_data(test_data_negative_one, &hi, -1);
437	hid_set_data(test_data_positive_one, &hi, 1);
438	hid_set_data(test_data_maximum, &hi, 32767);
439	ATF_REQUIRE(hid_locate(hrd, 0xff000003U, hid_input, &hi,
440	    NO_REPORT_ID) > 0);
441	hid_set_data(test_data_minimum, &hi, -2147483648);
442	hid_set_data(test_data_negative_one, &hi, -1);
443	hid_set_data(test_data_positive_one, &hi, 1);
444	hid_set_data(test_data_maximum, &hi, 2147483647);
445	ATF_CHECK(memcmp(test_data_minimum, range_test_minimum_report,
446	    sizeof test_data_minimum) == 0);
447	ATF_CHECK(memcmp(test_data_negative_one,
448	    range_test_negative_one_report,
449	    sizeof test_data_negative_one) == 0);
450	ATF_CHECK(memcmp(test_data_positive_one,
451	    range_test_positive_one_report,
452	    sizeof test_data_positive_one) == 0);
453	ATF_CHECK(memcmp(test_data_maximum, range_test_maximum_report,
454	    sizeof test_data_maximum) == 0);
455
456	hid_dispose_report_desc(hrd);
457	hrd = NULL;
458
459	ATF_REQUIRE((hrd = hid_use_report_desc(
460	    unsigned_range_test_report_descriptor,
461	    __arraycount(range_test_report_descriptor))) != NULL);
462	ATF_REQUIRE(hid_locate(hrd, 0xff000011U, hid_input, &hi,
463	    NO_REPORT_ID) > 0);
464	hid_set_data(test_data_minimum, &hi, 0);
465	hid_set_data(test_data_positive_one, &hi, 1);
466	hid_set_data(test_data_negative_one, &hi, 0xfffffffe);
467	hid_set_data(test_data_maximum, &hi, 0xffffffff);
468	ATF_REQUIRE(hid_locate(hrd, 0xff000012U, hid_input, &hi,
469	    NO_REPORT_ID) > 0);
470	hid_set_data(test_data_minimum, &hi, 0);
471	hid_set_data(test_data_positive_one, &hi, 1);
472	hid_set_data(test_data_negative_one, &hi, 0xfffe);
473	hid_set_data(test_data_maximum, &hi, 0xffff);
474	ATF_REQUIRE(hid_locate(hrd, 0xff000013U, hid_input, &hi,
475	    NO_REPORT_ID) > 0);
476	hid_set_data(test_data_minimum, &hi, 0);
477	hid_set_data(test_data_positive_one, &hi, 1);
478	hid_set_data(test_data_negative_one, &hi, 0xfffffffe);
479	hid_set_data(test_data_maximum, &hi, 0xffffffff);
480	ATF_CHECK(memcmp(test_data_minimum,
481	    unsigned_range_test_minimum_report,
482	    sizeof test_data_minimum) == 0);
483	ATF_CHECK(memcmp(test_data_negative_one,
484	    unsigned_range_test_negative_one_report,
485	    sizeof test_data_negative_one) == 0);
486	ATF_CHECK(memcmp(test_data_positive_one,
487	    unsigned_range_test_positive_one_report,
488	    sizeof test_data_positive_one) == 0);
489	ATF_CHECK(memcmp(test_data_maximum,
490	    unsigned_range_test_maximum_report,
491	    sizeof test_data_maximum) == 0);
492
493	hid_dispose_report_desc(hrd);
494	hrd = NULL;
495}
496
497ATF_TP_ADD_TCS(tp)
498{
499
500	ATF_TP_ADD_TC(tp, check_hid_logical_range);
501	ATF_TP_ADD_TC(tp, check_hid_physical_range);
502	ATF_TP_ADD_TC(tp, check_hid_usage);
503	ATF_TP_ADD_TC(tp, check_hid_get_data);
504	ATF_TP_ADD_TC(tp, check_hid_set_data);
505
506	return atf_no_error();
507}
508