usb 2.12.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.js +1 -1
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/capability.js.map +1 -1
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/endpoint.d.ts +1 -0
- package/dist/usb/endpoint.js +2 -2
- package/dist/usb/endpoint.js.map +1 -1
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js +2 -2
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +2 -2
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.js +10 -10
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.codespellrc +3 -0
- package/libusb/.private/appveyor_build.sh +5 -1
- package/libusb/.private/ci-build.sh +26 -1
- package/libusb/.private/ci-container-build.sh +2 -5
- package/libusb/.private/wbs.txt +5 -8
- package/libusb/AUTHORS +22 -0
- package/libusb/ChangeLog +19 -2
- package/libusb/HACKING +25 -0
- package/libusb/INSTALL_WIN.txt +11 -10
- package/libusb/NEWS +2 -2
- package/libusb/README +3 -2
- package/libusb/README.git +1 -1
- package/libusb/Xcode/common.xcconfig +8 -1
- package/libusb/Xcode/config.h +0 -6
- package/libusb/Xcode/debug.xcconfig +4 -1
- package/libusb/Xcode/libusb.xcconfig +1 -1
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +60 -30
- package/libusb/Xcode/libusb_debug.xcconfig +1 -1
- package/libusb/Xcode/libusb_release.xcconfig +1 -1
- package/libusb/Xcode/release.xcconfig +1 -1
- package/libusb/appveyor.yml +33 -9
- package/libusb/configure.ac +68 -37
- package/libusb/examples/dpfp.c +2 -2
- package/libusb/examples/fxload.c +2 -2
- package/libusb/examples/hotplugtest.c +28 -13
- package/libusb/examples/listdevs.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +1 -1
- package/libusb/examples/testlibusb.c +1 -1
- package/libusb/examples/xusb.c +74 -19
- package/libusb/libusb/Makefile.am +11 -1
- package/libusb/libusb/core.c +364 -186
- package/libusb/libusb/descriptor.c +276 -16
- package/libusb/libusb/hotplug.c +5 -4
- package/libusb/libusb/io.c +72 -61
- package/libusb/libusb/libusb-1.0.def +14 -1
- package/libusb/libusb/libusb.h +245 -76
- package/libusb/libusb/libusbi.h +35 -13
- package/libusb/libusb/os/darwin_usb.c +542 -279
- package/libusb/libusb/os/darwin_usb.h +44 -115
- package/libusb/libusb/os/emscripten_webusb.cpp +870 -0
- package/libusb/libusb/os/events_posix.c +40 -0
- package/libusb/libusb/os/events_posix.h +3 -0
- package/libusb/libusb/os/linux_usbfs.c +27 -16
- package/libusb/libusb/os/netbsd_usb.c +36 -36
- package/libusb/libusb/os/openbsd_usb.c +34 -34
- package/libusb/libusb/os/sunos_usb.c +25 -15
- package/libusb/libusb/os/threads_posix.c +1 -5
- package/libusb/libusb/os/windows_common.c +13 -5
- package/libusb/libusb/os/windows_common.h +8 -0
- package/libusb/libusb/os/windows_winusb.c +366 -174
- package/libusb/libusb/os/windows_winusb.h +13 -9
- package/libusb/libusb/strerror.c +5 -5
- package/libusb/libusb/sync.c +24 -19
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/Base.props +60 -0
- package/libusb/msvc/Configuration.Application.props +7 -0
- package/libusb/msvc/Configuration.Base.props +47 -0
- package/libusb/msvc/Configuration.DynamicLibrary.props +21 -0
- package/libusb/msvc/Configuration.StaticLibrary.props +7 -0
- package/libusb/msvc/ProjectConfigurations.Base.props +69 -0
- package/libusb/msvc/build_all.ps1 +17 -0
- package/libusb/msvc/config.h +2 -2
- package/libusb/msvc/dpfp.vcxproj +33 -0
- package/libusb/msvc/dpfp_threaded.vcxproj +38 -0
- package/libusb/msvc/fxload.vcxproj +46 -0
- package/libusb/msvc/getopt.vcxproj +33 -0
- package/libusb/msvc/hotplugtest.vcxproj +32 -0
- package/libusb/msvc/init_context.vcxproj +35 -0
- package/libusb/msvc/libusb.sln +542 -0
- package/libusb/msvc/libusb_dll.vcxproj +61 -0
- package/libusb/msvc/libusb_static.vcxproj +49 -0
- package/libusb/msvc/listdevs.vcxproj +32 -0
- package/libusb/msvc/sam3u_benchmark.vcxproj +33 -0
- package/libusb/msvc/set_option.vcxproj +35 -0
- package/libusb/msvc/stress.vcxproj +35 -0
- package/libusb/msvc/stress_mt.vcxproj +33 -0
- package/libusb/msvc/testlibusb.vcxproj +32 -0
- package/libusb/msvc/xusb.vcxproj +38 -0
- package/libusb/tests/Makefile.am +25 -3
- package/libusb/tests/init_context.c +153 -0
- package/libusb/tests/macos.c +130 -0
- package/libusb/tests/set_option.c +253 -0
- package/libusb/tests/stress.c +17 -14
- package/libusb/tests/stress_mt.c +265 -0
- package/libusb/tests/testlib.c +1 -1
- package/libusb/tests/umockdev.c +9 -9
- package/libusb/tests/webusb-test-shim/index.js +12 -0
- package/libusb/tests/webusb-test-shim/package-lock.json +50 -0
- package/libusb/tests/webusb-test-shim/package.json +10 -0
- package/package.json +7 -7
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +15 -5
- package/libusb/msvc/dpfp_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_2019.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +0 -26
- package/libusb/msvc/fxload_2013.vcxproj +0 -94
- package/libusb/msvc/fxload_2013.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2015.vcxproj +0 -94
- package/libusb/msvc/fxload_2015.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2017.vcxproj +0 -113
- package/libusb/msvc/fxload_2017.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2019.vcxproj +0 -113
- package/libusb/msvc/fxload_2019.vcxproj.filters +0 -35
- package/libusb/msvc/getopt_2013.vcxproj +0 -72
- package/libusb/msvc/getopt_2013.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2015.vcxproj +0 -73
- package/libusb/msvc/getopt_2015.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2017.vcxproj +0 -92
- package/libusb/msvc/getopt_2017.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2019.vcxproj +0 -92
- package/libusb/msvc/getopt_2019.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2013.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2015.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2017.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2019.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +0 -23
- package/libusb/msvc/libusb_2013.sln +0 -137
- package/libusb/msvc/libusb_2015.sln +0 -137
- package/libusb/msvc/libusb_2017.sln +0 -240
- package/libusb/msvc/libusb_2019.sln +0 -240
- package/libusb/msvc/libusb_dll_2013.vcxproj +0 -104
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2015.vcxproj +0 -105
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2017.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2019.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2015.vcxproj +0 -95
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2017.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2019.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +0 -80
- package/libusb/msvc/listdevs_2013.vcxproj +0 -86
- package/libusb/msvc/listdevs_2013.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2015.vcxproj +0 -86
- package/libusb/msvc/listdevs_2015.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2017.vcxproj +0 -105
- package/libusb/msvc/listdevs_2017.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2019.vcxproj +0 -105
- package/libusb/msvc/listdevs_2019.vcxproj.filters +0 -23
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +0 -26
- package/libusb/msvc/stress_2013.vcxproj +0 -89
- package/libusb/msvc/stress_2013.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2015.vcxproj +0 -89
- package/libusb/msvc/stress_2015.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2017.vcxproj +0 -108
- package/libusb/msvc/stress_2017.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2019.vcxproj +0 -108
- package/libusb/msvc/stress_2019.vcxproj.filters +0 -32
- package/libusb/msvc/testlibusb_2013.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2015.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2017.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2019.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2013.vcxproj +0 -86
- package/libusb/msvc/xusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2015.vcxproj +0 -86
- package/libusb/msvc/xusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2017.vcxproj +0 -105
- package/libusb/msvc/xusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2019.vcxproj +0 -105
- package/libusb/msvc/xusb_2019.vcxproj.filters +0 -23
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{349EE8F9-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.StaticLibrary.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<PropertyGroup>
|
|
18
|
+
<OutDir>$(IntDir)..\lib\</OutDir>
|
|
19
|
+
<TargetName>libusb-1.0</TargetName>
|
|
20
|
+
</PropertyGroup>
|
|
21
|
+
<ItemGroup>
|
|
22
|
+
<ClCompile Include="..\libusb\core.c" />
|
|
23
|
+
<ClCompile Include="..\libusb\descriptor.c" />
|
|
24
|
+
<ClCompile Include="..\libusb\os\events_windows.c" />
|
|
25
|
+
<ClCompile Include="..\libusb\hotplug.c" />
|
|
26
|
+
<ClCompile Include="..\libusb\io.c" />
|
|
27
|
+
<ClCompile Include="..\libusb\strerror.c" />
|
|
28
|
+
<ClCompile Include="..\libusb\sync.c" />
|
|
29
|
+
<ClCompile Include="..\libusb\os\threads_windows.c" />
|
|
30
|
+
<ClCompile Include="..\libusb\os\windows_common.c" />
|
|
31
|
+
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
|
|
32
|
+
<ClCompile Include="..\libusb\os\windows_winusb.c" />
|
|
33
|
+
</ItemGroup>
|
|
34
|
+
<ItemGroup>
|
|
35
|
+
<ClInclude Include=".\config.h" />
|
|
36
|
+
<ClInclude Include="..\libusb\os\events_windows.h" />
|
|
37
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
38
|
+
<ClInclude Include="..\libusb\libusbi.h" />
|
|
39
|
+
<ClInclude Include="..\libusb\os\threads_windows.h" />
|
|
40
|
+
<ClInclude Include="..\libusb\version.h" />
|
|
41
|
+
<ClInclude Include="..\libusb\version_nano.h" />
|
|
42
|
+
<ClInclude Include="..\libusb\os\windows_common.h" />
|
|
43
|
+
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
|
|
44
|
+
<ClInclude Include="..\libusb\os\windows_winusb.h" />
|
|
45
|
+
</ItemGroup>
|
|
46
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
47
|
+
<ImportGroup Label="ExtensionTargets">
|
|
48
|
+
</ImportGroup>
|
|
49
|
+
</Project>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\examples\listdevs.c" />
|
|
19
|
+
</ItemGroup>
|
|
20
|
+
<ItemGroup>
|
|
21
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
22
|
+
</ItemGroup>
|
|
23
|
+
<ItemGroup>
|
|
24
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
25
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
26
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
27
|
+
</ProjectReference>
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
30
|
+
<ImportGroup Label="ExtensionTargets">
|
|
31
|
+
</ImportGroup>
|
|
32
|
+
</Project>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{861cdd5f-59a2-4f34-957e-5c1af98be0a4}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\examples\sam3u_benchmark.c" />
|
|
19
|
+
</ItemGroup>
|
|
20
|
+
<ItemGroup>
|
|
21
|
+
<ClInclude Include=".\config.h" />
|
|
22
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
23
|
+
</ItemGroup>
|
|
24
|
+
<ItemGroup>
|
|
25
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
26
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
27
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
28
|
+
</ProjectReference>
|
|
29
|
+
</ItemGroup>
|
|
30
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
31
|
+
<ImportGroup Label="ExtensionTargets">
|
|
32
|
+
</ImportGroup>
|
|
33
|
+
</Project>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{35BD5D4B-5102-4A08-81C0-AAF3285FCB01}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\tests\set_option.c" />
|
|
19
|
+
<ClCompile Include="..\tests\testlib.c" />
|
|
20
|
+
</ItemGroup>
|
|
21
|
+
<ItemGroup>
|
|
22
|
+
<ClInclude Include=".\config.h" />
|
|
23
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
24
|
+
<ClInclude Include="..\tests\libusb_testlib.h" />
|
|
25
|
+
</ItemGroup>
|
|
26
|
+
<ItemGroup>
|
|
27
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
28
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
29
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
30
|
+
</ProjectReference>
|
|
31
|
+
</ItemGroup>
|
|
32
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
33
|
+
<ImportGroup Label="ExtensionTargets">
|
|
34
|
+
</ImportGroup>
|
|
35
|
+
</Project>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{53942EFF-C810-458D-B3CB-EE5CE9F1E781}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\tests\stress.c" />
|
|
19
|
+
<ClCompile Include="..\tests\testlib.c" />
|
|
20
|
+
</ItemGroup>
|
|
21
|
+
<ItemGroup>
|
|
22
|
+
<ClInclude Include=".\config.h" />
|
|
23
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
24
|
+
<ClInclude Include="..\tests\libusb_testlib.h" />
|
|
25
|
+
</ItemGroup>
|
|
26
|
+
<ItemGroup>
|
|
27
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
28
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
29
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
30
|
+
</ProjectReference>
|
|
31
|
+
</ItemGroup>
|
|
32
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
33
|
+
<ImportGroup Label="ExtensionTargets">
|
|
34
|
+
</ImportGroup>
|
|
35
|
+
</Project>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{9EAF1311-2BBB-4177-882B-DA7FA0AD7912}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\tests\stress_mt.c" />
|
|
19
|
+
</ItemGroup>
|
|
20
|
+
<ItemGroup>
|
|
21
|
+
<ClInclude Include=".\config.h" />
|
|
22
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
23
|
+
</ItemGroup>
|
|
24
|
+
<ItemGroup>
|
|
25
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
26
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
27
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
28
|
+
</ProjectReference>
|
|
29
|
+
</ItemGroup>
|
|
30
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
31
|
+
<ImportGroup Label="ExtensionTargets">
|
|
32
|
+
</ImportGroup>
|
|
33
|
+
</Project>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{70828935-325B-4749-B381-0E55EF31AEE8}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemGroup>
|
|
18
|
+
<ClCompile Include="..\examples\testlibusb.c" />
|
|
19
|
+
</ItemGroup>
|
|
20
|
+
<ItemGroup>
|
|
21
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
22
|
+
</ItemGroup>
|
|
23
|
+
<ItemGroup>
|
|
24
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
25
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
26
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
27
|
+
</ProjectReference>
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
30
|
+
<ImportGroup Label="ExtensionTargets">
|
|
31
|
+
</ImportGroup>
|
|
32
|
+
</Project>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<Import Project="ProjectConfigurations.Base.props" />
|
|
4
|
+
<PropertyGroup Label="Globals">
|
|
5
|
+
<ProjectGuid>{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}</ProjectGuid>
|
|
6
|
+
</PropertyGroup>
|
|
7
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
8
|
+
<Import Project="Configuration.Application.props" />
|
|
9
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
10
|
+
<ImportGroup Label="ExtensionSettings">
|
|
11
|
+
</ImportGroup>
|
|
12
|
+
<ImportGroup Label="PropertySheets">
|
|
13
|
+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
14
|
+
<Import Project="Base.props" />
|
|
15
|
+
</ImportGroup>
|
|
16
|
+
<PropertyGroup Label="UserMacros" />
|
|
17
|
+
<ItemDefinitionGroup>
|
|
18
|
+
<ClCompile>
|
|
19
|
+
<!--VS2013 complains about while(0)-->
|
|
20
|
+
<DisableSpecificWarnings Condition="'$(PlatformToolsetVersion)'<='120'">4127;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
21
|
+
</ClCompile>
|
|
22
|
+
</ItemDefinitionGroup>
|
|
23
|
+
<ItemGroup>
|
|
24
|
+
<ClCompile Include="..\examples\xusb.c" />
|
|
25
|
+
</ItemGroup>
|
|
26
|
+
<ItemGroup>
|
|
27
|
+
<ClInclude Include="..\libusb\libusb.h" />
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
<ItemGroup>
|
|
30
|
+
<ProjectReference Include=".\libusb_static.vcxproj">
|
|
31
|
+
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
|
|
32
|
+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
|
33
|
+
</ProjectReference>
|
|
34
|
+
</ItemGroup>
|
|
35
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
36
|
+
<ImportGroup Label="ExtensionTargets">
|
|
37
|
+
</ImportGroup>
|
|
38
|
+
</Project>
|
package/libusb/tests/Makefile.am
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
AM_CPPFLAGS = -I$(top_srcdir)/libusb
|
|
2
2
|
LDADD = ../libusb/libusb-1.0.la
|
|
3
|
-
|
|
3
|
+
AM_LDFLAGS = -static
|
|
4
4
|
|
|
5
|
-
stress_SOURCES = stress.c
|
|
5
|
+
stress_SOURCES = stress.c testlib.c
|
|
6
|
+
stress_mt_SOURCES = stress_mt.c
|
|
7
|
+
set_option_SOURCES = set_option.c testlib.c
|
|
8
|
+
init_context_SOURCES = init_context.c testlib.c
|
|
9
|
+
macos_SOURCES = macos.c testlib.c
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
stress_mt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
|
|
12
|
+
stress_mt_LDADD = $(LDADD) $(THREAD_LIBS)
|
|
13
|
+
stress_mt_LDFLAGS = $(AM_LDFLAGS)
|
|
14
|
+
|
|
15
|
+
if OS_EMSCRIPTEN
|
|
16
|
+
# On the Web you can't block the main thread as this blocks the event loop itself,
|
|
17
|
+
# causing deadlocks when trying to use async APIs like WebUSB.
|
|
18
|
+
# We use the PROXY_TO_PTHREAD Emscripten's feature to move the main app to a separate thread
|
|
19
|
+
# where it can block safely.
|
|
20
|
+
stress_mt_LDFLAGS += ${AM_LDFLAGS} -s PROXY_TO_PTHREAD -s EXIT_RUNTIME
|
|
21
|
+
endif
|
|
22
|
+
|
|
23
|
+
noinst_HEADERS = libusb_testlib.h
|
|
24
|
+
noinst_PROGRAMS = stress stress_mt set_option init_context
|
|
25
|
+
if OS_DARWIN
|
|
26
|
+
noinst_PROGRAMS += macos
|
|
27
|
+
endif
|
|
8
28
|
|
|
9
29
|
if BUILD_UMOCKDEV_TEST
|
|
10
30
|
# NOTE: We add libumockdev-preload.so so that we can run tests in-process
|
|
@@ -16,3 +36,5 @@ umockdev_SOURCES = umockdev.c
|
|
|
16
36
|
|
|
17
37
|
noinst_PROGRAMS += umockdev
|
|
18
38
|
endif
|
|
39
|
+
|
|
40
|
+
TESTS=$(noinst_PROGRAMS)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* -*- Mode: C; indent-tabs-mode:nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Unit tests for libusb_set_option
|
|
4
|
+
* Copyright © 2023 Nathan Hjelm <hjelmn@cs.unm.edu>
|
|
5
|
+
* Copyright © 2023 Google, LLC. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This library is free software; you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
9
|
+
* License as published by the Free Software Foundation; either
|
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15
|
+
* Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
18
|
+
* License along with this library; if not, write to the Free Software
|
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "config.h"
|
|
23
|
+
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
#include <inttypes.h>
|
|
27
|
+
#include "libusbi.h"
|
|
28
|
+
#include "libusb_testlib.h"
|
|
29
|
+
|
|
30
|
+
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
31
|
+
#include <winbase.h>
|
|
32
|
+
|
|
33
|
+
static int unsetenv(const char *env) {
|
|
34
|
+
return _putenv_s(env, "");
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#define LIBUSB_TEST_CLEAN_EXIT(code) \
|
|
39
|
+
do { \
|
|
40
|
+
if (test_ctx != NULL) { \
|
|
41
|
+
libusb_exit(test_ctx); \
|
|
42
|
+
} \
|
|
43
|
+
unsetenv("LIBUSB_DEBUG"); \
|
|
44
|
+
return (code); \
|
|
45
|
+
} while (0)
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Fail the test if the expression does not evaluate to LIBUSB_SUCCESS.
|
|
49
|
+
*/
|
|
50
|
+
#define LIBUSB_TEST_RETURN_ON_ERROR(expr) \
|
|
51
|
+
do { \
|
|
52
|
+
int _result = (expr); \
|
|
53
|
+
if (LIBUSB_SUCCESS != _result) { \
|
|
54
|
+
libusb_testlib_logf("Not success (%s) at %s:%d", #expr, \
|
|
55
|
+
__FILE__, __LINE__); \
|
|
56
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_FAILURE); \
|
|
57
|
+
} \
|
|
58
|
+
} while (0)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Use relational operator to compare two values and fail the test if the
|
|
62
|
+
* comparison is false. Intended to compare integer or pointer types.
|
|
63
|
+
*
|
|
64
|
+
* Example: LIBUSB_EXPECT(==, 0, 1) -> fail, LIBUSB_EXPECT(==, 0, 0) -> ok.
|
|
65
|
+
*/
|
|
66
|
+
#define LIBUSB_EXPECT(operator, lhs, rhs) \
|
|
67
|
+
do { \
|
|
68
|
+
int64_t _lhs = (int64_t)(intptr_t)(lhs), _rhs = (int64_t)(intptr_t)(rhs); \
|
|
69
|
+
if (!(_lhs operator _rhs)) { \
|
|
70
|
+
libusb_testlib_logf("Expected %s (%" PRId64 ") " #operator \
|
|
71
|
+
" %s (%" PRId64 ") at %s:%d", #lhs, \
|
|
72
|
+
(int64_t)(intptr_t)_lhs, #rhs, \
|
|
73
|
+
(int64_t)(intptr_t)_rhs, __FILE__, \
|
|
74
|
+
__LINE__); \
|
|
75
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_FAILURE); \
|
|
76
|
+
} \
|
|
77
|
+
} while (0)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
static libusb_testlib_result test_init_context_basic(void) {
|
|
81
|
+
libusb_context *test_ctx = NULL;
|
|
82
|
+
|
|
83
|
+
/* test basic functionality */
|
|
84
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,
|
|
85
|
+
/*num_options=*/0));
|
|
86
|
+
|
|
87
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_SUCCESS);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static libusb_testlib_result test_init_context_log_level(void) {
|
|
91
|
+
libusb_context *test_ctx = NULL;
|
|
92
|
+
|
|
93
|
+
struct libusb_init_option options[] = {
|
|
94
|
+
{
|
|
95
|
+
.option = LIBUSB_OPTION_LOG_LEVEL,
|
|
96
|
+
.value = {
|
|
97
|
+
.ival = LIBUSB_LOG_LEVEL_ERROR,
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/* test basic functionality */
|
|
103
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, options,
|
|
104
|
+
/*num_options=*/1));
|
|
105
|
+
|
|
106
|
+
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
|
|
107
|
+
LIBUSB_EXPECT(==, test_ctx->debug, LIBUSB_LOG_LEVEL_ERROR);
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_SUCCESS);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static void LIBUSB_CALL test_log_cb(libusb_context *ctx, enum libusb_log_level level,
|
|
114
|
+
const char *str) {
|
|
115
|
+
UNUSED(ctx);
|
|
116
|
+
UNUSED(level);
|
|
117
|
+
UNUSED(str);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static libusb_testlib_result test_init_context_log_cb(void) {
|
|
121
|
+
libusb_context *test_ctx = NULL;
|
|
122
|
+
|
|
123
|
+
struct libusb_init_option options[] = {
|
|
124
|
+
{
|
|
125
|
+
.option = LIBUSB_OPTION_LOG_CB,
|
|
126
|
+
.value = {
|
|
127
|
+
.log_cbval = (libusb_log_cb) &test_log_cb,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/* test basic functionality */
|
|
133
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, options,
|
|
134
|
+
/*num_options=*/1));
|
|
135
|
+
|
|
136
|
+
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
|
|
137
|
+
LIBUSB_EXPECT(==, test_ctx->log_handler, test_log_cb);
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_SUCCESS);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static const libusb_testlib_test tests[] = {
|
|
144
|
+
{ "test_init_context_basic", &test_init_context_basic },
|
|
145
|
+
{ "test_init_context_log_level", &test_init_context_log_level },
|
|
146
|
+
{ "test_init_context_log_cb", &test_init_context_log_cb },
|
|
147
|
+
LIBUSB_NULL_TEST
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
int main(int argc, char *argv[])
|
|
151
|
+
{
|
|
152
|
+
return libusb_testlib_run_tests(argc, argv, tests);
|
|
153
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* -*- Mode: C; indent-tabs-mode:nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Unit tests for libusb_set_option
|
|
4
|
+
* Copyright © 2023 Nathan Hjelm <hjelmn@cs.unm.edu>
|
|
5
|
+
* Copyright © 2023 Google, LLC. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This library is free software; you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
9
|
+
* License as published by the Free Software Foundation; either
|
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15
|
+
* Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
18
|
+
* License along with this library; if not, write to the Free Software
|
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "config.h"
|
|
23
|
+
|
|
24
|
+
#include <stdbool.h>
|
|
25
|
+
#include <stdlib.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <inttypes.h>
|
|
28
|
+
#include "libusbi.h"
|
|
29
|
+
#include "libusb_testlib.h"
|
|
30
|
+
|
|
31
|
+
#define LIBUSB_TEST_CLEAN_EXIT(code) \
|
|
32
|
+
do { \
|
|
33
|
+
if (test_ctx != NULL) { \
|
|
34
|
+
libusb_exit(test_ctx); \
|
|
35
|
+
} \
|
|
36
|
+
unsetenv("LIBUSB_DEBUG"); \
|
|
37
|
+
return (code); \
|
|
38
|
+
} while (0)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fail the test if the expression does not evaluate to LIBUSB_SUCCESS.
|
|
42
|
+
*/
|
|
43
|
+
#define LIBUSB_TEST_RETURN_ON_ERROR(expr) \
|
|
44
|
+
do { \
|
|
45
|
+
int _result = (expr); \
|
|
46
|
+
if (LIBUSB_SUCCESS != _result) { \
|
|
47
|
+
libusb_testlib_logf("Not success (%s) at %s:%d", #expr, \
|
|
48
|
+
__FILE__, __LINE__); \
|
|
49
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_FAILURE); \
|
|
50
|
+
} \
|
|
51
|
+
} while (0)
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Use relational operator to compare two values and fail the test if the
|
|
55
|
+
* comparison is false. Intended to compare integer or pointer types.
|
|
56
|
+
*
|
|
57
|
+
* Example: LIBUSB_EXPECT(==, 0, 1) -> fail, LIBUSB_EXPECT(==, 0, 0) -> ok.
|
|
58
|
+
*/
|
|
59
|
+
#define LIBUSB_EXPECT(operator, lhs, rhs) \
|
|
60
|
+
do { \
|
|
61
|
+
int64_t _lhs = (lhs), _rhs = (rhs); \
|
|
62
|
+
if (!(_lhs operator _rhs)) { \
|
|
63
|
+
libusb_testlib_logf("Expected %s (%" PRId64 ") " #operator \
|
|
64
|
+
" %s (%" PRId64 ") at %s:%d", #lhs, \
|
|
65
|
+
(int64_t)(intptr_t)_lhs, #rhs, \
|
|
66
|
+
(int64_t)(intptr_t)_rhs, __FILE__, \
|
|
67
|
+
__LINE__); \
|
|
68
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_FAILURE); \
|
|
69
|
+
} \
|
|
70
|
+
} while (0)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
extern uint32_t libusb_testonly_fake_running_version;
|
|
74
|
+
extern int libusb_testonly_using_running_interface_version;
|
|
75
|
+
extern int libusb_testonly_using_running_device_version;
|
|
76
|
+
extern bool libusb_testonly_clear_running_version_cache;
|
|
77
|
+
|
|
78
|
+
static libusb_testlib_result test_macos_version_fallback(void) {
|
|
79
|
+
libusb_context *test_ctx = NULL;
|
|
80
|
+
libusb_testonly_fake_running_version = 100001;
|
|
81
|
+
libusb_testonly_clear_running_version_cache = true;
|
|
82
|
+
|
|
83
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,
|
|
84
|
+
/*num_options=*/0));
|
|
85
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_interface_version, 220);
|
|
86
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_device_version, 197);
|
|
87
|
+
|
|
88
|
+
libusb_exit(test_ctx);
|
|
89
|
+
test_ctx = NULL;
|
|
90
|
+
|
|
91
|
+
libusb_testonly_fake_running_version = 100900;
|
|
92
|
+
|
|
93
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,
|
|
94
|
+
/*num_options=*/0));
|
|
95
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_interface_version, 650);
|
|
96
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_device_version, 650);
|
|
97
|
+
|
|
98
|
+
libusb_exit(test_ctx);
|
|
99
|
+
test_ctx = NULL;
|
|
100
|
+
|
|
101
|
+
libusb_testonly_fake_running_version = 101200;
|
|
102
|
+
|
|
103
|
+
LIBUSB_TEST_RETURN_ON_ERROR(libusb_init_context(&test_ctx, /*options=*/NULL,
|
|
104
|
+
/*num_options=*/0));
|
|
105
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_interface_version, 800);
|
|
106
|
+
LIBUSB_EXPECT(==, libusb_testonly_using_running_device_version, 650);
|
|
107
|
+
|
|
108
|
+
libusb_exit(test_ctx);
|
|
109
|
+
test_ctx = NULL;
|
|
110
|
+
|
|
111
|
+
// Test a version smaller than 10.0. Initialization should fail.
|
|
112
|
+
libusb_testonly_fake_running_version = 99999;
|
|
113
|
+
|
|
114
|
+
int error = libusb_init_context(&test_ctx, /*options=*/NULL,
|
|
115
|
+
/*num_options=*/0);
|
|
116
|
+
LIBUSB_EXPECT(!=, error, LIBUSB_SUCCESS);
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
LIBUSB_TEST_CLEAN_EXIT(TEST_STATUS_SUCCESS);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static const libusb_testlib_test tests[] = {
|
|
123
|
+
{ "test_macos_version_fallback", &test_macos_version_fallback },
|
|
124
|
+
LIBUSB_NULL_TEST
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
int main(int argc, char *argv[])
|
|
128
|
+
{
|
|
129
|
+
return libusb_testlib_run_tests(argc, argv, tests);
|
|
130
|
+
}
|