diff --git a/ports/win32/vs_2019/CMakeLists.txt b/ports/win32/vs_2019/CMakeLists.txt new file mode 100644 index 0000000..d5b601d --- /dev/null +++ b/ports/win32/vs_2019/CMakeLists.txt @@ -0,0 +1,12 @@ +# Portions of this file were generated with AI assistance. + +target_sources(${PROJECT_NAME} PRIVATE + # {{BEGIN_TARGET_SOURCES}} + + # {{END_TARGET_SOURCES}} +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/inc +) diff --git a/ports/win32/vs_2019/inc/fx_port.h b/ports/win32/vs_2019/inc/fx_port.h index 3fa5d2a..d0288df 100644 --- a/ports/win32/vs_2019/inc/fx_port.h +++ b/ports/win32/vs_2019/inc/fx_port.h @@ -1,14 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * Copyright (c) 2026-present Eclipse ThreadX contributors + * 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 + * AI Disclosure: This file was largely AI-generated by Copilot (Claude Opus 4.8). + * The AI-generated portions may be considered public domain (CC0-1.0) + * and not subject to the project's licence. The human contributor has + * reviewed and verified that the code is correct. + * + * SPDX-License-Identifier: MIT and CC0-1.0 **************************************************************************/ +// Portions of this file were generated with AI assistance. /**************************************************************************/ /**************************************************************************/ @@ -26,11 +31,11 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* fx_port.h Win32/Visual */ -/* 6.3.0 */ +/* 6.5.1.202602 */ /* */ /* AUTHOR */ /* */ -/* William E. Lamie, Microsoft Corporation */ +/* Eclipse ThreadX contributors */ /* */ /* DESCRIPTION */ /* */ @@ -57,6 +62,8 @@ #include "fx_user.h" #endif +#include + /* Include the ThreadX api file. */ @@ -98,7 +105,8 @@ typedef unsigned long long ULONG64; /* Define basic alignment type used in block and byte pool operations. This data type must - be at least 32-bits in size and also be large enough to hold a pointer type. */ + be at least 32-bits in size and also be large enough to hold a pointer type. + On Win32 (ILP32) ULONG is 32 bits and holds a pointer, so ULONG is sufficient. */ #ifndef ALIGN_TYPE_DEFINED #define ALIGN_TYPE_DEFINED @@ -106,19 +114,173 @@ typedef unsigned long long ULONG64; #endif -#endif +#endif /* FX_STANDALONE_ENABLE */ + + +#ifdef FX_REGRESSION_TEST + +/* Define parameters for regression test suite. */ + +#define FX_MAX_SECTOR_CACHE 256 +#define FX_MAX_FAT_CACHE 64 +#define FX_FAT_MAP_SIZE 1 + + +/* Define variables and macros used to introduce errors for the regression test suite. */ + +extern ULONG _fx_ram_driver_io_error_request; +extern ULONG _fx_ram_driver_io_request_count; +extern ULONG _fx_file_open_max_file_size_request; +extern ULONG _fx_directory_entry_read_count; +extern ULONG _fx_directory_entry_read_error_request; +extern ULONG _fx_directory_entry_write_count; +extern ULONG _fx_directory_entry_write_error_request; +extern ULONG _fx_utility_fat_entry_write_count; +extern ULONG _fx_utility_fat_entry_write_error_request; +extern ULONG _fx_utility_fat_entry_read_count; +extern ULONG _fx_utility_fat_entry_read_error_request; +extern ULONG _fx_utility_logical_sector_flush_count; +extern ULONG _fx_utility_logical_sector_flush_error_request; +extern ULONG _fx_utility_logical_sector_write_count; +extern ULONG _fx_utility_logical_sector_write_error_request; +extern ULONG _fx_utility_logical_sector_read_count; +extern ULONG _fx_utility_logical_sector_read_error_request; +extern ULONG _fx_utility_logical_sector_read_1_count; +extern ULONG _fx_utility_logical_sector_read_1_error_request; + +#ifdef FX_ENABLE_FAULT_TOLERANT +struct FX_MEDIA_STRUCT; +extern VOID fault_tolerant_enable_callback(struct FX_MEDIA_STRUCT *media_ptr, + UCHAR *fault_tolerant_memory_buffer, + ULONG log_size); +extern VOID fault_tolerant_apply_log_callback(struct FX_MEDIA_STRUCT *media_ptr, + UCHAR *fault_tolerant_memory_buffer, + ULONG log_size); +#endif /* FX_ENABLE_FAULT_TOLERANT */ + + +#define FX_DIRECTORY_ENTRY_READ_EXTENSION _fx_directory_entry_read_count++; \ + if (_fx_directory_entry_read_error_request) \ + { \ + _fx_directory_entry_read_error_request--; \ + if (_fx_directory_entry_read_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_DIRECTORY_ENTRY_WRITE_EXTENSION _fx_directory_entry_write_count++; \ + if (_fx_directory_entry_write_error_request) \ + { \ + _fx_directory_entry_write_error_request--; \ + if (_fx_directory_entry_write_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_UTILITY_FAT_ENTRY_READ_EXTENSION _fx_utility_fat_entry_read_count++; \ + if (_fx_utility_fat_entry_read_error_request) \ + { \ + _fx_utility_fat_entry_read_error_request--; \ + if (_fx_utility_fat_entry_read_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + if (_fx_utility_fat_entry_read_error_request == 10000) \ + { \ + *entry_ptr = 1; \ + _fx_utility_fat_entry_read_error_request = 0; \ + return(FX_SUCCESS); \ + } \ + if (_fx_utility_fat_entry_read_error_request == 20000) \ + { \ + *entry_ptr = media_ptr -> fx_media_fat_reserved; \ + _fx_utility_fat_entry_read_error_request = 0; \ + return(FX_SUCCESS); \ + } \ + if (_fx_utility_fat_entry_read_error_request == 30000) \ + { \ + *entry_ptr = cluster; \ + _fx_utility_fat_entry_read_error_request = 0; \ + return(FX_SUCCESS); \ + } \ + if (_fx_utility_fat_entry_read_error_request == 40000) \ + { \ + media_ptr -> fx_media_total_clusters = 0; \ + _fx_utility_fat_entry_read_error_request = 0; \ + return(FX_SUCCESS); \ + } \ + } + +#define FX_UTILITY_FAT_ENTRY_WRITE_EXTENSION _fx_utility_fat_entry_write_count++; \ + if (_fx_utility_fat_entry_write_error_request) \ + { \ + _fx_utility_fat_entry_write_error_request--; \ + if (_fx_utility_fat_entry_write_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_UTILITY_LOGICAL_SECTOR_FLUSH_EXTENSION _fx_utility_logical_sector_flush_count++; \ + if (_fx_utility_logical_sector_flush_error_request) \ + { \ + _fx_utility_logical_sector_flush_error_request--; \ + if (_fx_utility_logical_sector_flush_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION _fx_utility_logical_sector_read_count++; \ + if (_fx_utility_logical_sector_read_error_request) \ + { \ + _fx_utility_logical_sector_read_error_request--; \ + if (_fx_utility_logical_sector_read_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_UTILITY_LOGICAL_SECTOR_READ_EXTENSION_1 _fx_utility_logical_sector_read_1_count++; \ + if (_fx_utility_logical_sector_read_1_error_request) \ + { \ + _fx_utility_logical_sector_read_1_error_request--; \ + if (_fx_utility_logical_sector_read_1_error_request == 0) \ + { \ + cache_entry = FX_NULL; \ + } \ + } + +#define FX_UTILITY_LOGICAL_SECTOR_WRITE_EXTENSION _fx_utility_logical_sector_write_count++; \ + if (_fx_utility_logical_sector_write_error_request) \ + { \ + _fx_utility_logical_sector_write_error_request--; \ + if (_fx_utility_logical_sector_write_error_request == 0) \ + { \ + return(FX_IO_ERROR); \ + } \ + } + +#define FX_FAULT_TOLERANT_ENABLE_EXTENSION fault_tolerant_enable_callback(media_ptr, media_ptr -> fx_media_fault_tolerant_memory_buffer, total_size); +#define FX_FAULT_TOLERANT_APPLY_LOGS_EXTENSION fault_tolerant_apply_log_callback(media_ptr, media_ptr -> fx_media_fault_tolerant_memory_buffer, size); + +#endif /* FX_REGRESSION_TEST */ + /* Define FileX internal protection macros. If FX_SINGLE_THREAD is defined, these protection macros are effectively disabled. However, for multi-thread uses, the macros are setup to utilize a ThreadX mutex for multiple thread access control into an open media. */ +/* Reduce the mutex error checking for testing purpose. */ + #if defined(FX_SINGLE_THREAD) || defined(FX_STANDALONE_ENABLE) #define FX_PROTECT #define FX_UNPROTECT #else -#define FX_PROTECT if (media_ptr -> fx_media_id != FX_MEDIA_ID) return(FX_MEDIA_NOT_OPEN); \ - else if (tx_mutex_get(&(media_ptr -> fx_media_protect), TX_WAIT_FOREVER) != TX_SUCCESS) return(FX_MEDIA_NOT_OPEN); +#define FX_PROTECT tx_mutex_get(&(media_ptr -> fx_media_protect), TX_WAIT_FOREVER); #define FX_UNPROTECT tx_mutex_put(&(media_ptr -> fx_media_protect)); #endif @@ -131,6 +293,9 @@ typedef unsigned long long ULONG64; #define FX_DISABLE_INTS old_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE); #define FX_RESTORE_INTS tx_interrupt_control(old_interrupt_posture); #else +#ifndef FX_LEGACY_INTERRUPT_PROTECTION +#define FX_LEGACY_INTERRUPT_PROTECTION +#endif #define FX_INT_SAVE_AREA #define FX_DISABLE_INTS #define FX_RESTORE_INTS @@ -166,15 +331,15 @@ typedef unsigned long long ULONG64; #endif /* Define the update rate of the system timer. These values may also be defined at the command - line when compiling the fx_system_initialize.c module in the FileX library build. Alternatively, they can - be modified in this file or fx_user.h. Note: the update rate must be an even number of seconds greater - than or equal to 2, which is the minimal update rate for FAT time. */ + line when compiling the fx_system_initialize.c module in the FileX library build. Alternatively, + they can be modified in this file or fx_user.h. Note: the update rate must be an even number of + seconds greater than or equal to 2, which is the minimal update rate for FAT time. */ /* Define the number of seconds the timer parameters are updated in FileX. The default value is 10 seconds. This value can be overwritten externally. */ #ifndef FX_UPDATE_RATE_IN_SECONDS -#define FX_UPDATE_RATE_IN_SECONDS 10 +#define FX_UPDATE_RATE_IN_SECONDS 10 #endif @@ -196,11 +361,9 @@ typedef unsigned long long ULONG64; #ifdef FX_SYSTEM_INIT CHAR _fx_version_id[] = - "Copyright (c) 2024 Microsoft Corporation. * FileX Win32/Version 6.5.1.202602 *"; - * Copyright (c) 2026-present Eclipse ThreadX contributors + "Copyright (c) 2026 Eclipse ThreadX contributors. * FileX Win32/Visual 6.5.1.202602 *"; #else extern CHAR _fx_version_id[]; #endif -#endif - +#endif /* FX_PORT_H */ diff --git a/scripts/build_fx.ps1 b/scripts/build_fx.ps1 index 5407157..db002a2 100644 --- a/scripts/build_fx.ps1 +++ b/scripts/build_fx.ps1 @@ -1,3 +1,5 @@ +# Portions of this file were generated with AI assistance. + [CmdletBinding()] param( [ValidateSet('win64', 'win32')] @@ -28,7 +30,7 @@ if (-not $BuildDir) { } if (-not $ThreadXDir) { - $ThreadXDir = Join-Path (Split-Path -Parent $repoRoot) 'threadx-fd-codex' + $ThreadXDir = Join-Path (Split-Path -Parent $repoRoot) 'threadx-fd' } $selectedConfigurations = Resolve-RegressionConfigurations -RequestedConfigurations $Configuration diff --git a/test/cmake/CMakeLists.txt b/test/cmake/CMakeLists.txt index d6ccd66..b2168af 100644 --- a/test/cmake/CMakeLists.txt +++ b/test/cmake/CMakeLists.txt @@ -1,3 +1,5 @@ +# Portions of this file were generated with AI assistance. + cmake_minimum_required(VERSION 3.13 FATAL_ERROR) cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0057 NEW) @@ -51,7 +53,13 @@ set(standalone_no_cache_fault_tolerant_build ${no_cache_build} ${FX_FAULT_TOLERA if(MSVC) add_compile_options(/W3 /Zi) - add_link_options(/DEBUG /INCREMENTAL:NO) + # /LARGEADDRESSAWARE lets the 32-bit (win32) test executables use the full + # 4 GB user address space available to a 32-bit process on 64-bit Windows, + # instead of the default 2 GB. The large-media regression tests allocate + # ~1.7 GB of RAM-disk + data buffers (e.g. filex_file_allocate_test), which + # overflows the 2 GB limit and makes calloc return NULL -> crash. This flag + # is the default for x64, so it is a no-op for the win64 build. + add_link_options(/DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE) # Both cl.exe and gcc accept -DFOO; use it to keep the per-configuration # definitions consistent with the Linux path. add_compile_options(-DFX_REGRESSION_TEST ${${CMAKE_BUILD_TYPE}}) diff --git a/test/cmake/regression/CMakeLists.txt b/test/cmake/regression/CMakeLists.txt index 613f601..1915fff 100644 --- a/test/cmake/regression/CMakeLists.txt +++ b/test/cmake/regression/CMakeLists.txt @@ -153,9 +153,21 @@ endif() foreach(test_case ${regression_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) - add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name}) + if(MSVC) + # CMake repeats the target name in its object directory. Several descriptive + # FileX test names otherwise exceed the legacy path limit used by cl.exe in a + # normally nested Windows worktree. + string(MD5 test_target_hash ${test_name}) + string(SUBSTRING ${test_target_hash} 0 12 test_target_hash) + set(test_target fx_test_${test_target_hash}) + else() + set(test_target ${test_name}) + endif() + + add_executable(${test_target} ${test_case}) + target_link_libraries(${test_target} PRIVATE test_utility) + set_target_properties(${test_target} PROPERTIES OUTPUT_NAME ${test_name}) + add_test(NAME ${CMAKE_BUILD_TYPE}::${test_name} COMMAND ${test_target}) endforeach() # These two tests write or corrupt large amounts of data on a 900 MB RAM disk and are diff --git a/test/regression_test/filex_directory_create_delete_test.c b/test/regression_test/filex_directory_create_delete_test.c index d092469..9ad4ca7 100644 --- a/test/regression_test/filex_directory_create_delete_test.c +++ b/test/regression_test/filex_directory_create_delete_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + /* This FileX test concentrates on the basic directory create/delete operations. */ #ifndef FX_STANDALONE_ENABLE @@ -111,8 +113,10 @@ static UCHAR *cache_buffer; static UCHAR *fault_tolerant_buffer; #else static UCHAR cache_buffer[CACHE_SIZE]; +#ifdef FX_ENABLE_FAULT_TOLERANT static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE]; #endif +#endif extern ULONG _fx_ram_driver_copy_default_format; @@ -3064,4 +3068,3 @@ FX_DIR_ENTRY search_directory; test_control_return(0); } } - diff --git a/test/regression_test/filex_directory_duplicate_entries_test.c b/test/regression_test/filex_directory_duplicate_entries_test.c index 5266d66..1ff2379 100644 --- a/test/regression_test/filex_directory_duplicate_entries_test.c +++ b/test/regression_test/filex_directory_duplicate_entries_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + /* This FileX test concentrates on recovery operation when there are duplicate entries. */ #ifndef FX_STANDALONE_ENABLE @@ -49,8 +51,10 @@ static UCHAR *cache_buffer; static UCHAR *fault_tolerant_buffer; #else static UCHAR cache_buffer[CACHE_SIZE]; +#ifdef FX_ENABLE_FAULT_TOLERANT static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE]; #endif +#endif extern ULONG _fx_ram_driver_copy_default_format; diff --git a/test/regression_test/filex_directory_rename_test.c b/test/regression_test/filex_directory_rename_test.c index 36fd181..f76e8fb 100644 --- a/test/regression_test/filex_directory_rename_test.c +++ b/test/regression_test/filex_directory_rename_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + /* This FileX test concentrates on the directory rename operations. */ #ifndef FX_STANDALONE_ENABLE @@ -47,8 +49,10 @@ static UCHAR *cache_buffer; static UCHAR *fault_tolerant_buffer; #else static UCHAR cache_buffer[CACHE_SIZE]; +#ifdef FX_ENABLE_FAULT_TOLERANT static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE]; #endif +#endif /* Define thread prototypes. */ diff --git a/test/regression_test/filex_file_create_delete_test.c b/test/regression_test/filex_file_create_delete_test.c index d296ba4..43d01bb 100644 --- a/test/regression_test/filex_file_create_delete_test.c +++ b/test/regression_test/filex_file_create_delete_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + /* This FileX test concentrates on the file create/delete operations. */ #ifndef FX_STANDALONE_ENABLE @@ -54,8 +56,10 @@ static UCHAR *cache_buffer; static UCHAR *fault_tolerant_buffer; #else static UCHAR cache_buffer[CACHE_SIZE]; +#ifdef FX_ENABLE_FAULT_TOLERANT static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE]; #endif +#endif static UCHAR fat_buffer[128]; static UCHAR name_buffer[FX_MAX_LONG_NAME_LEN+1]; diff --git a/test/regression_test/filex_file_rename_test.c b/test/regression_test/filex_file_rename_test.c index c6c104e..3ff5bbd 100644 --- a/test/regression_test/filex_file_rename_test.c +++ b/test/regression_test/filex_file_rename_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + /* This FileX test concentrates on the file rename operations. */ #ifndef FX_STANDALONE_ENABLE @@ -46,8 +48,10 @@ static UCHAR *cache_buffer; static UCHAR *fault_tolerant_buffer; #else static UCHAR cache_buffer[CACHE_SIZE]; +#ifdef FX_ENABLE_FAULT_TOLERANT static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE]; #endif +#endif /* Define thread prototypes. */ diff --git a/test/regression_test/fx_ram_driver_test.h b/test/regression_test/fx_ram_driver_test.h index df9e610..be264e3 100644 --- a/test/regression_test/fx_ram_driver_test.h +++ b/test/regression_test/fx_ram_driver_test.h @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +// Portions of this file were generated with AI assistance. + #ifndef _FX_RAM_DRIVER_TEST_H_ #define _FX_RAM_DRIVER_TEST_H_ @@ -24,15 +26,28 @@ /* Define the memory buffer to format the media if enable fault tolerant feature.*/ +/* On MSVC these are heap-allocated (see fx_ram_driver_test.c) to avoid committing + huge BSS arrays and exceeding the 2 GB PE image limit, so declare them as + pointers there; other compilers keep them as BSS arrays. */ +#ifdef _MSC_VER +extern UCHAR *ram_disk_memory_large; +extern UCHAR *large_data_buffer; +#else extern UCHAR ram_disk_memory_large[900000000]; extern UCHAR large_data_buffer[900000000]; +#endif #define large_data_buffer_size 900000000 /* Define memory for tests to be run in standalone mode (without Azure RTOS: ThreadX) */ #ifdef FX_STANDALONE_ENABLE +#ifdef _MSC_VER +extern UCHAR *ram_disk_memory; +extern UCHAR *ram_disk_memory1; +#else extern UCHAR ram_disk_memory[300000000]; extern UCHAR ram_disk_memory1[30000000]; #endif +#endif /* Define a macro for test. */ /* We do not need error code anymore but still define return_value_if_fail for compatibility backward. */