aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngvar Stepanyan <me@rreverser.com>2023-12-13 14:30:33 +0000
committerTormod Volden <debian.tormod@gmail.com>2023-12-19 00:38:11 +0100
commitc2e150773ec0a50b4031344a195387d0108ce8a3 (patch)
tree1860cf26ba7cf435a1ea279ac5f145c8c3f462cf
parentb27247063b70b113c83d5f17de43961a02ecd082 (diff)
downloadlibusb-c2e150773ec0a50b4031344a195387d0108ce8a3.tar.gz
tests/set_option: Allow no devices in test_no_discovery
Instead of assuming there will always be some devices detected (when not using LIBUSB_OPTION_NO_DEVICE_DISCOVERY), let the test pass but print a warning to the user if there is none. This is to allow automated build tests on restricted build environments without USB devices. References #1374 Closes #1379
-rwxr-xr-x.private/ci-build.sh3
-rw-r--r--libusb/version_nano.h2
-rw-r--r--tests/set_option.c8
3 files changed, 7 insertions, 6 deletions
diff --git a/.private/ci-build.sh b/.private/ci-build.sh
index f490285..33dfb3b 100755
--- a/.private/ci-build.sh
+++ b/.private/ci-build.sh
@@ -63,9 +63,6 @@ cflags+=" -Wpointer-arith"
cflags+=" -Wredundant-decls"
cflags+=" -Wswitch-enum"
-# Tell tests that we don't have any devices.
-cflags+=" -DCI_WITHOUT_DEVICES"
-
# enable address sanitizer
if [ "${asan}" = "yes" ]; then
cflags+=" -fsanitize=address"
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 7d6338a..695356c 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11851
+#define LIBUSB_NANO 11852
diff --git a/tests/set_option.c b/tests/set_option.c
index 20c55eb..defa3cf 100644
--- a/tests/set_option.c
+++ b/tests/set_option.c
@@ -166,7 +166,7 @@ static libusb_testlib_result test_set_log_level_env(void) {
static libusb_testlib_result test_no_discovery(void)
{
-#if defined(__linux__) && !defined(CI_WITHOUT_DEVICES)
+#if defined(__linux__)
libusb_context *test_ctx;
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,
/*num_options=*/0));
@@ -176,7 +176,11 @@ static libusb_testlib_result test_no_discovery(void)
libusb_exit(test_ctx);
test_ctx = NULL;
- LIBUSB_EXPECT(>, num_devices, 0);
+ if (num_devices == 0) {
+ libusb_testlib_logf("Warning: no devices found, the test will only verify that setting LIBUSB_OPTION_NO_DEVICE_DISCOVERY succeeds.");
+ }
+
+ LIBUSB_EXPECT(>=, num_devices, 0);
LIBUSB_TEST_RETURN_ON_ERROR(libusb_set_option(NULL, LIBUSB_OPTION_NO_DEVICE_DISCOVERY));
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,