-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_nvapi.ps1
More file actions
192 lines (171 loc) · 7.14 KB
/
test_nvapi.ps1
File metadata and controls
192 lines (171 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env pwsh
# test_nvapi.ps1 - Runs NVAPI C# Wrapper unit tests
# Get the directory where this script is located
$scriptRoot = $PSScriptRoot
if (-not $scriptRoot) {
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
}
# Change to script directory
Set-Location $scriptRoot
Write-Host "Working directory: $scriptRoot" -ForegroundColor Cyan
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "NVAPIWrapper Test Suite (Native + Facade)" -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
# ============================================================================
# Read version from VERSION file and calculate build number from git commits
# ============================================================================
Write-Host "Determining version number..." -ForegroundColor Yellow
$versionFile = Join-Path $scriptRoot "VERSION"
if (-not (Test-Path $versionFile)) {
Write-Host "Warning: VERSION file not found, using default version" -ForegroundColor Yellow
$version = "1.0.0"
} else {
# Read MAJOR and MINOR from VERSION file
$versionContent = Get-Content $versionFile
$major = "1"
$minor = "0"
foreach ($line in $versionContent) {
if ($line -match "^MAJOR=(\d+)") {
$major = $matches[1]
}
elseif ($line -match "^MINOR=(\d+)") {
$minor = $matches[1]
}
}
# Get git commit count for PATCH/build number
$patch = "0"
try {
# Check if git is available
$gitPath = Get-Command git -ErrorAction SilentlyContinue
if ($gitPath) {
# Get the commit count
$commitCount = & git rev-list --count HEAD 2>&1
if ($LASTEXITCODE -eq 0 -and $commitCount -match "^\d+$") {
$patch = $commitCount
}
}
}
catch {
# Silently fall back to 0
}
$version = "$major.$minor.$patch"
}
Write-Host "Testing version: $version" -ForegroundColor Green
Write-Host ""
# ============================================================================
# Verify dotnet CLI is available
# ============================================================================
Write-Host "Checking for .NET CLI..." -ForegroundColor Yellow
try {
$dotnetPath = Get-Command dotnet -ErrorAction Stop
$dotnetVersion = & dotnet --version 2>&1
Write-Host ".NET CLI found: $($dotnetPath.Source)" -ForegroundColor Green
Write-Host ".NET version: $dotnetVersion" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host ""
Write-Host "ERROR: dotnet CLI not found in PATH" -ForegroundColor Red
Write-Host ""
Write-Host "Please ensure .NET 10.0 SDK is installed" -ForegroundColor Yellow
Write-Host "Download from: https://dotnet.microsoft.com/download/dotnet/10.0" -ForegroundColor Cyan
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
# ============================================================================
# Check .NET 10.0 SDK availability
# ============================================================================
Write-Host "Checking for .NET 10.0 SDK..." -ForegroundColor Yellow
try {
$sdks = & dotnet --list-sdks 2>&1
$net10Sdk = $sdks | Where-Object { $_ -match "10\.0\." }
if ($net10Sdk) {
Write-Host ".NET 10.0 SDK found:" -ForegroundColor Green
$net10Sdk | ForEach-Object { Write-Host " $_" -ForegroundColor Green }
Write-Host ""
} else {
Write-Host ""
Write-Host "ERROR: .NET 10.0 SDK not found" -ForegroundColor Red
Write-Host ""
Write-Host "Available SDKs:" -ForegroundColor Yellow
$sdks | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
Write-Host ""
Write-Host "Please install .NET 10.0 SDK from: https://dotnet.microsoft.com/download/dotnet/10.0" -ForegroundColor Cyan
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
} catch {
Write-Host ""
Write-Host "ERROR: Failed to check .NET SDK version: $_" -ForegroundColor Red
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
# ============================================================================
# Verify test projects exist
# ============================================================================
$nativeProjectPath = Join-Path $scriptRoot "NVAPIWrapper.NativeTests\NVAPIWrapper.NativeTests.csproj"
$facadeProjectPath = Join-Path $scriptRoot "NVAPIWrapper.FacadeTests\NVAPIWrapper.FacadeTests.csproj"
foreach ($path in @($nativeProjectPath, $facadeProjectPath)) {
if (-not (Test-Path $path)) {
Write-Host "ERROR: Test project not found at: $path" -ForegroundColor Red
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "Test project found: $path" -ForegroundColor Green
}
Write-Host ""
# ============================================================================
# Build and run unit tests
# ============================================================================
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "Building and running Native + Facade unit tests..." -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host ""
Write-Host "Running tests in $nativeProjectPath" -ForegroundColor Yellow
try {
& dotnet test $nativeProjectPath --configuration Debug --verbosity normal
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "*** TESTS FAILED OR SKIPPED IN $nativeProjectPath ***" -ForegroundColor Yellow
Read-Host "Press Enter to exit..."
exit 1
}
} catch {
Write-Host ""
Write-Host "ERROR: Failed to run unit tests in $nativeProjectPath" -ForegroundColor Red
Write-Host "Error: $_" -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to exit..."
exit 1
}
Write-Host ""
Write-Host "Running tests in $facadeProjectPath" -ForegroundColor Yellow
try {
& dotnet test $facadeProjectPath --configuration Debug --verbosity normal --filter "Category=Passive"
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "*** TESTS FAILED OR SKIPPED IN $facadeProjectPath ***" -ForegroundColor Yellow
Read-Host "Press Enter to exit..."
exit 1
}
} catch {
Write-Host ""
Write-Host "ERROR: Failed to run unit tests in $facadeProjectPath" -ForegroundColor Red
Write-Host "Error: $_" -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to exit..."
exit 1
}
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Green
Write-Host "*** ALL TESTS COMPLETED (Native + Facade) ***" -ForegroundColor Green
Write-Host "============================================================================" -ForegroundColor Green
Write-Host "Tests auto-skip when hardware/driver prerequisites are missing." -ForegroundColor Gray
Write-Host ""
Read-Host "Press Enter to exit..."