Files
filex/scripts/test_fx.ps1
T
Frédéric DesbiensandCopilot 7cbe022bab Added Win64/VS 2022 port for FileX (#94)
- New port: ports/win64/vs_2022/inc/fx_port.h
  - Based on the Win32 port; updated ALIGN_TYPE to ULONG64 for 64-bit
    pointers, added FX_REGRESSION_TEST hooks from the Linux port, and
    bumped the port name string to Win64/Visual.
- New CMake infrastructure: ports/win64/vs_2022/CMakeLists.txt
  - Exposes only the inc/ directory (port is header-only).
- Updated test/cmake/CMakeLists.txt
  - Added MSVC guards: skip -m32 / GCC coverage flags; locate VS 2022
    toolchain; build ThreadX from source alongside FileX via
    THREADX_SOURCE_DIR.
- Updated test/cmake/regression/CMakeLists.txt
  - Added MSVC-compatible compile options (/W3 /Zi instead of -Wall
    -fprofile-arcs); added win64_compat include path for standalone +
    MSVC builds; added per-test TIMEOUT overrides for the two inherently
    long-running fault-tolerant tests on Windows.
- Updated test/cmake/samples/CMakeLists.txt
  - Added MSVC-compatible flag handling.
- New PowerShell scripts: scripts/build_fx.ps1, scripts/test_fx.ps1,
  scripts/fx_windows_common.ps1
  - Support all 9 build configurations; -Clean, -Config, -Verbose flags;
    modelled on the ThreadX Win64 build/test scripts.
- New Windows compatibility shims for standalone builds:
  test/regression_test/win64_compat/pthread.h
  test/regression_test/win64_compat/unistd.h
  - Minimal pthreads (CreateThread / WaitForSingleObject / TerminateThread)
    and usleep (Sleep) shims so standalone test files compile on MSVC.
- Fixed test/regression_test/fx_ram_driver_test.c and .h
  - RAM driver: added bounds check so out-of-range sector READs use a
    safe scratch buffer instead of segfaulting.
  - MSVC: large test buffers (ram_disk_memory_large, large_data_buffer,
    and standalone-mode ram_disk_memory / ram_disk_memory1) moved from
    BSS to calloc() via a .CRT\ constructor.  This avoids the MSVC
    PE image 2 GB hard limit (LNK1248) and eliminates demand-zero page-
    fault overhead that would otherwise slow the test suite.
- Bulk-fixed 93 fault-tolerant test files
  - [FAULT_TOLERANT_SIZE] -> [FAULT_TOLERANT_SIZE > 0 ? FAULT_TOLERANT_SIZE : 1]
    so that MSVC C2466 (zero-length array) is not triggered when
    FX_ENABLE_FAULT_TOLERANT is not defined.
- Fixed filextestcontrol.c: standalone test runner thread exit
  - The Win64 pthread shim makes pthread_exit() a no-op so that
    test_control_thread_entry() proceeds to exit(failed_tests),
    giving ctest the correct process exit code.
- Fixed common/src/fx_utility_logical_sector_write.c
  - Added missing bounds guard to prevent sector-write past end of
    RAM disk during fault-tolerant interrupt simulation tests.

All 9 build configurations pass 136/136 regression tests on Win64/VS 2022.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-15 13:15:22 -04:00

122 lines
3.9 KiB
PowerShell

[CmdletBinding()]
param(
[ValidateSet('win64', 'win32')]
[string]$Arch = 'win64',
[AllowNull()]
[object]$Configuration = 'all',
[int]$Parallel = [Math]::Max(1, [Environment]::ProcessorCount),
[int]$RepeatFailCount = 1,
[int]$TestTimeoutSeconds = 60,
[switch]$CollectFailureDiagnostics = $true,
[string]$TestRegex,
[switch]$RerunFailedOnly,
[string]$BuildDir,
[switch]$Clean
)
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'fx_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
if (($settings.FileXArch -eq 'win32') -or ($settings.FileXArch -eq 'win64')) {
if ($Parallel -ne 1) {
Write-Warning "Windows simulator regression tests are timing-sensitive under concurrent ctest execution. 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 {
if ($CollectFailureDiagnostics -and (Test-Path -LiteralPath $currentBuildDir)) {
try {
Invoke-CtestFailureDiagnostics -BuildDir $currentBuildDir -TestingTemporaryDir $currentTestingTemporaryDir `
-TimeoutSeconds $TestTimeoutSeconds
}
catch {
Write-Warning "Failure diagnostics collection failed for ${currentConfiguration}: $($_.Exception.Message)"
}
}
$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 ', ')"
}