diff --git a/common/core/inc/ux_api.h b/common/core/inc/ux_api.h index ed26f727f..90fa31101 100644 --- a/common/core/inc/ux_api.h +++ b/common/core/inc/ux_api.h @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -1168,7 +1169,9 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL #define UX_NON_CONTROL_TRANSFER_TIMEOUT 50000 #endif #define UX_PORT_ENABLE_WAIT 50 +#ifndef UX_DEVICE_ADDRESS_SET_WAIT #define UX_DEVICE_ADDRESS_SET_WAIT 50 +#endif #define UX_HIGH_SPEED_DETECTION_HANDSHAKE_SUSPEND_WAIT 200 #define UX_ENUMERATION_THREAD_WAIT 200 @@ -1543,8 +1546,16 @@ VOID _ux_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, UL /* Define USBX root HUB constants. */ +#ifndef UX_RH_ENUMERATION_RETRY #define UX_RH_ENUMERATION_RETRY 3 +#endif +#ifndef UX_RH_ENUMERATION_RETRY_DELAY #define UX_RH_ENUMERATION_RETRY_DELAY 100 +#endif +/* USB spec minimum debounce interval (ms) on device attach. */ +#ifndef UX_HOST_STACK_DEVICE_ATTACH_DEBOUNCE_DELAY +#define UX_HOST_STACK_DEVICE_ATTACH_DEBOUNCE_DELAY 100 +#endif /* Define USBX PCI driver constants. */ @@ -2856,4 +2867,3 @@ UINT ux_device_stack_transfer_run(UX_SLAVE_TRANSFER *transfer_request, ULONG #endif - diff --git a/common/core/src/ux_host_stack_rh_device_insertion.c b/common/core/src/ux_host_stack_rh_device_insertion.c index d00e52633..06216a0a7 100644 --- a/common/core/src/ux_host_stack_rh_device_insertion.c +++ b/common/core/src/ux_host_stack_rh_device_insertion.c @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -112,7 +113,7 @@ UINT status; return(port_status); /* A debounce interval with a minimum duration of 100 ms on attach. */ - _ux_utility_delay_ms(100); + _ux_utility_delay_ms(UX_HOST_STACK_DEVICE_ATTACH_DEBOUNCE_DELAY); /* The first attempts to do a device enumeration may fail. Typically, after the port is reset and the first command is sent to diff --git a/common/usbx_host_classes/inc/ux_host_class_cdc_acm.h b/common/usbx_host_classes/inc/ux_host_class_cdc_acm.h index b8c392f48..36d3a1810 100644 --- a/common/usbx_host_classes/inc/ux_host_class_cdc_acm.h +++ b/common/usbx_host_classes/inc/ux_host_class_cdc_acm.h @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -61,7 +62,9 @@ extern "C" { /* Define CDC ACM Class constants. */ +#ifndef UX_HOST_CLASS_CDC_ACM_DEVICE_INIT_DELAY #define UX_HOST_CLASS_CDC_ACM_DEVICE_INIT_DELAY 1000 +#endif #define UX_HOST_CLASS_CDC_ACM_CLASS_TRANSFER_TIMEOUT 300000 #define UX_HOST_CLASS_CDC_DATA_CLASS 0x0A #define UX_HOST_CLASS_CDC_CONTROL_CLASS 0x02 diff --git a/common/usbx_host_classes/inc/ux_host_class_storage.h b/common/usbx_host_classes/inc/ux_host_class_storage.h index f9a5a59b1..769b3e6c9 100644 --- a/common/usbx_host_classes/inc/ux_host_class_storage.h +++ b/common/usbx_host_classes/inc/ux_host_class_storage.h @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -131,8 +132,12 @@ extern "C" { /* Define Storage Class constants. */ +#ifndef UX_HOST_CLASS_STORAGE_DEVICE_INIT_DELAY #define UX_HOST_CLASS_STORAGE_DEVICE_INIT_DELAY (200) +#endif +#ifndef UX_HOST_CLASS_STORAGE_THREAD_SLEEP_TIME #define UX_HOST_CLASS_STORAGE_THREAD_SLEEP_TIME (2000) +#endif #define UX_HOST_CLASS_STORAGE_INSTANCE_SHUTDOWN_TIMER (10) #define UX_HOST_CLASS_STORAGE_THREAD_PRIORITY_CLASS 20 #define UX_HOST_CLASS_STORAGE_TRANSFER_TIMEOUT 10000 diff --git a/ports/win32/vs_2019/CMakeLists.txt b/ports/win32/vs_2019/CMakeLists.txt new file mode 100644 index 000000000..c729f25df --- /dev/null +++ b/ports/win32/vs_2019/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2026 Eclipse ThreadX contributors +# +# SPDX-License-Identifier: MIT +# +# AI Disclosure: This file was largely AI-generated by Copilot (Claude Opus 4.8). + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/inc +) +# Portions of this file were generated with AI assistance. diff --git a/ports/win32/vs_2019/inc/ux_port.h b/ports/win32/vs_2019/inc/ux_port.h new file mode 100644 index 000000000..7b5f85c48 --- /dev/null +++ b/ports/win32/vs_2019/inc/ux_port.h @@ -0,0 +1,271 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * Copyright (C) 2026 Eclipse ThreadX contributors + * + * This program and the accompanying materials are made available under the + * terms of the MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ +// Portions of this file were generated with AI assistance. + +/* AI Disclosure: This file was largely AI-generated by Copilot (Claude Opus 4.8). */ + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** USBX Component */ +/** */ +/** Port Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* ux_port.h Win32/VS 2019 */ +/* 6.5.2.202603 */ +/* */ +/* AUTHOR */ +/* */ +/* Frédéric Desbiens */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file contains data type definitions that make USBX function */ +/* identically on a variety of different processor architectures. */ +/* This port targets the Win32 simulation environment (MSVC, 32-bit) */ +/* for use with the USBX regression test suite. It is not intended */ +/* for production use. */ +/* */ +/**************************************************************************/ + +#ifndef UX_PORT_H +#define UX_PORT_H + + +/* Determine if the optional USBX user define file should be used. */ + +#ifdef UX_INCLUDE_USER_DEFINE_FILE +#include "ux_user.h" +#endif + + +/* Include required system headers. */ + +#include +#include +#include + + +#if !defined(UX_STANDALONE) +#include "tx_api.h" +#else + +/* Standalone build: define TX-compatible types when tx_api.h is absent. */ +#if !defined(TX_API_H) && !defined(TX_PORT_H) + +#ifndef VOID +#define VOID void +typedef char CHAR; +typedef unsigned char UCHAR; +typedef int INT; +typedef unsigned int UINT; +typedef long LONG; +typedef unsigned long ULONG; +typedef short SHORT; +typedef unsigned short USHORT; +#endif + +#ifndef ULONG64_DEFINED +typedef uint64_t ULONG64; +#define ULONG64_DEFINED +#endif + +#ifndef ALIGN_TYPE_DEFINED +#define ALIGN_TYPE ULONG +#define ALIGN_TYPE_DEFINED +#endif + +#endif /* !TX_API_H && !TX_PORT_H */ +#endif /* UX_STANDALONE */ + + +/* Remap Windows SDK macros that clash with USBX identifiers. + These must appear AFTER Windows headers (pulled in by tx_api.h) so that the + Windows SDK definition of "interface" (struct __declspec(novtable)) is + overridden here. "class" does not need remapping since USBX is compiled + as C (not C++), where "class" is a plain identifier. */ + +#ifdef interface +#undef interface +#endif +#define interface usbx_interface + + +/* CPU definition — no preemptive timer required on x86/x64 simulation. */ + +#undef THREADX_X86_NO_PTIMER + + +/* Memory-mapped I/O (no IN/OUT instructions on x86). Use UX_USE_IO_INSTRUCTIONS + to disable these macros when function implementations are provided (e.g. test + utility mocks). */ + +#ifndef UX_USE_IO_INSTRUCTIONS +#define inpb(a) (*((UCHAR *)(a))) +#define inpw(a) (*((USHORT *)(a))) +#define inpl(a) (*((ULONG *)(a))) +#define outpb(a,b) (*((UCHAR *)(a)) = (UCHAR )(b)) +#define outpw(a,b) (*((USHORT *)(a)) = (USHORT)(b)) +#define outpl(a,b) (*((ULONG *)(a)) = (ULONG )(b)) +#else + +/* Function prototypes when I/O function implementations are provided. */ + +UCHAR inpb(ULONG); +ULONG inpl(ULONG); + +UCHAR outpb(ULONG,UCHAR); +ULONG outpl(ULONG,ULONG); + +/* MSVC treats inpw/outpw as built-in intrinsics that emit privileged x86 IN/OUT + instructions — these fault in user mode. The test utility provides mock + implementations named inpw_mok / outpw_mok; redirect all callers to them. */ +#ifdef _MSC_VER +USHORT inpw_mok(ULONG); +USHORT outpw_mok(ULONG, USHORT); +#define inpw(a) inpw_mok(a) +#define outpw(a, b) outpw_mok((a), (b)) +#else +USHORT inpw(ULONG); +USHORT outpw(ULONG, USHORT); +#endif + +#endif + +/* Additional generic USBX type. */ + +#ifndef SLONG_DEFINED +typedef LONG SLONG; +#define SLONG_DEFINED +#endif + + +/* Generic USBX project constants. All are wrapped in #ifndef so they can + be overridden from ux_user.h or the command line. */ + +#ifndef UX_PERIODIC_RATE +#define UX_PERIODIC_RATE 100 +#endif + +#ifndef UX_MAX_CLASS_DRIVER +#define UX_MAX_CLASS_DRIVER 8 +#endif + +#ifndef UX_MAX_SLAVE_CLASS_DRIVER +#define UX_MAX_SLAVE_CLASS_DRIVER 3 +#endif + +#ifndef UX_MAX_HCD +#define UX_MAX_HCD 2 +#endif + +#ifndef UX_MAX_DEVICES +#define UX_MAX_DEVICES 8 +#endif + +#ifndef UX_MAX_ED +#define UX_MAX_ED 80 +#endif + +#ifndef UX_MAX_TD +#define UX_MAX_TD 32 +#endif + +#ifndef UX_MAX_ISO_TD +#define UX_MAX_ISO_TD 128 +#endif + +#ifndef UX_HOST_ENUM_THREAD_STACK_SIZE +#define UX_HOST_ENUM_THREAD_STACK_SIZE (2*1024) +#endif + +#ifndef UX_THREAD_STACK_SIZE +#define UX_THREAD_STACK_SIZE (1*1024) +#endif + +#ifndef UX_THREAD_PRIORITY_ENUM +#define UX_THREAD_PRIORITY_ENUM 20 +#endif + +#ifndef UX_THREAD_PRIORITY_CLASS +#define UX_THREAD_PRIORITY_CLASS 20 +#endif + +#ifndef UX_THREAD_PRIORITY_KEYBOARD +#define UX_THREAD_PRIORITY_KEYBOARD 20 +#endif + +#ifndef UX_THREAD_PRIORITY_HCD +#define UX_THREAD_PRIORITY_HCD 2 +#endif + +#ifndef UX_THREAD_PRIORITY_DCD +#define UX_THREAD_PRIORITY_DCD 2 +#endif + +#ifndef UX_NO_TIME_SLICE +#define UX_NO_TIME_SLICE 0 +#endif + +#ifndef UX_MAX_SLAVE_LUN +#define UX_MAX_SLAVE_LUN 2 +#endif + +#ifndef UX_MAX_HOST_LUN +#define UX_MAX_HOST_LUN 2 +#endif + +#ifndef UX_HOST_CLASS_STORAGE_MAX_MEDIA +#define UX_HOST_CLASS_STORAGE_MAX_MEDIA 2 +#endif + +#ifndef UX_HOST_CLASS_STORAGE_MAX_PARTITIONS_COUNT +#define UX_HOST_CLASS_STORAGE_MAX_PARTITIONS_COUNT 8 +#endif + +#ifndef UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH +#define UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH 256 +#endif + +#ifndef UX_SLAVE_REQUEST_DATA_MAX_LENGTH +#define UX_SLAVE_REQUEST_DATA_MAX_LENGTH 4096 +#endif + + +/* Interrupt lockout constructs used to protect allocation/release that may + occur under ISR in the device stack. */ + +#ifdef TX_API_H +#define UX_INT_SAVE_AREA unsigned int old_interrupt_posture; +#define UX_DISABLE_INTS old_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE); +#define UX_RESTORE_INTS tx_interrupt_control(old_interrupt_posture); +#endif + + +/* Version ID string. */ + +#ifdef UX_SYSTEM_INIT +CHAR _ux_version_id[] = + "(c) 2024 Microsoft Corp. (c) 2026 Eclipse ThreadX contributors." + " * USBX Win32/VS 2019 Version 6.5.2.202603 *"; +#else +extern CHAR _ux_version_id[]; +#endif + +#endif /* UX_PORT_H */ diff --git a/ports/win64/vs_2022/CMakeLists.txt b/ports/win64/vs_2022/CMakeLists.txt new file mode 100644 index 000000000..526c16efd --- /dev/null +++ b/ports/win64/vs_2022/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2026 Eclipse ThreadX contributors +# +# SPDX-License-Identifier: MIT +# +# AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/inc +) +# Portions of this file were generated with AI assistance. diff --git a/ports/win64/vs_2022/inc/ux_port.h b/ports/win64/vs_2022/inc/ux_port.h new file mode 100644 index 000000000..48cbdbd7d --- /dev/null +++ b/ports/win64/vs_2022/inc/ux_port.h @@ -0,0 +1,271 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * Copyright (C) 2026 Eclipse ThreadX contributors + * + * This program and the accompanying materials are made available under the + * terms of the MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ +// Portions of this file were generated with AI assistance. + +/* AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). */ + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** USBX Component */ +/** */ +/** Port Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* ux_port.h Win64/VS 2022 */ +/* 6.5.2.202603 */ +/* */ +/* AUTHOR */ +/* */ +/* Frédéric Desbiens */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file contains data type definitions that make USBX function */ +/* identically on a variety of different processor architectures. */ +/* This port targets the Win64 simulation environment (MSVC, 64-bit) */ +/* for use with the USBX regression test suite. It is not intended */ +/* for production use. */ +/* */ +/**************************************************************************/ + +#ifndef UX_PORT_H +#define UX_PORT_H + + +/* Determine if the optional USBX user define file should be used. */ + +#ifdef UX_INCLUDE_USER_DEFINE_FILE +#include "ux_user.h" +#endif + + +/* Include required system headers. */ + +#include +#include +#include + + +#if !defined(UX_STANDALONE) +#include "tx_api.h" +#else + +/* Standalone build: define TX-compatible types when tx_api.h is absent. */ +#if !defined(TX_API_H) && !defined(TX_PORT_H) + +#ifndef VOID +#define VOID void +typedef char CHAR; +typedef unsigned char UCHAR; +typedef int INT; +typedef unsigned int UINT; +typedef long LONG; +typedef unsigned long ULONG; +typedef short SHORT; +typedef unsigned short USHORT; +#endif + +#ifndef ULONG64_DEFINED +typedef uint64_t ULONG64; +#define ULONG64_DEFINED +#endif + +#ifndef ALIGN_TYPE_DEFINED +#define ALIGN_TYPE ULONG +#define ALIGN_TYPE_DEFINED +#endif + +#endif /* !TX_API_H && !TX_PORT_H */ +#endif /* UX_STANDALONE */ + + +/* Remap Windows SDK macros that clash with USBX identifiers. + These must appear AFTER Windows headers (pulled in by tx_api.h) so that the + Windows SDK definition of "interface" (struct __declspec(novtable)) is + overridden here. "class" does not need remapping since USBX is compiled + as C (not C++), where "class" is a plain identifier. */ + +#ifdef interface +#undef interface +#endif +#define interface usbx_interface + + +/* CPU definition — no preemptive timer required on x86/x64 simulation. */ + +#undef THREADX_X86_NO_PTIMER + + +/* Memory-mapped I/O (no IN/OUT instructions on x64). Use UX_USE_IO_INSTRUCTIONS + to disable these macros when function implementations are provided (e.g. test + utility mocks). */ + +#ifndef UX_USE_IO_INSTRUCTIONS +#define inpb(a) (*((UCHAR *)(a))) +#define inpw(a) (*((USHORT *)(a))) +#define inpl(a) (*((ULONG *)(a))) +#define outpb(a,b) (*((UCHAR *)(a)) = (UCHAR )(b)) +#define outpw(a,b) (*((USHORT *)(a)) = (USHORT)(b)) +#define outpl(a,b) (*((ULONG *)(a)) = (ULONG )(b)) +#else + +/* Function prototypes when I/O function implementations are provided. */ + +UCHAR inpb(ULONG); +ULONG inpl(ULONG); + +UCHAR outpb(ULONG,UCHAR); +ULONG outpl(ULONG,ULONG); + +/* MSVC treats inpw/outpw as built-in intrinsics that emit privileged x86 IN/OUT + instructions — these fault in user mode on x64. The test utility provides mock + implementations named inpw_mok / outpw_mok; redirect all callers to them. */ +#ifdef _MSC_VER +USHORT inpw_mok(ULONG); +USHORT outpw_mok(ULONG, USHORT); +#define inpw(a) inpw_mok(a) +#define outpw(a, b) outpw_mok((a), (b)) +#else +USHORT inpw(ULONG); +USHORT outpw(ULONG, USHORT); +#endif + +#endif + +/* Additional generic USBX type. */ + +#ifndef SLONG_DEFINED +typedef LONG SLONG; +#define SLONG_DEFINED +#endif + + +/* Generic USBX project constants. All are wrapped in #ifndef so they can + be overridden from ux_user.h or the command line. */ + +#ifndef UX_PERIODIC_RATE +#define UX_PERIODIC_RATE 100 +#endif + +#ifndef UX_MAX_CLASS_DRIVER +#define UX_MAX_CLASS_DRIVER 8 +#endif + +#ifndef UX_MAX_SLAVE_CLASS_DRIVER +#define UX_MAX_SLAVE_CLASS_DRIVER 3 +#endif + +#ifndef UX_MAX_HCD +#define UX_MAX_HCD 2 +#endif + +#ifndef UX_MAX_DEVICES +#define UX_MAX_DEVICES 8 +#endif + +#ifndef UX_MAX_ED +#define UX_MAX_ED 80 +#endif + +#ifndef UX_MAX_TD +#define UX_MAX_TD 32 +#endif + +#ifndef UX_MAX_ISO_TD +#define UX_MAX_ISO_TD 128 +#endif + +#ifndef UX_HOST_ENUM_THREAD_STACK_SIZE +#define UX_HOST_ENUM_THREAD_STACK_SIZE (2*1024) +#endif + +#ifndef UX_THREAD_STACK_SIZE +#define UX_THREAD_STACK_SIZE (1*1024) +#endif + +#ifndef UX_THREAD_PRIORITY_ENUM +#define UX_THREAD_PRIORITY_ENUM 20 +#endif + +#ifndef UX_THREAD_PRIORITY_CLASS +#define UX_THREAD_PRIORITY_CLASS 20 +#endif + +#ifndef UX_THREAD_PRIORITY_KEYBOARD +#define UX_THREAD_PRIORITY_KEYBOARD 20 +#endif + +#ifndef UX_THREAD_PRIORITY_HCD +#define UX_THREAD_PRIORITY_HCD 2 +#endif + +#ifndef UX_THREAD_PRIORITY_DCD +#define UX_THREAD_PRIORITY_DCD 2 +#endif + +#ifndef UX_NO_TIME_SLICE +#define UX_NO_TIME_SLICE 0 +#endif + +#ifndef UX_MAX_SLAVE_LUN +#define UX_MAX_SLAVE_LUN 2 +#endif + +#ifndef UX_MAX_HOST_LUN +#define UX_MAX_HOST_LUN 2 +#endif + +#ifndef UX_HOST_CLASS_STORAGE_MAX_MEDIA +#define UX_HOST_CLASS_STORAGE_MAX_MEDIA 2 +#endif + +#ifndef UX_HOST_CLASS_STORAGE_MAX_PARTITIONS_COUNT +#define UX_HOST_CLASS_STORAGE_MAX_PARTITIONS_COUNT 8 +#endif + +#ifndef UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH +#define UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH 256 +#endif + +#ifndef UX_SLAVE_REQUEST_DATA_MAX_LENGTH +#define UX_SLAVE_REQUEST_DATA_MAX_LENGTH 4096 +#endif + + +/* Interrupt lockout constructs used to protect allocation/release that may + occur under ISR in the device stack. */ + +#ifdef TX_API_H +#define UX_INT_SAVE_AREA unsigned int old_interrupt_posture; +#define UX_DISABLE_INTS old_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE); +#define UX_RESTORE_INTS tx_interrupt_control(old_interrupt_posture); +#endif + + +/* Version ID string. */ + +#ifdef UX_SYSTEM_INIT +CHAR _ux_version_id[] = + "(c) 2024 Microsoft Corp. (c) 2026 Eclipse ThreadX contributors." + " * USBX Win64/VS 2022 Version 6.5.2.202603 *"; +#else +extern CHAR _ux_version_id[]; +#endif + +#endif /* UX_PORT_H */ diff --git a/scripts/build_usbx.ps1 b/scripts/build_usbx.ps1 new file mode 100644 index 000000000..5040f5801 --- /dev/null +++ b/scripts/build_usbx.ps1 @@ -0,0 +1,104 @@ +# Copyright (C) 2026 Eclipse ThreadX contributors +# +# SPDX-License-Identifier: MIT +# +# Build script for the USBX Win64/Win32 regression test suite. +# AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). +# Portions of this file were generated with AI assistance. +# Author: Frédéric Desbiens +# +# Usage: +# .\build_usbx.ps1 [-Arch win64] [-Configuration all|] [-ThreadXDir ] +# [-FilexDir ] [-NetxduoDir ] [-BuildDir ] +# [-Clean] [-Parallel ] + +[CmdletBinding()] +param( + [ValidateSet('win64', 'win32')] + [string]$Arch = 'win64', + + [AllowNull()] + [object]$Configuration = 'all', + + [int]$Parallel = [Math]::Max(1, [Environment]::ProcessorCount), + + [int]$BuildTimeoutSeconds = 600, + + [string]$BuildDir, + + [string]$ThreadXDir, + + [string]$FilexDir, + + [string]$NetxduoDir, + + [switch]$Clean +) + +$ErrorActionPreference = 'Stop' +. (Join-Path $PSScriptRoot 'ux_windows_common.ps1') + +$repoRoot = Split-Path -Parent $PSScriptRoot +$settings = Get-PortSettings -SelectedArch $Arch + +function Resolve-AbsolutePath([string]$Path) { + $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path) +} + +if (-not $BuildDir) { + $BuildDir = Join-Path $repoRoot "build\tests\$Arch" +} + +if (-not $ThreadXDir) { + $ThreadXDir = Join-Path (Split-Path -Parent $repoRoot) 'threadx-fd' +} + +if (-not $FilexDir) { + $FilexDir = Join-Path (Split-Path -Parent $repoRoot) 'filex-fd' +} + +if (-not $NetxduoDir) { + $NetxduoDir = Join-Path (Split-Path -Parent $repoRoot) 'netxduo-fd' +} + +$BuildDir = Resolve-AbsolutePath $BuildDir +$ThreadXDir = Resolve-AbsolutePath $ThreadXDir +$FilexDir = Resolve-AbsolutePath $FilexDir +$NetxduoDir = Resolve-AbsolutePath $NetxduoDir + +$selectedConfigurations = Resolve-RegressionConfigurations -RequestedConfigurations $Configuration +Write-Host "Selected configurations: $($selectedConfigurations -join ', ')" + +Enter-VisualStudioDevShell -VsArch $settings.VsArch + +foreach ($currentConfiguration in $selectedConfigurations) { + $currentBuildDirName = Get-RegressionBuildDirectoryName -ConfigurationName $currentConfiguration + $currentBuildDir = Join-Path $BuildDir $currentBuildDirName + + if ($Clean) { + Remove-BuildDirectory -Path $currentBuildDir -RepoRoot $repoRoot + } + + Remove-NinjaLock -Path $currentBuildDir + + Write-Host "Configuring $Arch / $currentConfiguration" + Invoke-NativeCommand -FilePath 'cmake' -Arguments @( + '-S', (Join-Path $repoRoot 'test\cmake\usbx'), + '-B', $currentBuildDir, + '-G', 'Ninja', + '-DCMAKE_C_COMPILER_FORCED=TRUE', + '-DCMAKE_C_COMPILER_WORKS=TRUE', + '-DCMAKE_C_ABI_COMPILED=TRUE', + '-DCMAKE_ASM_COMPILER_FORCED=TRUE', + '-DCMAKE_ASM_COMPILER_WORKS=TRUE', + "-DCMAKE_BUILD_TYPE=$currentConfiguration", + "-DTHREADX_ARCH=$($settings.UsbxArch)", + "-DTHREADX_TOOLCHAIN=$($settings.UsbxToolchain)", + "-DTHREADX_SOURCE_DIR=$ThreadXDir", + "-DFILEX_SOURCE_DIR=$FilexDir", + "-DNETXDUO_SOURCE_DIR=$NetxduoDir" + ) + + Write-Host "Building $Arch / $currentConfiguration" + Invoke-CMakeBuild -BuildDir $currentBuildDir -Parallel $Parallel -TimeoutSeconds $BuildTimeoutSeconds +} diff --git a/scripts/test_usbx.ps1 b/scripts/test_usbx.ps1 new file mode 100644 index 000000000..f92926f14 --- /dev/null +++ b/scripts/test_usbx.ps1 @@ -0,0 +1,122 @@ +# Copyright (C) 2026 Eclipse ThreadX contributors +# +# SPDX-License-Identifier: MIT +# +# Test script for the USBX Win64/Win32 regression test suite. +# AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). +# Portions of this file were generated with AI assistance. +# Author: Frédéric Desbiens +# +# Usage: +# .\test_usbx.ps1 [-Arch win64] [-Configuration all|] [-BuildDir ] +# [-TestRegex ] [-RerunFailedOnly] [-Clean] + +[CmdletBinding()] +param( + [ValidateSet('win64', 'win32')] + [string]$Arch = 'win64', + + [AllowNull()] + [object]$Configuration = 'all', + + [int]$Parallel = [Math]::Max(1, [Environment]::ProcessorCount), + + [int]$RepeatFailCount = 1, + + [int]$TestTimeoutSeconds = 120, + + [string]$TestRegex, + + [switch]$RerunFailedOnly, + + [string]$BuildDir, + + [switch]$Clean +) + +$ErrorActionPreference = 'Stop' +. (Join-Path $PSScriptRoot 'ux_windows_common.ps1') + +$repoRoot = Split-Path -Parent $PSScriptRoot +$settings = Get-PortSettings -SelectedArch $Arch + +if (-not $BuildDir) { + $BuildDir = Join-Path $repoRoot "build\tests\$Arch" +} + +$selectedConfigurations = Resolve-RegressionConfigurations -RequestedConfigurations $Configuration +Write-Host "Selected configurations: $($selectedConfigurations -join ', ')" + +Enter-VisualStudioDevShell -VsArch $settings.VsArch + +# The Win64/Win32 ThreadX simulator pins all threads to a single core for +# deterministic scheduling. Running multiple test processes in parallel causes +# timer starvation. Always enforce serial execution. +if ($Parallel -ne 1) { + Write-Warning "The Win64 ThreadX simulator pins all threads to a single core for deterministic scheduling. Running multiple test processes in parallel causes timer starvation. Forcing -Parallel 1." + $Parallel = 1 +} + +$failedConfigurations = @() + +foreach ($currentConfiguration in $selectedConfigurations) { + $currentBuildDirName = Get-RegressionBuildDirectoryName -ConfigurationName $currentConfiguration + $currentBuildDir = Join-Path $BuildDir $currentBuildDirName + $currentTestingTemporaryDir = Join-Path $currentBuildDir 'Testing\Temporary' + + try { + if ($Clean) { + $currentTestingDir = Join-Path $currentBuildDir 'Testing' + Remove-CtestTestingDirectory -Path $currentTestingDir + } + + if (-not (Test-Path -LiteralPath $currentBuildDir)) { + throw "Build directory does not exist for $Arch / ${currentConfiguration}: $currentBuildDir" + } + + Remove-NinjaLock -Path $currentBuildDir + if (Test-Path -LiteralPath $currentTestingTemporaryDir) { + Remove-Item -LiteralPath (Join-Path $currentTestingTemporaryDir 'LastTest.log') -Force -ErrorAction SilentlyContinue + Remove-Item -LiteralPath (Join-Path $currentTestingTemporaryDir 'LastTestsFailed.log') -Force -ErrorAction SilentlyContinue + } + + Write-Host "Testing $Arch / $currentConfiguration" + $ctestArguments = @( + '--test-dir', $currentBuildDir, + '--output-on-failure', + '--timeout', $TestTimeoutSeconds.ToString(), + '-j', $Parallel.ToString() + ) + + if ($RepeatFailCount -gt 1) { + $ctestArguments += @('--repeat', "until-pass:$RepeatFailCount") + } + + if ($TestRegex) { + $ctestArguments += @('-R', $TestRegex) + } + + if ($RerunFailedOnly) { + $ctestArguments += '--rerun-failed' + } + + Invoke-NativeCommand -FilePath 'ctest' -Arguments $ctestArguments + } + catch { + $failedConfigurations += @{ + Configuration = $currentConfiguration + Message = $_.Exception.Message + } + Write-Warning "Configuration failed: $currentConfiguration" + } +} + +if ($failedConfigurations.Count -gt 0) { + Write-Host '' + Write-Host 'Configuration failure summary:' + foreach ($failedConfiguration in $failedConfigurations) { + Write-Host "- $($failedConfiguration.Configuration): $($failedConfiguration.Message)" + } + + throw "One or more configurations failed: $($failedConfigurations.Configuration -join ', ')" +} diff --git a/scripts/ux_windows_common.ps1 b/scripts/ux_windows_common.ps1 new file mode 100644 index 000000000..6896cd29d --- /dev/null +++ b/scripts/ux_windows_common.ps1 @@ -0,0 +1,403 @@ +# Copyright (C) 2026 Eclipse ThreadX contributors +# +# SPDX-License-Identifier: MIT +# +# Shared helpers for the USBX Win64/Win32 build and test scripts. +# AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). +# Portions of this file were generated with AI assistance. +# Author: Frédéric Desbiens + +[CmdletBinding()] +param() + +$ErrorActionPreference = 'Stop' + +function Invoke-NativeCommand { + param( + [Parameter(Mandatory = $true)] + [string]$FilePath, + + [Parameter()] + [string[]]$Arguments = @() + ) + + & $FilePath @Arguments + if ($LASTEXITCODE -ne 0) { + throw "Command failed with exit code ${LASTEXITCODE}: $FilePath $($Arguments -join ' ')" + } +} + +function Get-CommandPathIfAvailable { + param( + [Parameter(Mandatory = $true)] + [string]$CommandName + ) + + $command = Get-Command $CommandName -ErrorAction SilentlyContinue + if ($null -eq $command) { + return $null + } + + return $command.Source +} + +function Get-PortSettings { + param( + [Parameter(Mandatory = $true)] + [string]$SelectedArch + ) + + switch ($SelectedArch) { + 'win32' { + return @{ + UsbxArch = 'win32' + UsbxToolchain = 'vs_2019' + VsArch = 'x86' + } + } + 'win64' { + return @{ + UsbxArch = 'win64' + UsbxToolchain = 'vs_2022' + VsArch = 'amd64' + } + } + default { + throw "Unsupported architecture: $SelectedArch" + } + } +} + +function Get-RegressionConfigurations { + return @( + 'default_build_coverage' + ) +} + +# Maps a CMake build-type name to a short filesystem-safe directory name. +function Get-ShortConfigName { + param( + [Parameter(Mandatory = $true)] + [string]$ConfigurationName + ) + + $knownNames = @{ + 'default_build_coverage' = 'dbc' + 'error_check_build_full_coverage' = 'ecbfc' + 'tracex_enable_build' = 'tex' + 'device_buffer_owner_build' = 'dbo' + 'device_zero_copy_build' = 'dzc' + 'nofx_build_coverage' = 'nofx' + 'optimized_build' = 'opt' + 'standalone_device_build_coverage' = 'sad' + 'standalone_device_buffer_owner_build' = 'sadb' + 'standalone_device_zero_copy_build' = 'sadz' + 'standalone_host_build_coverage' = 'sah' + 'standalone_build_coverage' = 'sa' + 'generic_build' = 'gen' + 'otg_support_build' = 'otg' + 'memory_management_build_coverage' = 'mm' + 'msrc_rtos_build' = 'msrcr' + 'msrc_standalone_build' = 'msrcsa' + } + + if ($knownNames.ContainsKey($ConfigurationName)) { + return $knownNames[$ConfigurationName] + } + + return $ConfigurationName -replace '[^a-zA-Z0-9_-]', '_' +} + +# Generic configuration resolver. +function Resolve-Configurations { + param( + [Parameter(Mandatory = $true)] + [string[]]$ValidConfigurations, + + [Parameter(Mandatory = $false)] + [AllowNull()] + [AllowEmptyCollection()] + [object]$RequestedConfigurations = 'all' + ) + + $resolvedConfigurations = @() + + if ($null -eq $RequestedConfigurations) { + $resolvedConfigurations = @('all') + } + elseif ($RequestedConfigurations -is [System.Array]) { + foreach ($requestedConfiguration in $RequestedConfigurations) { + if ($null -ne $requestedConfiguration) { + $resolvedConfigurations += [string]$requestedConfiguration + } + } + } + else { + $resolvedConfigurations = @([string]$RequestedConfigurations) + } + + $normalizedConfigurations = @() + foreach ($requestedConfiguration in $resolvedConfigurations) { + foreach ($configurationPart in ($requestedConfiguration -split ',')) { + $trimmedConfiguration = $configurationPart.Trim() + if ($trimmedConfiguration.Length -gt 0) { + $normalizedConfigurations += $trimmedConfiguration + } + } + } + + if (($normalizedConfigurations.Count -eq 0) -or ($normalizedConfigurations -contains 'all')) { + return $ValidConfigurations + } + + foreach ($normalizedConfiguration in $normalizedConfigurations) { + if ($ValidConfigurations -notcontains $normalizedConfiguration) { + throw "Unsupported configuration: $normalizedConfiguration" + } + } + + return $normalizedConfigurations +} + +function Resolve-RegressionConfigurations { + param( + [Parameter(Mandatory = $false)] + [AllowNull()] + [AllowEmptyCollection()] + [object]$RequestedConfigurations = 'all' + ) + + return Resolve-Configurations -ValidConfigurations (Get-RegressionConfigurations) ` + -RequestedConfigurations $RequestedConfigurations +} + +function Get-RegressionBuildDirectoryName { + param( + [Parameter(Mandatory = $true)] + [string]$ConfigurationName + ) + + return Get-ShortConfigName -ConfigurationName $ConfigurationName +} + +function Enter-VisualStudioDevShell { + param( + [Parameter(Mandatory = $true)] + [string]$VsArch + ) + + $targetArch = switch ($VsArch) { + 'amd64' { 'x64' } + 'x86' { 'x86' } + default { $VsArch } + } + + if ((Get-Command cl -ErrorAction SilentlyContinue) -and ($env:VSCMD_ARG_TGT_ARCH -eq $targetArch)) { + return + } + + $vsWherePath = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' + if (-not (Test-Path -LiteralPath $vsWherePath)) { + throw "Unable to locate vswhere.exe at $vsWherePath" + } + + $installationPath = & $vsWherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if (-not $installationPath) { + throw 'Unable to locate a Visual Studio installation with MSVC build tools.' + } + + $launchScript = Join-Path $installationPath 'Common7\Tools\Launch-VsDevShell.ps1' + if (-not (Test-Path -LiteralPath $launchScript)) { + throw "Unable to locate Launch-VsDevShell.ps1 at $launchScript" + } + + $env:VSCMD_SKIP_SENDTELEMETRY = '1' + & $launchScript -VsInstallationPath $installationPath -Arch $VsArch -HostArch amd64 -SkipAutomaticLocation | Out-Null + + if (-not (Get-Command cl -ErrorAction SilentlyContinue)) { + throw 'MSVC compiler environment was not activated successfully.' + } +} + +function Remove-BuildDirectory { + param( + [Parameter(Mandatory = $true)] + [string]$Path, + + [Parameter(Mandatory = $true)] + [string]$RepoRoot + ) + + $fullRepoRoot = [System.IO.Path]::GetFullPath($RepoRoot) + $fullPath = [System.IO.Path]::GetFullPath($Path) + + if (-not $fullPath.StartsWith($fullRepoRoot, [System.StringComparison]::OrdinalIgnoreCase)) { + throw "Refusing to remove a directory outside the repository: $fullPath" + } + + if (Test-Path -LiteralPath $fullPath) { + try { + Remove-Item -LiteralPath $fullPath -Recurse -Force -ErrorAction Stop + return + } catch { + Write-Warning "Failed to remove build directory '$fullPath': $($_.Exception.Message)" + } + + Get-ChildItem -LiteralPath $fullPath -Force -Recurse -ErrorAction SilentlyContinue | ForEach-Object { + try { + if (($_.Attributes -band [System.IO.FileAttributes]::ReadOnly) -ne 0) { + $_.Attributes = ($_.Attributes -band (-bnot [System.IO.FileAttributes]::ReadOnly)) + } + } catch { } + } + + try { + Remove-Item -LiteralPath $fullPath -Recurse -Force -ErrorAction Stop + } catch { + Write-Warning "Proceeding with partially cleaned build directory '$fullPath': $($_.Exception.Message)" + } + } +} + +function Remove-CtestTestingDirectory { + param( + [Parameter(Mandatory = $true)] + [string]$Path + ) + + if (-not (Test-Path -LiteralPath $Path)) { + return + } + + try { + Remove-Item -LiteralPath $Path -Recurse -Force -ErrorAction Stop + return + } catch { + Write-Warning "Failed to remove CTest directory '$Path': $($_.Exception.Message)" + } + + Get-ChildItem -LiteralPath $Path -Force -Recurse -ErrorAction SilentlyContinue | ForEach-Object { + try { + if (($_.Attributes -band [System.IO.FileAttributes]::ReadOnly) -ne 0) { + $_.Attributes = ($_.Attributes -band (-bnot [System.IO.FileAttributes]::ReadOnly)) + } + } catch { } + } + + try { + Remove-Item -LiteralPath $Path -Recurse -Force -ErrorAction Stop + } catch { + Write-Warning "Proceeding with partially cleaned CTest directory '$Path': $($_.Exception.Message)" + } +} + +function Remove-NinjaLock { + param( + [Parameter(Mandatory = $true)] + [string]$Path + ) + + $ninjaLockPath = Join-Path $Path '.ninja_lock' + if (Test-Path -LiteralPath $ninjaLockPath) { + Remove-Item -LiteralPath $ninjaLockPath -Force + } +} + +function Invoke-ProcessWithTimeout { + param( + [Parameter(Mandatory = $true)] + [string]$FilePath, + + [Parameter()] + [string[]]$Arguments = @(), + + [Parameter()] + [int]$TimeoutSeconds = 0 + ) + + $argumentList = @() + foreach ($argument in $Arguments) { + if ($argument -match '\s|"') { + $argumentList += '"' + ($argument -replace '"', '\"') + '"' + } + else { + $argumentList += $argument + } + } + + $process = Start-Process -FilePath $FilePath -ArgumentList $argumentList -NoNewWindow -PassThru + if ($TimeoutSeconds -le 0) { + $process | Wait-Process + $completed = $true + } + else { + try { + $process | Wait-Process -Timeout $TimeoutSeconds -ErrorAction Stop + $completed = $true + } + catch { + $completed = $false + } + } + + if (-not $completed) { + $null = Start-Process -FilePath 'taskkill.exe' ` + -ArgumentList @('/PID', $process.Id.ToString(), '/T', '/F') ` + -WindowStyle Hidden -Wait -PassThru + + return @{ + Completed = $false + ExitCode = $null + } + } + + $process.Refresh() + return @{ + Completed = $true + ExitCode = $process.ExitCode + } +} + +function Invoke-CMakeBuild { + param( + [Parameter(Mandatory = $true)] + [string]$BuildDir, + + [Parameter()] + [int]$Parallel = 1, + + [Parameter()] + [int]$TimeoutSeconds = 600 + ) + + Remove-NinjaLock -Path $BuildDir + $buildResult = Invoke-ProcessWithTimeout -FilePath 'ninja' -Arguments @( + '-C', $BuildDir, + '-j', $Parallel.ToString() + ) -TimeoutSeconds $TimeoutSeconds + + if ($buildResult.Completed -and ($buildResult.ExitCode -eq 0)) { + return + } + + if ($buildResult.Completed) { + throw "Ninja build failed with exit code $($buildResult.ExitCode) in $BuildDir" + } + + Write-Warning "Ninja build timed out after ${TimeoutSeconds}s in $BuildDir. Retrying the interrupted build." + Remove-NinjaLock -Path $BuildDir + $retryResult = Invoke-ProcessWithTimeout -FilePath 'ninja' -Arguments @( + '-C', $BuildDir, + '-j', $Parallel.ToString() + ) -TimeoutSeconds $TimeoutSeconds + + if ($retryResult.Completed -and ($retryResult.ExitCode -eq 0)) { + return + } + + if (-not $retryResult.Completed) { + throw "Ninja build timed out again after ${TimeoutSeconds}s in $BuildDir" + } + + throw "Ninja retry failed with exit code $($retryResult.ExitCode) in $BuildDir" +} diff --git a/test/cmake/libs/CMakeLists.txt b/test/cmake/libs/CMakeLists.txt index f66a8d25a..1e6931a9e 100644 --- a/test/cmake/libs/CMakeLists.txt +++ b/test/cmake/libs/CMakeLists.txt @@ -35,3 +35,4 @@ foreach(lib threadx netxduo filex) endforeach() endforeach() endforeach() +# Portions of this file were generated with AI assistance. diff --git a/test/cmake/libs/nx_user.h b/test/cmake/libs/nx_user.h index 3cca9406a..601148414 100644 --- a/test/cmake/libs/nx_user.h +++ b/test/cmake/libs/nx_user.h @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -78,4 +79,3 @@ } #endif - diff --git a/test/cmake/usbx/CMakeLists.txt b/test/cmake/usbx/CMakeLists.txt index fb2f69f75..aa0fddb40 100644 --- a/test/cmake/usbx/CMakeLists.txt +++ b/test/cmake/usbx/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0077 NEW) +# Suppress try_compile link step when MSVC cannot produce a runnable executable +# (e.g. when the VS environment is not fully initialised for a given target arch). +if(MSVC) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +endif() + project(usbx_test LANGUAGES C) # Use customized ux_user.h @@ -214,31 +220,119 @@ if($ENV{USBX_STATIC}) else() message(STATUS "Building usbx BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") endif() -if(NOT BUILD_SHARED_LIBS) - if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") - add_link_options(-fprofile-arcs) - add_link_options(-lgcov) + +if(MSVC) + # Win64/Win32 MSVC simulation path ------------------------------------------- + message(STATUS "Building for Windows (MSVC) - ${THREADX_ARCH}") + # Reduce timing constants so tests run faster under the Win64 simulation + # (ThreadX Win64 runs at 5x wall-clock: TX_TIMER_PERIODIC=1ms but + # TX_WIN32_TICKS_PER_INTERRUPT=5, so _ux_utility_delay_ms(X) takes X/5 ms). + # CDC-ACM device init delay: 1000ms → 100ms (saves ~3s in connection tests). + # Enumeration debounce: 100 → 10 ticks (2ms real at N=5) — safe in the + # simulator (no spurious disconnects), leaving more time for enumeration in the + # 100-tick poll windows used by tests. + # NOTE: UX_DEVICE_ADDRESS_SET_WAIT is intentionally left at default (50ms) + # because reducing it causes non-deterministic test failures — the simulated + # device needs sufficient time to switch to its new address. + # NOTE: UX_TEST_HCD_CONNECT_SLEEP left at default (100 ticks). Reducing it + # below 100 broke CDC-ACM and CCID activation (UX_HOST_CLASS_CDC_ACM_DEVICE_ + # INIT_DELAY=100 is already applied, but the host enumeration thread still + # needs ~100 ticks to complete class activation). + # NOTE: UX_TEST_HCD_DISCONNECT_SLEEP reduced from 100 to 80 ticks. DISCONNECT_ + # SLEEP must be at least DEACTIVATE_WAIT + ~25-30 ticks (overhead after the + # dummy-class sleep completes) so that the old device is fully removed before + # the next connect is signalled. At 60-70 ticks the "interfaces_scan" test + # failed because the new connect overlapped with the tail-end of the prior + # device teardown (freeing interfaces/configuration/device structures). At 80 + # ticks the gap is large enough for reliable cleanup. + # NOTE: UX_TEST_DUMMY_DEACTIVATE_WAIT reduced from 200 to 50 ticks. The + # original 200-tick sleep exists to let pending host-class transfers finish, + # but the Win64 simulator processes all transfers near-instantly (no real + # hardware), so 50 ticks (80ms real) is ample. This means device teardown + # completes at ~55 ticks from disconnect; tests that poll for device=NULL + # (e.g. CCID, HID-memory, enum_bMaxPacketSize0) can start their next iteration + # 145 ticks sooner than with the default 200-tick wait. This constant has a + # #ifndef guard in ux_host_class_dummy.c (defaulting to UX_ENUMERATION_THREAD_ + # WAIT=200) so Linux targets are unaffected. + # NOTE: UX_TEST_TICK_SCALE=5 compensates for the 5× faster ThreadX clock only + # in ux_test_sleep_break_if() timeouts (which use tx_time_get() comparisons), + # so tests like CCID that poll for disconnect/connect completion with tick-based + # timeouts get the same real-time budget as on Linux. + # NOTE: UX_HOST_CLASS_STORAGE_THREAD_SLEEP_TIME reduced from 2000ms to 400ms. + # The storage management thread cycles at this interval; the test suite uses it + # as a wait unit (×2 to ×6), so 2000ms causes usbx_ux_host_class_storage_ + # thread_entry_test to take 66s. At 400ms the simulated storage operations + # still complete well within one cycle (operations are near-instant in sim) + # while the ×N multipliers provide enough cycle count margin. + add_compile_options(/W3 /Zi -DUX_INCLUDE_USER_DEFINE_FILE -DUX_USE_IO_INSTRUCTIONS + -DUX_HOST_CLASS_CDC_ACM_DEVICE_INIT_DELAY=100 + -DUX_HOST_STACK_DEVICE_ATTACH_DEBOUNCE_DELAY=10 + -DUX_TEST_TICK_SCALE=5 + -DUX_HOST_CLASS_STORAGE_THREAD_SLEEP_TIME=400 + -DUX_TEST_HCD_DISCONNECT_SLEEP=80 + -DUX_TEST_DUMMY_DEACTIVATE_WAIT=50 + ${${CMAKE_BUILD_TYPE}}) + add_link_options(/DEBUG /INCREMENTAL:NO) + + # Copy ux_user_win.h into the same custom_inc directory where ux_user.h lands + # so that ux_user.h can #include "ux_user_win.h" without additional -I flags. + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ux_user_win.h + ${CMAKE_BINARY_DIR}/usbx/custom_inc/ux_user_win.h COPYONLY) + + # On Windows, build ThreadX, FileX and NetXDuo from source. + if(NOT DEFINED THREADX_SOURCE_DIR) + message(FATAL_ERROR + "THREADX_SOURCE_DIR must point to a ThreadX source tree. " + "Pass -DTHREADX_SOURCE_DIR= or use build_usbx.ps1.") + endif() + if(NOT DEFINED FILEX_SOURCE_DIR) + message(FATAL_ERROR + "FILEX_SOURCE_DIR must point to a FileX source tree. " + "Pass -DFILEX_SOURCE_DIR= or use build_usbx.ps1.") + endif() + if(NOT DEFINED NETXDUO_SOURCE_DIR) + message(FATAL_ERROR + "NETXDUO_SOURCE_DIR must point to a NetXDuo source tree. " + "Pass -DNETXDUO_SOURCE_DIR= or use build_usbx.ps1.") endif() -endif() -# Control if it's for 64 bit or 32 bit -if($ENV{ENABLE_64}) - message(STATUS "Building for 64bit") + add_subdirectory(${THREADX_SOURCE_DIR} threadx_build) + # Fast-forward the ThreadX Win64 simulated clock through idle periods so the + # regression suite is CPU-bound rather than wall-clock-bound (mirrors the + # Linux port's TX_LINUX_NO_IDLE_ENABLE). Applied only to the ThreadX port. + target_compile_options(threadx PRIVATE -DTX_WIN32_NO_IDLE_ENABLE) + add_subdirectory(${FILEX_SOURCE_DIR} filex_build) + # Supply the win64 pointer-extension macros to NetXDuo before adding it. + set(NX_USER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libs/nx_user.h" + CACHE FILEPATH "NetX Duo user configuration file" FORCE) + add_subdirectory(${NETXDUO_SOURCE_DIR} netxduo_build) else() - add_compile_options(-m32) - add_link_options(-m32) - message(STATUS "Building for 32bit") + if(NOT BUILD_SHARED_LIBS) + if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") + add_link_options(-fprofile-arcs) + add_link_options(-lgcov) + endif() + endif() + + # Control if it's for 64 bit or 32 bit + if($ENV{ENABLE_64}) + message(STATUS "Building for 64bit") + else() + add_compile_options(-m32) + add_link_options(-m32) + message(STATUS "Building for 32bit") + endif() + add_compile_options( + -std=c99 + -ggdb + -g3 + -gdwarf-2 + -fdiagnostics-color + -DUX_USE_IO_INSTRUCTIONS + #-DUX_DEVICE_CLASS_DFU_CUSTOM_REQUEST_ENABLE + #-DUX_DEVICE_CLASS_DFU_STATUS_MODE=1 + ${${CMAKE_BUILD_TYPE}}) endif() -add_compile_options( - -std=c99 - -ggdb - -g3 - -gdwarf-2 - -fdiagnostics-color - -DUX_USE_IO_INSTRUCTIONS - #-DUX_DEVICE_CLASS_DFU_CUSTOM_REQUEST_ENABLE - #-DUX_DEVICE_CLASS_DFU_STATUS_MODE=1 - ${${CMAKE_BUILD_TYPE}}) enable_testing() @@ -250,61 +344,67 @@ else() endif() # TODO: Unmask after adding sample for STANDALONE -if(NOT (CMAKE_BUILD_TYPE MATCHES "standalone.*")) +if(NOT MSVC AND NOT (CMAKE_BUILD_TYPE MATCHES "standalone.*")) add_subdirectory(../usbx/samples samples) endif() -# Coverage -if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") +# Coverage instrumentation (GCC/Clang only — not supported by MSVC) +if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES ".*_coverage") target_compile_options(usbx PRIVATE -fprofile-arcs -ftest-coverage) target_link_options(usbx PRIVATE -fprofile-arcs -ftest-coverage) endif() -# Build ThreadX library once -execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) -add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh - build_libs) - -add_dependencies(usbx build_libs) -target_include_directories(usbx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) - -add_library(threadx SHARED IMPORTED GLOBAL) -add_library("azrtos::threadx" ALIAS threadx) -set_target_properties( - threadx PROPERTIES IMPORTED_LOCATION - ${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) - -add_library(netxduo SHARED IMPORTED GLOBAL) -add_library("azrtos::netxduo" ALIAS netxduo) -set_target_properties( - netxduo PROPERTIES IMPORTED_LOCATION - ${CMAKE_BINARY_DIR}/../libs/netxduo/libnetxduo.so) - -add_library(filex SHARED IMPORTED GLOBAL) -add_library("azrtos::filex" ALIAS filex) -set_target_properties( - filex PROPERTIES IMPORTED_LOCATION - ${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so) - -target_compile_options( - usbx - PRIVATE -Werror - -Wall - -Wextra - -pedantic - -fmessage-length=0 - -fsigned-char - -ffunction-sections - -fdata-sections - -Wunused - -Wuninitialized - -Wmissing-declarations - -Wconversion - -Wpointer-arith - -Wshadow - -Wlogical-op - -Waggregate-return - -Wfloat-equal) +# Build ThreadX/FileX/NetXDuo shared libraries (Linux only) +if(NOT MSVC) + execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) + add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh + build_libs) + + add_dependencies(usbx build_libs) + target_include_directories(usbx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) + + add_library(threadx SHARED IMPORTED GLOBAL) + add_library("azrtos::threadx" ALIAS threadx) + set_target_properties( + threadx PROPERTIES IMPORTED_LOCATION + ${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) + + add_library(netxduo SHARED IMPORTED GLOBAL) + add_library("azrtos::netxduo" ALIAS netxduo) + set_target_properties( + netxduo PROPERTIES IMPORTED_LOCATION + ${CMAKE_BINARY_DIR}/../libs/netxduo/libnetxduo.so) + + add_library(filex SHARED IMPORTED GLOBAL) + add_library("azrtos::filex" ALIAS filex) + set_target_properties( + filex PROPERTIES IMPORTED_LOCATION + ${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so) +endif() + +if(MSVC) + target_compile_options(usbx PRIVATE /W3) +else() + target_compile_options( + usbx + PRIVATE -Werror + -Wall + -Wextra + -pedantic + -fmessage-length=0 + -fsigned-char + -ffunction-sections + -fdata-sections + -Wunused + -Wuninitialized + -Wmissing-declarations + -Wconversion + -Wpointer-arith + -Wshadow + -Wlogical-op + -Waggregate-return + -Wfloat-equal) +endif() # Remove includes and files not needed from usbx build set(UX_STANDALONE_HOST_EXCLUDES @@ -428,9 +528,15 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "generic_build") get_target_property(INCLUDES_LIST usbx INCLUDE_DIRECTORIES) set(NEW_INCLUDES_LIST "") + if(MSVC) + set(_port_to_replace "ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}") + else() + set(_port_to_replace "ports/linux/gnu") + endif() foreach(INCLUDE_LIST ${INCLUDES_LIST}) - string(REPLACE "ports/linux/gnu" "ports/generic" INCLUDE_LIST ${INCLUDE_LIST}) + string(REPLACE "${_port_to_replace}" "ports/generic" INCLUDE_LIST ${INCLUDE_LIST}) list(APPEND NEW_INCLUDES_LIST "${INCLUDE_LIST}") endforeach() set_target_properties(usbx PROPERTIES INCLUDE_DIRECTORIES "${NEW_INCLUDES_LIST}") -endif() \ No newline at end of file +endif() +# Portions of this file were generated with AI assistance. diff --git a/test/cmake/usbx/libs/CMakeLists.txt b/test/cmake/usbx/libs/CMakeLists.txt new file mode 100644 index 000000000..1e6931a9e --- /dev/null +++ b/test/cmake/usbx/libs/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) + +project(libs LANGUAGES C) + +if($ENV{ENABLE_64}) + message(STATUS "Building for 64bit") + set(NX_USER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/nx_user.h) +else() + add_compile_options(-m32) + add_link_options(-m32) + message(STATUS "Building for 32bit") +endif() +message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") + +get_filename_component(externals ${CMAKE_CURRENT_SOURCE_DIR}/../../../externals + ABSOLUTE) +add_subdirectory(${externals}/threadx threadx) +add_subdirectory(${externals}/netxduo netxduo) +add_subdirectory(${externals}/filex filex) +target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE) +if(NOT DEFINED ENV{ENABLE_IDLE}) + target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE) +endif() +target_compile_options(filex PRIVATE -DFX_ENABLE_EXFAT) + +target_compile_options(netxduo PRIVATE -DTX_ENABLE_EVENT_TRACE -DNX_PHYSICAL_HEADER=20) + +foreach(lib threadx netxduo filex) + get_target_property(dirs ${lib} INCLUDE_DIRECTORIES) + execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc) + foreach(dir ${dirs}) + file(GLOB header_files ${dir}/*.h) + foreach(header_file ${header_files}) + execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc) + endforeach() + endforeach() +endforeach() +# Portions of this file were generated with AI assistance. diff --git a/test/cmake/usbx/libs/nx_user.h b/test/cmake/usbx/libs/nx_user.h new file mode 100644 index 000000000..601148414 --- /dev/null +++ b/test/cmake/usbx/libs/nx_user.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * + * This program and the accompanying materials are made available under the + * terms of the MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ +// Portions of this file were generated with AI assistance. + + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** NetX Component */ +/** */ +/** User Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* nx_user.h PORTABLE C */ +/* 6.0 */ +/* */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file contains user defines for configuring NetX in specific */ +/* ways. This file will have an effect only if the application and */ +/* NetX library are built with NX_INCLUDE_USER_DEFINE_FILE defined. */ +/* Note that all the defines in this file may also be made on the */ +/* command line when building NetX library and application objects. */ +/* */ +/**************************************************************************/ + +#ifndef NX_USER_H +#define NX_USER_H + +/* Define the extension to hold the control block for 64-bit mode. */ +#define NX_THREAD_EXTENSION_PTR_SET(a, b) { \ + TX_THREAD *thread_ptr; \ + thread_ptr = (TX_THREAD *) (a); \ + (thread_ptr -> tx_thread_extension_ptr) = (VOID *)(b); \ + } +#define NX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + NX_PARAMETER_NOT_USED(c); \ + TX_THREAD *thread_ptr; \ + thread_ptr = tx_thread_identify(); \ + while(1)\ + { \ + if (thread_ptr -> tx_thread_extension_ptr) \ + { \ + (a) = (b *)(thread_ptr -> tx_thread_extension_ptr); \ + break; \ + } \ + tx_thread_sleep(1); \ + } \ + } +#define NX_TIMER_EXTENSION_PTR_SET(a, b) { \ + TX_TIMER *timer_ptr; \ + timer_ptr = (TX_TIMER *) (a); \ + (timer_ptr -> tx_timer_internal.tx_timer_internal_extension_ptr) = (VOID *)(b); \ + } +#define NX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + NX_PARAMETER_NOT_USED(c); \ + if (!_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr) \ + return; \ + (a) = (b *)(_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr); \ + } + +#endif diff --git a/test/cmake/usbx/regression/CMakeLists.txt b/test/cmake/usbx/regression/CMakeLists.txt index 729559c49..e00f11f27 100644 --- a/test/cmake/usbx/regression/CMakeLists.txt +++ b/test/cmake/usbx/regression/CMakeLists.txt @@ -646,6 +646,9 @@ set(test_utility_files add_library(test_utility ${test_utility_files}) target_link_libraries(test_utility PUBLIC azrtos::usbx azrtos::threadx azrtos::netxduo azrtos::filex) target_compile_definitions(test_utility PUBLIC CTEST) +if(MSVC) + target_compile_options(test_utility PRIVATE /W3) +endif() if (CMAKE_BUILD_TYPE MATCHES "msrc_rtos_build") set(test_cases @@ -734,9 +737,38 @@ else() endif() endif() +# Exclude test files that use GCC/Clang-specific directives (#warning) not +# supported by MSVC in C mode. At configure time, create patched copies in +# the build directory that replace "#warning " with the MSVC-compatible +# "#pragma message()" directive. Original source files are never modified, so +# Linux builds are unaffected. +if(MSVC) + set(_msvc_test_cases) + foreach(_src ${test_cases}) + file(READ "${_src}" _content) + if(_content MATCHES "#warning") + get_filename_component(_fname "${_src}" NAME) + set(_dst "${CMAKE_CURRENT_BINARY_DIR}/msvc_compat/${_fname}") + string(REGEX REPLACE + "#warning ([^\n\r]*)" + "#pragma message(\"warning: \\1\")" + _content "${_content}") + file(WRITE "${_dst}" "${_content}") + list(APPEND _msvc_test_cases "${_dst}") + else() + list(APPEND _msvc_test_cases "${_src}") + endif() + endforeach() + set(test_cases "${_msvc_test_cases}") +endif() + foreach(test_case ${test_cases}) get_filename_component(test_name ${test_case} NAME_WE) add_executable(${test_name} ${test_case}) target_link_libraries(${test_name} PRIVATE test_utility) + if(MSVC) + target_compile_options(${test_name} PRIVATE /W3) + endif() add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name}) endforeach() +# Portions of this file were generated with AI assistance. diff --git a/test/cmake/usbx/ux_user.h b/test/cmake/usbx/ux_user.h index 091e51ad1..fa12c2712 100644 --- a/test/cmake/usbx/ux_user.h +++ b/test/cmake/usbx/ux_user.h @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ @@ -330,5 +331,9 @@ void ux_test_assert_hit(char* file, int line); #include "usbh_core.h" #endif +/* Windows simulation port overrides (LLP64 pointer extension macros, etc.) */ +#ifdef _WIN32 +#include "ux_user_win.h" #endif +#endif diff --git a/test/cmake/usbx/ux_user_win.h b/test/cmake/usbx/ux_user_win.h new file mode 100644 index 000000000..9ea13e1ef --- /dev/null +++ b/test/cmake/usbx/ux_user_win.h @@ -0,0 +1,98 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * Copyright (C) 2026 Eclipse ThreadX contributors + * + * This program and the accompanying materials are made available under the + * terms of the MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ +// Portions of this file were generated with AI assistance. + +/* AI Disclosure: This file was largely AI-generated by Copilot (Claude Sonnet 4.6). */ + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** USBX Component */ +/** */ +/** User Specific — Windows Simulation Port */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* ux_user_win.h Win32/Win64 */ +/* 6.5.2.202603 */ +/* */ +/* AUTHOR */ +/* */ +/* Frédéric Desbiens */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file overrides selected USBX configuration constants for the */ +/* Windows simulation port. It is included by ux_user.h (which is */ +/* included when UX_INCLUDE_USER_DEFINE_FILE is defined). */ +/* */ +/* This file is intended for test builds only; it is not part of any */ +/* production configuration. */ +/* */ +/**************************************************************************/ + +#ifndef UX_USER_WIN_H +#define UX_USER_WIN_H + + +/* On 64-bit Windows the ABI is LLP64: ULONG is 32 bits while pointers are + 64 bits. USBX thread/timer entry functions receive control-block pointers + through a ULONG parameter, which silently truncates the upper 32 bits. + The UX_THREAD_EXTENSION_PTR_SET/GET and UX_TIMER_EXTENSION_PTR_SET/GET + hooks work around this by storing the full 64-bit pointer in the TX_THREAD + / TX_TIMER_INTERNAL extension field (a VOID *) and recovering it via + tx_thread_identify() / the expired-timer pointer. + Win32 builds are unaffected: on ILP32/LLP32 ULONG and pointers are both + 32 bits so the default no-op macros in ux_api.h are correct. */ + +#ifdef _WIN64 + +#define UX_THREAD_EXTENSION_PTR_SET(a, b) { \ + TX_THREAD *_tx_ptr; \ + _tx_ptr = (TX_THREAD *)(a); \ + (_tx_ptr -> tx_thread_extension_ptr) = (VOID *)(b); \ + } +#define UX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + UX_PARAMETER_NOT_USED(c); \ + TX_THREAD *_tx_ptr; \ + _tx_ptr = tx_thread_identify(); \ + while (1) \ + { \ + if (_tx_ptr -> tx_thread_extension_ptr) \ + { \ + (a) = (b *)(_tx_ptr -> tx_thread_extension_ptr); \ + break; \ + } \ + tx_thread_sleep(1); \ + } \ + } +#define UX_TIMER_EXTENSION_PTR_SET(a, b) { \ + TX_TIMER *_timer_ptr; \ + _timer_ptr = (TX_TIMER *)(a); \ + (_timer_ptr -> tx_timer_internal.tx_timer_internal_extension_ptr) = (VOID *)(b); \ + } +#define UX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + UX_PARAMETER_NOT_USED(c); \ + if (!_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr) \ + return; \ + (a) = (b *)(_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr); \ + } + +#endif /* _WIN64 */ + + +#endif /* UX_USER_WIN_H */ diff --git a/test/regression/usbx_class_multi_interface_enumeration_test.c b/test/regression/usbx_class_multi_interface_enumeration_test.c index d33d57c05..7aef028f9 100644 --- a/test/regression/usbx_class_multi_interface_enumeration_test.c +++ b/test/regression/usbx_class_multi_interface_enumeration_test.c @@ -1,4 +1,5 @@ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -21,6 +22,18 @@ #include "ux_test.h" +/* Scale factor for the hand-rolled tick-based connect/remove wait loops below. + On ports where ThreadX ticks advance faster than 1ms/tick (e.g. the Win32/ + Win64 simulator with tick batching TX_WIN32_TICKS_PER_INTERRUPT=5) a raw + N-tick budget represents 1/scale of the intended real time, which is too + tight on slower single-core hosts. Multiplying by UX_TEST_TICK_SCALE (set + to the batch factor on those ports, 1 elsewhere) restores the same real-time + budget these waits get on Linux. */ +#ifndef UX_TEST_TICK_SCALE +#define UX_TEST_TICK_SCALE 1 +#endif + + /* Define USBX demo constants. */ #define UX_DEMO_STACK_SIZE 4096 @@ -345,6 +358,8 @@ UX_HOST_CLASS *cls; static UINT ux_demo_dummy_instance_connect_wait(ULONG wait_ticks) { ULONG t0 = tx_time_get(), t1; + if (wait_ticks != 0 && wait_ticks != 0xFFFFFFFFul) + wait_ticks *= UX_TEST_TICK_SCALE; while(1) { #if defined(UX_HOST_STANDALONE) @@ -377,6 +392,8 @@ ULONG t0 = tx_time_get(), t1; static UINT ux_demo_dummy_instance_remove_wait(ULONG wait_ticks) { ULONG t0 = tx_time_get(), t1; + if (wait_ticks != 0 && wait_ticks != 0xFFFFFFFFul) + wait_ticks *= UX_TEST_TICK_SCALE; while(1) { #if defined(UX_HOST_STANDALONE) diff --git a/test/regression/usbx_ux_device_class_hid_descriptor_send_test.c b/test/regression/usbx_ux_device_class_hid_descriptor_send_test.c index b86bb29c9..6e3ef1e45 100644 --- a/test/regression/usbx_ux_device_class_hid_descriptor_send_test.c +++ b/test/regression/usbx_ux_device_class_hid_descriptor_send_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. #include "usbx_test_common_hid.h" #include "ux_host_class_hid_keyboard.h" @@ -651,7 +652,7 @@ ALIGN_TYPE tmp; /** Test case: 'if (hid_descriptor_length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH)' **/ /**************************************************/ #if UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH > 255 -#warning (hid_descriptor_length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) not tested due to buffer size too big +#pragma message("warning: (hid_descriptor_length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) not tested due to buffer size too big") #else /* Create a transfer request for the HID class descriptor. */ diff --git a/test/regression/usbx_ux_device_class_video_basic_tests.c b/test/regression/usbx_ux_device_class_video_basic_tests.c index 27c3c6215..31c2eb4e5 100644 --- a/test/regression/usbx_ux_device_class_video_basic_tests.c +++ b/test/regression/usbx_ux_device_class_video_basic_tests.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the simple video host/device class operation. */ @@ -690,7 +691,7 @@ CHAR * memory_pointer; #if !UX_TEST_MULTI_IFC_ON || !UX_TEST_MULTI_ALT_ON || !UX_TEST_MULTI_CLS_ON || \ (_CONFIGURE_DESCRIPTORS_LEN > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_ux_device_stack_descriptor_send_test.c b/test/regression/usbx_ux_device_stack_descriptor_send_test.c index 6de7006cd..596a2dac3 100644 --- a/test/regression/usbx_ux_device_stack_descriptor_send_test.c +++ b/test/regression/usbx_ux_device_stack_descriptor_send_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. #include "usbx_test_common_hid.h" #include "ux_host_class_hid_keyboard.h" @@ -435,7 +436,7 @@ UCHAR *hid_class_descriptor = device_framework_high_spe * Test case: string descriptor is too large for device to send. **************************************************/ #if UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH > 255 -#warning String descriptor too large not tested due to control buffer too big +#pragma message("warning: String descriptor too large not tested due to control buffer too big") #else /* Make the language ID framework too large. */ diff --git a/test/regression/usbx_ux_host_class_hid_logitech_pro_x_superlight_test.c b/test/regression/usbx_ux_host_class_hid_logitech_pro_x_superlight_test.c index 79e3ff1b9..14cd51e1c 100644 --- a/test/regression/usbx_ux_host_class_hid_logitech_pro_x_superlight_test.c +++ b/test/regression/usbx_ux_host_class_hid_logitech_pro_x_superlight_test.c @@ -1,4 +1,5 @@ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -364,6 +365,7 @@ UINT status; UX_HOST_CLASS_HID_REPORT *hid_report; UX_HOST_CLASS_HID_FIELD *hid_field; get_id.ux_host_class_hid_report_get_type = UX_HOST_CLASS_HID_REPORT_TYPE_INPUT; + get_id.ux_host_class_hid_report_get_report = UX_NULL; status = ux_host_class_hid_report_id_get(hid, &get_id); hid_report = get_id.ux_host_class_hid_report_get_report; while(hid_report != UX_NULL) diff --git a/test/regression/usbx_ux_host_class_storage_media_get_test.c b/test/regression/usbx_ux_host_class_storage_media_get_test.c index 5c9dd0f6a..c22fa2177 100644 --- a/test/regression/usbx_ux_host_class_storage_media_get_test.c +++ b/test/regression/usbx_ux_host_class_storage_media_get_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the storage host/device class operation. */ @@ -590,7 +591,7 @@ INT media_index; test_control_return(1); } #if UX_MAX_HOST_LUN < 2 || UX_HOST_CLASS_STORAGE_MAX_MEDIA < 2 -#warning Increase UX_MAX_HOST_LUN and UX_HOST_CLASS_STORAGE_MAX_MEDIA for coverage test +#pragma message("warning: Increase UX_MAX_HOST_LUN and UX_HOST_CLASS_STORAGE_MAX_MEDIA for coverage test") #else stepinfo(">>>>>>>>>>>>>>> ux_host_class_storage_media_get(0) - SUCCESS\n"); storage_medias[0].ux_host_class_storage_media_storage = UX_NULL; @@ -698,4 +699,4 @@ static UINT demo_thread_media_flush(VOID *storage, ULONG lun, ULONG number_block ram_disk_flush = UX_TRUE; return ram_disk_flush_status; -} \ No newline at end of file +} diff --git a/test/regression/usbx_uxe_device_audio_test.c b/test/regression/usbx_uxe_device_audio_test.c index 153653b6a..5c5e38884 100644 --- a/test/regression/usbx_uxe_device_audio_test.c +++ b/test/regression/usbx_uxe_device_audio_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -409,7 +410,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_audio APIs Test.................................. "); #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_ccid_test.c b/test/regression/usbx_uxe_device_ccid_test.c index e7b8e2056..40a8e1c10 100644 --- a/test/regression/usbx_uxe_device_ccid_test.c +++ b/test/regression/usbx_uxe_device_ccid_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -170,7 +171,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_printer APIs Test.................................. "); #if !defined(UX_DEVICE_CLASS_CCID_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_cdc_acm_test.c b/test/regression/usbx_uxe_device_cdc_acm_test.c index 2ec30e00e..2aa075e39 100644 --- a/test/regression/usbx_uxe_device_cdc_acm_test.c +++ b/test/regression/usbx_uxe_device_cdc_acm_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -64,7 +65,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_cdc_acm APIs Test.................................. "); #if !defined(UX_DEVICE_CLASS_CDC_ACM_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_dfu_test.c b/test/regression/usbx_uxe_device_dfu_test.c index cc322078f..f49339873 100644 --- a/test/regression/usbx_uxe_device_dfu_test.c +++ b/test/regression/usbx_uxe_device_dfu_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the simple dpump host/device class operation. */ @@ -265,7 +266,7 @@ ULONG test_n; /* Inform user. */ printf("Running uxe_device_dfu APIs Test.................................... "); #if !defined(UX_DEVICE_CLASS_DFU_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_hid_test.c b/test/regression/usbx_uxe_device_hid_test.c index cc0225e23..fb7767f8b 100644 --- a/test/regression/usbx_uxe_device_hid_test.c +++ b/test/regression/usbx_uxe_device_hid_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -73,7 +74,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_hid APIs Test.................................... "); #if !defined(UX_DEVICE_CLASS_HID_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_pima_test.c b/test/regression/usbx_uxe_device_pima_test.c index b9796ea80..eab21aaa9 100644 --- a/test/regression/usbx_uxe_device_pima_test.c +++ b/test/regression/usbx_uxe_device_pima_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -463,7 +464,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_pima APIs Test................................... "); #if !defined(UX_DEVICE_CLASS_PRINTER_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_printer_test.c b/test/regression/usbx_uxe_device_printer_test.c index cd81c0c30..a9f2f628f 100644 --- a/test/regression/usbx_uxe_device_printer_test.c +++ b/test/regression/usbx_uxe_device_printer_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_printer APIs Test.................................. "); #if !defined(UX_DEVICE_CLASS_PRINTER_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_stack_test.c b/test/regression/usbx_uxe_device_stack_test.c index 0a47e86f9..aa2c1c523 100644 --- a/test/regression/usbx_uxe_device_stack_test.c +++ b/test/regression/usbx_uxe_device_stack_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -74,7 +75,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_system APIs Test........................................ "); #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_storage_test.c b/test/regression/usbx_uxe_device_storage_test.c index d68504dce..bd10e83d0 100644 --- a/test/regression/usbx_uxe_device_storage_test.c +++ b/test/regression/usbx_uxe_device_storage_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -73,7 +74,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_storage APIs Test................................ "); #if !defined(UX_DEVICE_CLASS_STORAGE_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_device_video_test.c b/test/regression/usbx_uxe_device_video_test.c index 9a4a3f00c..9269247b2 100644 --- a/test/regression/usbx_uxe_device_video_test.c +++ b/test/regression/usbx_uxe_device_video_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -451,7 +452,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_device_video APIs Test.................................. "); #if !defined(UX_DEVICE_CLASS_VIDEO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_audio_test.c b/test/regression/usbx_uxe_host_audio_test.c index a2544d25b..b9bf4a50e 100644 --- a/test/regression/usbx_uxe_host_audio_test.c +++ b/test/regression/usbx_uxe_host_audio_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_audio APIs Test.................................... "); #if !defined(UX_HOST_CLASS_AUDIO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_cdc_acm_test.c b/test/regression/usbx_uxe_host_cdc_acm_test.c index cd369b0bf..d73bf890a 100644 --- a/test/regression/usbx_uxe_host_cdc_acm_test.c +++ b/test/regression/usbx_uxe_host_cdc_acm_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_cdc_acm APIs Test.................................. "); #if !defined(UX_HOST_CLASS_CDC_ACM_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_gser_test.c b/test/regression/usbx_uxe_host_gser_test.c index 4862f4cd0..d091e3605 100644 --- a/test/regression/usbx_uxe_host_gser_test.c +++ b/test/regression/usbx_uxe_host_gser_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_gser APIs Test..................................... "); #if !defined(UX_HOST_CLASS_GSER_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_hid_test.c b/test/regression/usbx_uxe_host_hid_test.c index ad89b9813..ec03a3c27 100644 --- a/test/regression/usbx_uxe_host_hid_test.c +++ b/test/regression/usbx_uxe_host_hid_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -79,7 +80,7 @@ CHAR *memory_pointer; !defined(UX_DEVICE_CLASS_HID_KEYBOARD_ENABLE_ERROR_CHECKING) ||\ !defined(UX_DEVICE_CLASS_HID_MOUSE_ENABLE_ERROR_CHECKING) ||\ !defined(UX_DEVICE_CLASS_HID_REMOTE_CONTROL_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_pima_test.c b/test/regression/usbx_uxe_host_pima_test.c index e22a69fb5..0d1b7a935 100644 --- a/test/regression/usbx_uxe_host_pima_test.c +++ b/test/regression/usbx_uxe_host_pima_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -64,7 +65,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_pima APIs Test.................................... "); #if !defined(UX_HOST_CLASS_PIMA_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_printer_test.c b/test/regression/usbx_uxe_host_printer_test.c index 77d961956..ef735dcf1 100644 --- a/test/regression/usbx_uxe_host_printer_test.c +++ b/test/regression/usbx_uxe_host_printer_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_printer APIs Test.................................... "); #if !defined(UX_HOST_CLASS_PRINTER_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_prolific_test.c b/test/regression/usbx_uxe_host_prolific_test.c index 1967bcf30..48c8f22b3 100644 --- a/test/regression/usbx_uxe_host_prolific_test.c +++ b/test/regression/usbx_uxe_host_prolific_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_prolific APIs Test................................. "); #if !defined(UX_HOST_CLASS_PROLIFIC_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_stack_test.c b/test/regression/usbx_uxe_host_stack_test.c index 175b3c854..1cba13453 100644 --- a/test/regression/usbx_uxe_host_stack_test.c +++ b/test/regression/usbx_uxe_host_stack_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -75,7 +76,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_system APIs Test........................................ "); #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_storage_test.c b/test/regression/usbx_uxe_host_storage_test.c index 490509ab3..dcb46d3ba 100644 --- a/test/regression/usbx_uxe_host_storage_test.c +++ b/test/regression/usbx_uxe_host_storage_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_storage APIs Test.................................... "); #if !defined(UX_HOST_CLASS_STORAGE_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_swar_test.c b/test/regression/usbx_uxe_host_swar_test.c index 3deddddf0..ae0ca2f47 100644 --- a/test/regression/usbx_uxe_host_swar_test.c +++ b/test/regression/usbx_uxe_host_swar_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -65,7 +66,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_swar APIs Test..................................... "); #if !defined(UX_HOST_CLASS_SWAR_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_host_video_test.c b/test/regression/usbx_uxe_host_video_test.c index 23d4ef114..9eb72c209 100644 --- a/test/regression/usbx_uxe_host_video_test.c +++ b/test/regression/usbx_uxe_host_video_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -64,7 +65,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_host_video APIs Test.................................... "); #if !defined(UX_HOST_CLASS_VIDEO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/usbx_uxe_system_test.c b/test/regression/usbx_uxe_system_test.c index 2ac99c7b9..243f46b7a 100644 --- a/test/regression/usbx_uxe_system_test.c +++ b/test/regression/usbx_uxe_system_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,6 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* This test is designed to test the ux_utility_descriptor_pack. */ @@ -72,7 +73,7 @@ CHAR *memory_pointer; /* Inform user. */ printf("Running uxe_system APIs Test........................................ "); #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING) -#warning Tests skipped due to compile option! +#pragma message("warning: Tests skipped due to compile option!") printf("SKIP SUCCESS!\n"); test_control_return(0); return; diff --git a/test/regression/ux_host_class_dummy.c b/test/regression/ux_host_class_dummy.c index 1bfea99fa..3ce7e4b01 100644 --- a/test/regression/ux_host_class_dummy.c +++ b/test/regression/ux_host_class_dummy.c @@ -1,4 +1,5 @@ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -15,6 +16,12 @@ #include "ux_host_class_dummy.h" #include "ux_host_stack.h" +/* Overridable deactivation wait so the Win64 simulator can reduce + the 200-tick default without affecting Linux/hardware targets. */ +#ifndef UX_TEST_DUMMY_DEACTIVATE_WAIT +#define UX_TEST_DUMMY_DEACTIVATE_WAIT UX_ENUMERATION_THREAD_WAIT +#endif + static UINT _ux_host_class_dummy_activate(UX_HOST_CLASS_COMMAND *command); static UINT _ux_host_class_dummy_deactivate(UX_HOST_CLASS_COMMAND *command); @@ -217,7 +224,7 @@ UX_ENDPOINT *endpoint; } /* If the class instance was busy, let it finish properly and not return. */ - _ux_host_thread_sleep(UX_ENUMERATION_THREAD_WAIT); + _ux_host_thread_sleep(UX_TEST_DUMMY_DEACTIVATE_WAIT); /* Destroy the instance. */ _ux_host_stack_class_instance_destroy(dummy -> ux_host_class_dummy_class, (VOID *) dummy); @@ -347,7 +354,7 @@ UX_ENDPOINT *endpoint; } /* If the class instance was busy, let it finish properly and not return. */ - _ux_host_thread_sleep(UX_ENUMERATION_THREAD_WAIT); + _ux_host_thread_sleep(UX_TEST_DUMMY_DEACTIVATE_WAIT); /* Destroy the instance. */ _ux_host_stack_class_instance_destroy(dummy -> ux_host_class_dummy_class, (VOID *) dummy); diff --git a/test/regression/ux_test.c b/test/regression/ux_test.c index f8cfdc110..a4a9b5dd4 100644 --- a/test/regression/ux_test.c +++ b/test/regression/ux_test.c @@ -1,4 +1,4 @@ -/***************************************************************************/ +/***************************************************************************/ /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -8,11 +8,21 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. -#include "ux_test.h" +#include "ux_test.h" #include "ux_test_hcd_sim_host.h" #include "ux_test_dcd_sim_slave.h" +/* Scale factor for tick-based timeouts in ux_test_sleep_break_if(). + On ports where ThreadX ticks advance faster than 1ms/tick (e.g. Win64 with + tick batching TX_WIN32_TICKS_PER_INTERRUPT=5), set this to the batch factor + so that ux_test_sleep_break_if(N, ...) waits N*scale ticks — the same real + time as N ticks would give on Linux (1ms/tick). */ +#ifndef UX_TEST_TICK_SCALE +#define UX_TEST_TICK_SCALE 1 +#endif + #define UX_TEST_TIMEOUT_MS 3000 static UX_TEST_ACTION ux_test_action_handler_check(UX_TEST_ACTION *action, UX_TEST_FUNCTION usbx_function, void *params, UCHAR advance); @@ -1312,7 +1322,7 @@ UINT status; } } t1 = tx_time_get(); - if (_ux_utility_time_elapsed(t0, t1) >= tick) + if (_ux_utility_time_elapsed(t0, t1) >= (tick * UX_TEST_TICK_SCALE)) { return(UX_TIMEOUT); } diff --git a/test/regression/ux_test_hcd_sim_host.c b/test/regression/ux_test_hcd_sim_host.c index 04f18a6ed..ac706ae68 100644 --- a/test/regression/ux_test_hcd_sim_host.c +++ b/test/regression/ux_test_hcd_sim_host.c @@ -1,4 +1,5 @@ /***************************************************************************/ +// Portions of this file were generated with AI assistance. /* Copyright (c) 2024 Microsoft Corporation */ /* Copyright (c) 2026 Eclipse ThreadX contributors */ /* */ @@ -14,6 +15,19 @@ #include "tx_api.h" #include "tx_thread.h" +/* Number of ticks for enum thread to process connect/disconnect. + Override via compile flags for ports where ticks fire faster than 1ms + (e.g. Win64 tick batching with TX_WIN32_TICKS_PER_INTERRUPT=5). + Connect sleep must be long enough for full enumeration to complete. + Disconnect sleep must be short enough that device structures are not + freed before tests that intentionally use them after disconnect. */ +#ifndef UX_TEST_HCD_CONNECT_SLEEP +#define UX_TEST_HCD_CONNECT_SLEEP 100 +#endif +#ifndef UX_TEST_HCD_DISCONNECT_SLEEP +#define UX_TEST_HCD_DISCONNECT_SLEEP 100 +#endif + #include "ux_api.h" #include "ux_hcd_sim_host.h" @@ -74,7 +88,7 @@ VOID ux_test_hcd_sim_host_disconnect(VOID) #else /* Sleep current thread for enum thread to run. */ - tx_thread_sleep(100); + tx_thread_sleep(UX_TEST_HCD_DISCONNECT_SLEEP); #endif } @@ -133,7 +147,7 @@ VOID ux_test_hcd_sim_host_connect(ULONG speed) ux_test_hcd_sim_host_connect_no_wait(speed); /* Sleep current thread for enum thread to run. */ - tx_thread_sleep(100); + tx_thread_sleep(UX_TEST_HCD_CONNECT_SLEEP); } /* Fork and modify _ux_hcd_sim_host_port_status_get. */