Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests for libusbhid (many of which fail)



details:   https://anonhg.NetBSD.org/src/rev/6b4c3f0b1cd8
branches:  trunk
changeset: 342620:6b4c3f0b1cd8
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Fri Jan 01 21:38:53 2016 +0000

description:
tests for libusbhid (many of which fail)

diffstat:

 distrib/sets/lists/debug/mi             |    3 +-
 distrib/sets/lists/tests/mi             |    7 +-
 etc/mtree/NetBSD.dist.tests             |    4 +-
 tests/lib/Makefile                      |    4 +-
 tests/lib/libusbhid/Makefile            |   15 +
 tests/lib/libusbhid/t_usbhid.c          |  510 ++++++++++++++++++++++++++++++++
 tests/lib/libusbhid/test_usb_hid_usages |   17 +
 7 files changed, 555 insertions(+), 5 deletions(-)

diffs (truncated from 640 to 300 lines):

diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Fri Jan 01 20:48:15 2016 +0000
+++ b/distrib/sets/lists/debug/mi       Fri Jan 01 21:38:53 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.138 2015/12/18 19:00:45 christos Exp $
+# $NetBSD: mi,v 1.139 2016/01/01 21:38:53 jakllsch Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -2149,6 +2149,7 @@
 ./usr/libdata/debug/usr/tests/lib/libtre/h_regex_att.debug             tests-obsolete          obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libtre/t_exhaust.debug               tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libtre/t_regex_att.debug             tests-lib-debug         debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libusbhid/t_usbhid.debug             tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libutil/t_efun.debug                 tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libutil/t_parsedate.debug            tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libutil/t_pidfile.debug              tests-lib-debug         debug,atf,compattestfile
diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Jan 01 20:48:15 2016 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Jan 01 21:38:53 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.657 2015/12/05 18:47:43 christos Exp $
+# $NetBSD: mi,v 1.658 2016/01/01 21:38:54 jakllsch Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -131,6 +131,7 @@
 ./usr/libdata/debug/usr/tests/lib/libskey                              tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libsljit                             tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libtre                               tests-lib-debug         compattestfile,atf
+./usr/libdata/debug/usr/tests/lib/libusbhid                            tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libutil                              tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/semaphore                            tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/semaphore/pthread                    tests-lib-debug         compattestfile,atf
@@ -3042,6 +3043,10 @@
 ./usr/tests/lib/libtre/h_regex_att             tests-obsolete          obsolete
 ./usr/tests/lib/libtre/t_exhaust               tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libtre/t_regex_att             tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libusbhid                      tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libusbhid/Atffile              tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libusbhid/t_usbhid             tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libusbhid/test_usb_hid_usages  tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libutil                                tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libutil/Atffile                        tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libutil/Kyuafile               tests-lib-tests         compattestfile,atf,kyua
diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Fri Jan 01 20:48:15 2016 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Fri Jan 01 21:38:53 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.122 2015/12/04 17:20:12 christos Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.123 2016/01/01 21:38:54 jakllsch Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -119,6 +119,7 @@
 ./usr/libdata/debug/usr/tests/lib/libskey
 ./usr/libdata/debug/usr/tests/lib/libsljit
 ./usr/libdata/debug/usr/tests/lib/libtre
+./usr/libdata/debug/usr/tests/lib/libusbhid
 ./usr/libdata/debug/usr/tests/lib/libutil
 ./usr/libdata/debug/usr/tests/libexec
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so
@@ -300,6 +301,7 @@
 ./usr/tests/lib/libsljit
 ./usr/tests/lib/libtre
 ./usr/tests/lib/libtre/data
+./usr/tests/lib/libusbhid
 ./usr/tests/lib/libutil
 ./usr/tests/libexec
 ./usr/tests/libexec/ld.elf_so
diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 tests/lib/Makefile
--- a/tests/lib/Makefile        Fri Jan 01 20:48:15 2016 +0000
+++ b/tests/lib/Makefile        Fri Jan 01 21:38:53 2016 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.24 2015/06/22 00:05:23 matt Exp $
+# $NetBSD: Makefile,v 1.25 2016/01/01 21:38:54 jakllsch Exp $
 
 .include <bsd.own.mk>
 
 TESTS_SUBDIRS= csu libbluetooth libc libcrypt libcurses libevent libexecinfo \
                libm libobjc libposix libppath libprop libpthread \
-               librt libtre libutil semaphore
+               librt libtre libusbhid libutil semaphore
 
 .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
 TESTS_SUBDIRS+= librumpclient librumphijack
diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 tests/lib/libusbhid/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libusbhid/Makefile      Fri Jan 01 21:38:53 2016 +0000
@@ -0,0 +1,15 @@
+#      $NetBSD: Makefile,v 1.1 2016/01/01 21:38:54 jakllsch Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/lib/libusbhid
+
+DPADD+=                ${LIBUSBHID}
+LDADD+=                -lusbhid
+
+TESTS_C+=      t_usbhid
+
+FILES=          test_usb_hid_usages
+FILESDIR=       ${TESTSDIR}
+
+.include <bsd.test.mk>
diff -r 3b7b8cde97af -r 6b4c3f0b1cd8 tests/lib/libusbhid/t_usbhid.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libusbhid/t_usbhid.c    Fri Jan 01 21:38:53 2016 +0000
@@ -0,0 +1,510 @@
+/*     $NetBSD: t_usbhid.c,v 1.1 2016/01/01 21:38:54 jakllsch Exp $    */
+
+/*
+ * Copyright (c) 2016 Jonathan A. Kollasch
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_usbhid.c,v 1.1 2016/01/01 21:38:54 jakllsch Exp $");
+
+#include <atf-c.h>
+
+#include <inttypes.h>
+#include <usbhid.h>
+#include <string.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <limits.h>
+
+ATF_TC(check_hid_logical_range);
+ATF_TC(check_hid_physical_range);
+ATF_TC(check_hid_usage);
+ATF_TC(check_hid_get_data);
+ATF_TC(check_hid_set_data);
+
+static const uint8_t range_test_report_descriptor[] = {
+       0x0b, 0x03, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x20,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x17, 0x00, 0x00, 0x00, 0x80,   // Logical Minimum
+       0x27, 0xff, 0xff, 0xff, 0x7f,   // Logical Maximum
+       0x37, 0x00, 0x00, 0x00, 0x80,   // Physical Minimum
+       0x47, 0xff, 0xff, 0xff, 0x7f,   // Physical Maximum
+       0x81, 0x00,                     // Input
+
+       0x0b, 0x02, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x10,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x16, 0x00, 0x80,               // Logical Minimum
+       0x26, 0xff, 0x7f,               // Logical Maximum
+       0x36, 0x00, 0x80,               // Physical Minimum
+       0x46, 0xff, 0x7f,               // Physical Maximum
+       0x81, 0x00,                     // Input
+
+       0x0b, 0x01, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x08,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x15, 0x80,                     // Logical Minimum
+       0x25, 0x7f,                     // Logical Maximum
+       0x35, 0x80,                     // Physical Minimum
+       0x45, 0x7f,                     // Physical Maximum
+       0x81, 0x00,                     // Input
+};
+
+static const uint8_t unsigned_range_test_report_descriptor[] = {
+       0x0b, 0x13, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x20,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x17, 0x00, 0x00, 0x00, 0x00,   // Logical Minimum
+       0x27, 0xff, 0xff, 0xff, 0xff,   // Logical Maximum
+       0x37, 0x00, 0x00, 0x00, 0x00,   // Physical Minimum
+       0x47, 0xff, 0xff, 0xff, 0xff,   // Physical Maximum
+       0x81, 0x00,                     // Input
+
+       0x0b, 0x12, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x10,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x16, 0x00, 0x00,               // Logical Minimum
+       0x26, 0xff, 0xff,               // Logical Maximum
+       0x36, 0x00, 0x00,               // Physical Minimum
+       0x46, 0xff, 0xff,               // Physical Maximum
+       0x81, 0x00,                     // Input
+
+       0x0b, 0x11, 0x00, 0x00, 0xff,   // Usage
+       0x75, 0x08,                     // Report Size
+       0x95, 0x01,                     // Report Count
+       0x15, 0x00,                     // Logical Minimum
+       0x25, 0xff,                     // Logical Maximum
+       0x35, 0x00,                     // Physical Minimum
+       0x45, 0xff,                     // Physical Maximum
+       0x81, 0x00,                     // Input
+};
+
+static const uint8_t range_test_minimum_report[7] = {
+       0x00, 0x00, 0x00, 0x80,
+       0x00, 0x80,
+       0x80,
+};
+
+static const uint8_t unsigned_range_test_minimum_report[7] = {
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,
+       0x00,
+};
+
+static const uint8_t range_test_maximum_report[7] = {
+       0xff, 0xff, 0xff, 0x7f,
+       0xff, 0x7f,
+       0x7f,
+};
+
+static const uint8_t unsigned_range_test_maximum_report[7] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff,
+       0xff,
+};
+
+static const uint8_t range_test_positive_one_report[7] = {
+       0x01, 0x00, 0x00, 0x00,
+       0x01, 0x00,
+       0x01,
+};
+
+static const uint8_t unsigned_range_test_positive_one_report[7] = {
+       0x01, 0x00, 0x00, 0x00,
+       0x01, 0x00,
+       0x01,
+};
+
+static const uint8_t range_test_negative_one_report[7] = {
+       0xff, 0xff, 0xff, 0xff,
+       0xff, 0xff,
+       0xff,
+};
+
+static const uint8_t unsigned_range_test_negative_one_report[7] = {
+       0xfe, 0xff, 0xff, 0xff,
+       0xfe, 0xff,
+       0xfe,
+};
+
+ATF_TC_HEAD(check_hid_usage, tc)
+{
+
+       atf_tc_set_md_var(tc, "descr", "Test libusbhid usage.c");
+}
+
+ATF_TC_BODY(check_hid_usage, tc)
+{
+       char usages_path[PATH_MAX];
+
+       (void)strlcpy(usages_path, atf_tc_get_config_var(tc, "srcdir"),
+           sizeof(usages_path));
+       (void)strlcat(usages_path, "/test_usb_hid_usages",
+           sizeof(usages_path));
+
+       atf_tc_expect_fail("hid_parse_*() fails because it doesn't use "
+           "scanf()");
+
+       hid_init(usages_path);
+
+       ATF_CHECK_STREQ("t_usbhid_page", hid_usage_page(0xff1b));
+       ATF_CHECK_EQ((uint32_t)hid_parse_usage_page("t_usbhid_page"), 0xff1b);
+
+       ATF_CHECK_STREQ("t_usbhid_usage", hid_usage_in_page(0xff1bff2a));
+       ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
+           "t_usbhid_page:t_usbhid_usage"), 0xff1bff2a);
+
+       ATF_CHECK_STREQ("Quick_zephyrs_blow_vexing_daft_Jim_",
+           hid_usage_page(0xff2a));
+       ATF_CHECK_EQ((uint32_t)hid_parse_usage_page(
+           "Quick_zephyrs_blow_vexing_daft_Jim_"), 0xff2a);
+
+       ATF_CHECK_STREQ("Usage_ID_Zero_%", hid_usage_in_page(0xff2a0000));
+       ATF_CHECK_EQ((uint32_t)hid_parse_usage_in_page(
+           "Quick_zephyrs_blow_vexing_daft_Jim_:Usage_ID_Zero_%"),
+           0xff2a0000);
+



Home | Main Index | Thread Index | Old Index