-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (242 loc) · 11 KB
/
Copy pathruntime-tests.yml
File metadata and controls
274 lines (242 loc) · 11 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Runtime Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
runtime-tests:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build win-witr
run: |
cl.exe /EHsc /std:c++20 main.cpp /Fe:win-witr.exe advapi32.lib iphlpapi.lib ws2_32.lib shell32.lib /DUNICODE /D_UNICODE
if ($LASTEXITCODE -ne 0) {
throw "Build failed!"
}
# ============ HELP COMMAND TESTS ============
- name: Test --help flag
run: |
Write-Host "Testing --help flag..." -ForegroundColor Cyan
./win-witr.exe --help
if ($LASTEXITCODE -ne 0) {
throw "❌ Help command failed"
}
Write-Host "✅ --help passed" -ForegroundColor Green
- name: Test -h flag
run: |
Write-Host "Testing -h flag..." -ForegroundColor Cyan
./win-witr.exe -h
if ($LASTEXITCODE -ne 0) {
throw "❌ Short help failed"
}
Write-Host "✅ -h passed" -ForegroundColor Green
# ============ VERSION COMMAND TESTS ============
- name: Test --version flag
run: |
Write-Host "Testing --version flag..." -ForegroundColor Cyan
$output = ./win-witr.exe --version | Out-String
Write-Host $output
if ($output -notmatch "win-witr v\d+\.\d+\.\d+") {
throw "❌ Version format incorrect: $output"
}
Write-Host "✅ --version passed" -ForegroundColor Green
- name: Test -v flag
run: |
Write-Host "Testing -v flag..." -ForegroundColor Cyan
./win-witr.exe -v
if ($LASTEXITCODE -ne 0) {
throw "❌ Short version failed"
}
Write-Host "✅ -v passed" -ForegroundColor Green
# ============ PID INSPECTION TESTS ============
- name: Test --pid with System Idle Process (PID 0)
run: |
Write-Host "Testing --pid 0 (System Idle)..." -ForegroundColor Cyan
./win-witr.exe --pid 0 2>&1 | Out-Null
# May fail due to permissions, that's OK
Write-Host "✅ PID 0 test completed" -ForegroundColor Green
- name: Test --pid with System process (PID 4)
run: |
Write-Host "Testing --pid 4 (System)..." -ForegroundColor Cyan
./win-witr.exe --pid 4 2>&1 | Out-Null
# May fail due to permissions, that's OK
Write-Host "✅ PID 4 test completed" -ForegroundColor Green
- name: Test --pid with current PowerShell process
run: |
Write-Host "Testing --pid with current process ($PID)..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid $PID | Out-String
Write-Host $output
if ($LASTEXITCODE -ne 0) {
throw "❌ Current process PID inspection failed"
}
if ($output -notmatch "Process Ancestry") {
throw "❌ Output missing 'Process Ancestry'"
}
Write-Host "✅ Current process PID test passed" -ForegroundColor Green
- name: Test --pid with explorer.exe
run: |
Write-Host "Testing --pid with explorer.exe..." -ForegroundColor Cyan
$explorerPid = (Get-Process explorer -ErrorAction SilentlyContinue | Select-Object -First 1).Id
if ($explorerPid) {
Write-Host "Found explorer.exe with PID: $explorerPid"
./win-witr.exe --pid $explorerPid
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ Explorer access might be restricted" -ForegroundColor Yellow
}
} else {
Write-Host "⚠️ Explorer not running, skipping" -ForegroundColor Yellow
}
Write-Host "✅ Explorer test completed" -ForegroundColor Green
# ============ ERROR HANDLING TESTS ============
- name: Test --pid with invalid PID (99999)
run: |
Write-Host "Testing --pid with non-existent PID (99999)..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid 99999 2>&1 | Out-String
Write-Host $output
if ($LASTEXITCODE -eq 0) {
throw "❌ Should fail with non-existent PID"
}
Write-Host "✅ Invalid PID handling passed" -ForegroundColor Green
- name: Test --pid with non-numeric argument
run: |
Write-Host "Testing --pid with non-numeric argument..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid notanumber 2>&1 | Out-String
Write-Host $output
if ($LASTEXITCODE -eq 0) {
throw "❌ Should fail with non-numeric PID"
}
if ($output -notmatch "not a valid number") {
throw "❌ Missing proper error message"
}
Write-Host "✅ Non-numeric PID handling passed" -ForegroundColor Green
- name: Test --pid without argument
run: |
Write-Host "Testing --pid without argument..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid 2>&1 | Out-String
Write-Host $output
if ($LASTEXITCODE -eq 0) {
throw "❌ Should fail when --pid has no argument"
}
if ($output -notmatch "requires an argument") {
throw "❌ Missing 'requires argument' error"
}
Write-Host "✅ Missing argument handling passed" -ForegroundColor Green
# ============ PROCESS NAME LOOKUP TESTS ============
- name: Test process name with svchost.exe
run: |
Write-Host "Testing process name lookup for svchost.exe..." -ForegroundColor Cyan
$output = ./win-witr.exe svchost.exe 2>&1 | Out-String
Write-Host $output
if ($output -match "Process Name specified") {
Write-Host "✅ Found svchost.exe" -ForegroundColor Green
} else {
Write-Host "⚠️ Unexpected output format" -ForegroundColor Yellow
}
- name: Test process name with explorer.exe
run: |
Write-Host "Testing process name lookup for explorer.exe..." -ForegroundColor Cyan
./win-witr.exe explorer.exe 2>&1 | Out-Null
Write-Host "✅ Explorer lookup completed" -ForegroundColor Green
- name: Test process name with non-existent process
run: |
Write-Host "Testing with non-existent process name..." -ForegroundColor Cyan
$output = ./win-witr.exe totallyFakeProcess.exe 2>&1 | Out-String
Write-Host $output
if ($LASTEXITCODE -eq 0) {
throw "❌ Should fail for non-existent process"
}
if ($output -notmatch "Could not find process") {
throw "❌ Missing proper error message"
}
Write-Host "✅ Non-existent process handling passed" -ForegroundColor Green
# ============ OUTPUT FORMAT VALIDATION ============
- name: Validate PID output contains required fields
run: |
Write-Host "Validating output format..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid $PID | Out-String
$requiredFields = @("Executable Path", "Process Ancestry", "Started")
foreach ($field in $requiredFields) {
if ($output -notmatch [regex]::Escape($field)) {
throw "❌ Output missing required field: $field"
}
}
Write-Host "✅ Output format validation passed" -ForegroundColor Green
- name: Test ancestry tree formatting
run: |
Write-Host "Testing ancestry tree formatting..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid $PID | Out-String
# Check for tree-like structure
if ($output -match "PID") {
Write-Host "✅ Ancestry tree formatting passed" -ForegroundColor Green
} else {
throw "❌ Ancestry tree not properly formatted"
}
- name: Test timestamp format
run: |
Write-Host "Testing timestamp format..." -ForegroundColor Cyan
$output = ./win-witr.exe --pid $PID | Out-String
# Should contain "ago" and a date
if ($output -match "ago") {
Write-Host "✅ Timestamp format passed" -ForegroundColor Green
} else {
throw "❌ Timestamp format incorrect"
}
# ============ STRESS TESTS ============
- name: Rapid-fire stress test
run: |
Write-Host "Running stress test (50 rapid requests)..." -ForegroundColor Cyan
for ($i = 0; $i -lt 50; $i++) {
./win-witr.exe --pid $PID | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "❌ Stress test failed at iteration $i"
}
}
Write-Host "✅ Stress test passed (50 iterations)" -ForegroundColor Green
- name: Test multiple running processes
run: |
Write-Host "Testing against multiple running processes..." -ForegroundColor Cyan
$processes = Get-Process | Where-Object { $_.Id -ne 0 -and $_.Id -ne 4 } | Select-Object -First 5
foreach ($proc in $processes) {
Write-Host " Testing PID $($proc.Id) ($($proc.Name))..."
./win-witr.exe --pid $proc.Id 2>&1 | Out-Null
}
Write-Host "✅ Multiple process test completed" -ForegroundColor Green
# ============ UNICODE HANDLING ============
- name: Test Unicode tree characters
run: |
Write-Host "Testing Unicode character handling..." -ForegroundColor Cyan
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$output = ./win-witr.exe --pid $PID 2>&1 | Out-String
if ($LASTEXITCODE -ne 0) {
throw "❌ Unicode handling failed"
}
Write-Host "✅ Unicode test passed" -ForegroundColor Green
# ============ FINAL SUMMARY ============
- name: Test Summary
if: always()
run: |
Write-Host ""
Write-Host "========================================" -ForegroundColor Magenta
Write-Host " 🎉 RUNTIME TESTS COMPLETED! 🎉" -ForegroundColor Magenta
Write-Host "========================================" -ForegroundColor Magenta
Write-Host ""
# ============ ELEVATED PRIVILEGES TEST (separate job) ============
runtime-tests-elevated:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build win-witr
run: |
cl.exe /EHsc /std:c++20 main.cpp /Fe:win-witr.exe advapi32.lib iphlpapi.lib ws2_32.lib shell32.lib /DUNICODE /D_UNICODE
- name: Note about elevation
run: |
Write-Host "Note: GitHub Actions runners have limited elevation capabilities" -ForegroundColor Yellow
Write-Host "Some system process access tests may be skipped" -ForegroundColor Yellow