* [Buildroot] [PATCH 2/3] package/libusb-compat: add option to build/install examples
2026-10-09 7:49 [Buildroot] [PATCH 1/3] package/libusb-compat: bump to version 0.1.9 Zoltan Gyarmati
@ 2026-10-09 7:49 ` Zoltan Gyarmati
2026-10-09 7:49 ` [Buildroot] [PATCH 3/3] support/testing/tests/package/test_libusb_compat: new runtime test Zoltan Gyarmati
2026-10-10 5:40 ` [Buildroot] [PATCH 1/3] package/libusb-compat: bump to version 0.1.9 Thomas Petazzoni via buildroot
2 siblings, 0 replies; 4+ messages in thread
From: Zoltan Gyarmati @ 2026-10-09 7:49 UTC (permalink / raw)
To: buildroot; +Cc: Zoltan Gyarmati
The examples are not installed by upstream, and their names conflict
with other packages (lsusb from busybox/usbutils, testlibusb from the
libusb examples), so install them in /usr/libexec/libusb-compat/examples.
Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
---
package/libusb-compat/Config.in | 11 +++++++++++
package/libusb-compat/libusb-compat.mk | 14 ++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/package/libusb-compat/Config.in b/package/libusb-compat/Config.in
index 076d7b8d77..5efa9bbe3d 100644
--- a/package/libusb-compat/Config.in
+++ b/package/libusb-compat/Config.in
@@ -5,3 +5,14 @@ config BR2_PACKAGE_LIBUSB_COMPAT
libusb-0.1 compatibility layer for libusb-1.0.
http://libusb.info/
+
+if BR2_PACKAGE_LIBUSB_COMPAT
+
+config BR2_PACKAGE_LIBUSB_COMPAT_EXAMPLES
+ bool "build libusb-compat examples"
+ help
+ Build and install the libusb-compat example programs (lsusb,
+ testlibusb and hotplug_monitor) in
+ /usr/libexec/libusb-compat/examples.
+
+endif
diff --git a/package/libusb-compat/libusb-compat.mk b/package/libusb-compat/libusb-compat.mk
index 4e78a213b7..c8dabe2068 100644
--- a/package/libusb-compat/libusb-compat.mk
+++ b/package/libusb-compat/libusb-compat.mk
@@ -20,5 +20,19 @@ LIBUSB_COMPAT_CONF_ENV += \
|sed -r -e '/\(SONAME\)/!d; s/.*\[(.+)\]$$/\1/'`
endif
+ifeq ($(BR2_PACKAGE_LIBUSB_COMPAT_EXAMPLES),y)
+LIBUSB_COMPAT_CONF_OPTS += --enable-examples-build
+# Examples are not installed by upstream, and their names conflict
+# with other packages (e.g. lsusb, testlibusb), so install them in a
+# package-specific directory.
+define LIBUSB_COMPAT_INSTALL_TARGET_EXAMPLES
+ $(foreach example,lsusb testlibusb hotplug_monitor,
+ $(INSTALL) -D -m0755 $(@D)/examples/$(example) \
+ $(TARGET_DIR)/usr/libexec/libusb-compat/examples/$(example)
+ )
+endef
+LIBUSB_COMPAT_POST_INSTALL_TARGET_HOOKS += LIBUSB_COMPAT_INSTALL_TARGET_EXAMPLES
+endif
+
$(eval $(autotools-package))
$(eval $(host-autotools-package))
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 3/3] support/testing/tests/package/test_libusb_compat: new runtime test
2026-10-09 7:49 [Buildroot] [PATCH 1/3] package/libusb-compat: bump to version 0.1.9 Zoltan Gyarmati
2026-10-09 7:49 ` [Buildroot] [PATCH 2/3] package/libusb-compat: add option to build/install examples Zoltan Gyarmati
@ 2026-10-09 7:49 ` Zoltan Gyarmati
2026-10-10 5:40 ` [Buildroot] [PATCH 1/3] package/libusb-compat: bump to version 0.1.9 Thomas Petazzoni via buildroot
2 siblings, 0 replies; 4+ messages in thread
From: Zoltan Gyarmati @ 2026-10-09 7:49 UTC (permalink / raw)
To: buildroot; +Cc: Zoltan Gyarmati
Signed-off-by: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>
---
DEVELOPERS | 2 +
.../tests/package/test_libusb_compat.py | 58 +++++++++++++++++++
.../test_libusb_compat/linux-usb.fragment | 2 +
3 files changed, 62 insertions(+)
create mode 100644 support/testing/tests/package/test_libusb_compat.py
create mode 100644 support/testing/tests/package/test_libusb_compat/linux-usb.fragment
diff --git a/DEVELOPERS b/DEVELOPERS
index 32ac338dc8..c850878e57 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3628,4 +3628,6 @@ F: package/quazip/
F: package/shapelib/
F: package/simple-mail/
F: package/tinc/
+F: support/testing/tests/package/test_libusb_compat.py
+F: support/testing/tests/package/test_libusb_compat/
F: support/testing/tests/package/test_quazip.py
diff --git a/support/testing/tests/package/test_libusb_compat.py b/support/testing/tests/package/test_libusb_compat.py
new file mode 100644
index 0000000000..d0bb57d4cc
--- /dev/null
+++ b/support/testing/tests/package/test_libusb_compat.py
@@ -0,0 +1,58 @@
+import os
+
+import infra.basetest
+
+
+class TestLibusbCompat(infra.basetest.BRTest):
+ # enable USB 2.0 support so we can test the USB enumeration in qemu
+ linux_fragment = \
+ infra.filepath("tests/package/test_libusb_compat/linux-usb.fragment")
+ config = \
+ f"""
+ BR2_aarch64=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.73"
+ BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+ BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{linux_fragment}"
+ BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+ BR2_PACKAGE_LIBUSB=y
+ BR2_PACKAGE_LIBUSB_COMPAT=y
+ BR2_PACKAGE_LIBUSB_COMPAT_EXAMPLES=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_GZIP=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ examples_dir = "/usr/libexec/libusb-compat/examples"
+
+ def test_run(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+ kern = os.path.join(self.builddir, "images", "Image")
+ # We add a USB keyboard device for the test.
+ self.emulator.boot(arch="aarch64",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "virt", "-cpu", "cortex-a57", "-m", "256M",
+ "-initrd", img,
+ "-device", "usb-ehci,id=ehci",
+ "-device", "usb-kbd,bus=ehci.0"])
+ self.emulator.login()
+
+ # The lsusb example prints "idVendor:idProduct" for every
+ # device. We expect the Linux Foundation 2.0 root hub
+ # (1d6b:0002) and the QEMU USB keyboard (0627:0001).
+ output, exit_code = self.emulator.run(f"{self.examples_dir}/lsusb")
+ self.assertEqual(exit_code, 0)
+ self.assertIn("1d6b:0002", output)
+ self.assertIn("0627:0001", output)
+
+ # The testlibusb example opens every device and prints its
+ # descriptors. The keyboard should show up as a HID
+ # (bInterfaceClass 3) device.
+ output, exit_code = self.emulator.run(f"{self.examples_dir}/testlibusb -v")
+ self.assertEqual(exit_code, 0)
+ self.assertIn("bInterfaceClass: 3", "\n".join(output))
diff --git a/support/testing/tests/package/test_libusb_compat/linux-usb.fragment b/support/testing/tests/package/test_libusb_compat/linux-usb.fragment
new file mode 100644
index 0000000000..d9abd2821e
--- /dev/null
+++ b/support/testing/tests/package/test_libusb_compat/linux-usb.fragment
@@ -0,0 +1,2 @@
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread