From 80ac39026dc759946050d7f7bed0b1b97faba51e Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 07:43:33 -0500 Subject: [PATCH 1/8] feat: runtime test --- .github/workflows/runtime-tests.yml | 273 ++++++++++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 .github/workflows/runtime-tests.yml diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml new file mode 100644 index 0000000..62b1b1a --- /dev/null +++ b/.github/workflows/runtime-tests.yml @@ -0,0 +1,273 @@ +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 + 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 + + - 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 \ No newline at end of file From 43161499f78c91ff7d121f47bbd2ddec3ae26a7c Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 07:45:41 -0500 Subject: [PATCH 2/8] fix: unicode wstring --- .github/workflows/runtime-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index 62b1b1a..8e0df2e 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -265,7 +265,7 @@ jobs: - 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 + 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: | From 97d7a4a58c8722ecba1c8b4396f562ce3f0d1a23 Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 07:46:56 -0500 Subject: [PATCH 3/8] fix: compile --- .github/workflows/runtime-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index 8e0df2e..e3b8808 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -265,7 +265,7 @@ jobs: - 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 + cl /O2 /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr.exe - name: Note about elevation run: | From 5dcef5608c4f3947b5b8a410221c775e4cebb97c Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 07:52:11 -0500 Subject: [PATCH 4/8] fix: cl command in yml --- .github/workflows/runtime-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index e3b8808..66a9ad0 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -265,7 +265,8 @@ jobs: - name: Build win-witr run: | - cl /O2 /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr.exe + 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: | From 6c5f20140838536e63ce3cafeb91f2ee51639338 Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 07:55:53 -0500 Subject: [PATCH 5/8] fix: again --- .github/workflows/runtime-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index 66a9ad0..746c878 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -19,7 +19,7 @@ jobs: - 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 + 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!" } From a97ca5b9f01254396237d76020fc05f731bdd62f Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 08:26:18 -0500 Subject: [PATCH 6/8] feat: add commenting to yml --- .github/workflows/runtime-tests.yml | 281 ++++++++++++++++------------ 1 file changed, 162 insertions(+), 119 deletions(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index 746c878..c6d2503 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -17,258 +17,301 @@ jobs: - name: Setup MSVC uses: ilammy/msvc-dev-cmd@v1 + - name: Initialize test results + run: | + @" + BUILD=⏳ + HELP=⏳ + VERSION=⏳ + PID_TESTS=⏳ + ERROR_HANDLING=⏳ + PROCESS_LOOKUP=⏳ + OUTPUT_VALIDATION=⏳ + STRESS_TESTS=⏳ + UNICODE=⏳ + "@ | Out-File -FilePath test-results.txt + - name: Build win-witr + id: build + continue-on-error: true 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) { + (Get-Content test-results.txt) -replace 'BUILD=⏳', 'BUILD=❌' | Set-Content test-results.txt throw "Build failed!" } + (Get-Content test-results.txt) -replace 'BUILD=⏳', 'BUILD=✅' | Set-Content test-results.txt # ============ HELP COMMAND TESTS ============ - - name: Test --help flag + - name: Test help commands + id: help + continue-on-error: true run: | Write-Host "Testing --help flag..." -ForegroundColor Cyan ./win-witr.exe --help if ($LASTEXITCODE -ne 0) { + (Get-Content test-results.txt) -replace 'HELP=⏳', 'HELP=❌' | Set-Content test-results.txt 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) { + (Get-Content test-results.txt) -replace 'HELP=⏳', 'HELP=❌' | Set-Content test-results.txt throw "❌ Short help failed" } - Write-Host "✅ -h passed" -ForegroundColor Green + + (Get-Content test-results.txt) -replace 'HELP=⏳', 'HELP=✅' | Set-Content test-results.txt + Write-Host "✅ Help tests passed" -ForegroundColor Green # ============ VERSION COMMAND TESTS ============ - - name: Test --version flag + - name: Test version commands + id: version + continue-on-error: true 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+") { + (Get-Content test-results.txt) -replace 'VERSION=⏳', 'VERSION=❌' | Set-Content test-results.txt 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) { + (Get-Content test-results.txt) -replace 'VERSION=⏳', 'VERSION=❌' | Set-Content test-results.txt throw "❌ Short version failed" } - Write-Host "✅ -v passed" -ForegroundColor Green + + (Get-Content test-results.txt) -replace 'VERSION=⏳', 'VERSION=✅' | Set-Content test-results.txt + Write-Host "✅ Version tests passed" -ForegroundColor Green # ============ PID INSPECTION TESTS ============ - - name: Test --pid with System Idle Process (PID 0) + - name: Test PID inspection + id: pid + continue-on-error: true 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) { + (Get-Content test-results.txt) -replace 'PID_TESTS=⏳', 'PID_TESTS=❌' | Set-Content test-results.txt throw "❌ Current process PID inspection failed" } if ($output -notmatch "Process Ancestry") { + (Get-Content test-results.txt) -replace 'PID_TESTS=⏳', 'PID_TESTS=❌' | Set-Content test-results.txt 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 + ./win-witr.exe --pid $explorerPid 2>&1 | Out-Null } - Write-Host "✅ Explorer test completed" -ForegroundColor Green + + (Get-Content test-results.txt) -replace 'PID_TESTS=⏳', 'PID_TESTS=✅' | Set-Content test-results.txt + Write-Host "✅ PID tests passed" -ForegroundColor Green # ============ ERROR HANDLING TESTS ============ - - name: Test --pid with invalid PID (99999) + - name: Test error handling + id: errors + continue-on-error: true 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) { + $ErrorActionPreference = 'Continue' + cmd /c "win-witr.exe --pid 99999 2>&1" > $null + $exitCode = $LASTEXITCODE + if ($exitCode -eq 0) { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt 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) { + $output = cmd /c "win-witr.exe --pid notanumber 2>&1" + $exitCode = $LASTEXITCODE + if ($exitCode -eq 0) { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt throw "❌ Should fail with non-numeric PID" } - if ($output -notmatch "not a valid number") { + if (($output -join " ") -notmatch "not a valid number") { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt 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) { + $output = cmd /c "win-witr.exe --pid 2>&1" + $exitCode = $LASTEXITCODE + if ($exitCode -eq 0) { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt throw "❌ Should fail when --pid has no argument" } - if ($output -notmatch "requires an argument") { + if (($output -join " ") -notmatch "requires an argument") { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt throw "❌ Missing 'requires argument' error" } - Write-Host "✅ Missing argument handling passed" -ForegroundColor Green + + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=✅' | Set-Content test-results.txt + Write-Host "✅ Error handling tests passed" -ForegroundColor Green # ============ PROCESS NAME LOOKUP TESTS ============ - - name: Test process name with svchost.exe + - name: Test process name lookup + id: lookup + continue-on-error: true 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: | + ./win-witr.exe svchost.exe 2>&1 | Out-Null + 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) { + $ErrorActionPreference = 'Continue' + $output = cmd /c "win-witr.exe totallyFakeProcess.exe 2>&1" + $exitCode = $LASTEXITCODE + if ($exitCode -eq 0) { + (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=❌' | Set-Content test-results.txt throw "❌ Should fail for non-existent process" } - if ($output -notmatch "Could not find process") { + if (($output -join " ") -notmatch "Could not find process") { + (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=❌' | Set-Content test-results.txt throw "❌ Missing proper error message" } - Write-Host "✅ Non-existent process handling passed" -ForegroundColor Green + + (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=✅' | Set-Content test-results.txt + Write-Host "✅ Process lookup tests passed" -ForegroundColor Green # ============ OUTPUT FORMAT VALIDATION ============ - - name: Validate PID output contains required fields + - name: Test output validation + id: output + continue-on-error: true 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)) { + (Get-Content test-results.txt) -replace 'OUTPUT_VALIDATION=⏳', 'OUTPUT_VALIDATION=❌' | Set-Content test-results.txt 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 { + if ($output -notmatch "PID") { + (Get-Content test-results.txt) -replace 'OUTPUT_VALIDATION=⏳', 'OUTPUT_VALIDATION=❌' | Set-Content test-results.txt 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 { + if ($output -notmatch "ago") { + (Get-Content test-results.txt) -replace 'OUTPUT_VALIDATION=⏳', 'OUTPUT_VALIDATION=❌' | Set-Content test-results.txt throw "❌ Timestamp format incorrect" } + + (Get-Content test-results.txt) -replace 'OUTPUT_VALIDATION=⏳', 'OUTPUT_VALIDATION=✅' | Set-Content test-results.txt + Write-Host "✅ Output validation passed" -ForegroundColor Green # ============ STRESS TESTS ============ - - name: Rapid-fire stress test + - name: Test stress and performance + id: stress + continue-on-error: true 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) { + (Get-Content test-results.txt) -replace 'STRESS_TESTS=⏳', 'STRESS_TESTS=❌' | Set-Content test-results.txt 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 + + (Get-Content test-results.txt) -replace 'STRESS_TESTS=⏳', 'STRESS_TESTS=✅' | Set-Content test-results.txt + Write-Host "✅ Stress tests passed (50 iterations)" -ForegroundColor Green # ============ UNICODE HANDLING ============ - - name: Test Unicode tree characters + - name: Test Unicode handling + id: unicode + continue-on-error: true 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) { + (Get-Content test-results.txt) -replace 'UNICODE=⏳', 'UNICODE=❌' | Set-Content test-results.txt throw "❌ Unicode handling failed" } + + (Get-Content test-results.txt) -replace 'UNICODE=⏳', 'UNICODE=✅' | Set-Content test-results.txt Write-Host "✅ Unicode test passed" -ForegroundColor Green # ============ FINAL SUMMARY ============ - - name: Test Summary + - name: Display summary if: always() run: | Write-Host "" Write-Host "========================================" -ForegroundColor Magenta Write-Host " 🎉 RUNTIME TESTS COMPLETED! 🎉" -ForegroundColor Magenta Write-Host "========================================" -ForegroundColor Magenta + Get-Content test-results.txt 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 + # ============ POST PR COMMENT ============ + - name: Post PR comment with results + if: github.event_name == 'pull_request' && always() + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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 + $results = Get-Content test-results.txt | ConvertFrom-StringData + + $allPassed = $true + foreach ($value in $results.Values) { + if ($value -ne '✅') { + $allPassed = $false + break + } + } + + $emoji = if ($allPassed) { '🎉' } else { '⚠️' } + $status = if ($allPassed) { 'All Tests Passed!' } else { 'Some Tests Failed' } + + $comment = @" + ## $emoji Runtime Tests Report - - - 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 \ No newline at end of file + **Status:** $status + **Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + | Test Category | Result | + |---------------|--------| + | 🔨 Build | $($results.BUILD) | + | 📖 Help Commands | $($results.HELP) | + | 🏷️ Version Commands | $($results.VERSION) | + | 🔍 PID Inspection | $($results.PID_TESTS) | + | ⚠️ Error Handling | $($results.ERROR_HANDLING) | + | 🔎 Process Lookup | $($results.PROCESS_LOOKUP) | + | ✏️ Output Validation | $($results.OUTPUT_VALIDATION) | + | 🚀 Stress Tests | $($results.STRESS_TESTS) | + | 🌐 Unicode Handling | $($results.UNICODE) | + + --- + 🤖 Automated test report by GitHub Actions + "@ + + $comment | Out-File -FilePath comment.txt -Encoding utf8 + + gh pr comment ${{ github.event.pull_request.number }} --body-file comment.txt + + Write-Host "✅ Posted comment to PR #${{ github.event.pull_request.number }}" -ForegroundColor Green \ No newline at end of file From 55e460e34f516f678ce5c5cc4ee8b16302dbd493 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Wed, 7 Jan 2026 08:29:03 -0500 Subject: [PATCH 7/8] fix: Potential fix for code scanning alert no. 5: Workflow does not contain permissions Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/runtime-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index c6d2503..82ed4d1 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [ main, master ] +permissions: + contents: read + pull-requests: write + jobs: runtime-tests: runs-on: windows-latest From 6d6d90ff2a95c805490841ac29b43d156865cc5f Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Wed, 7 Jan 2026 08:37:26 -0500 Subject: [PATCH 8/8] fix: throwing when no --- .github/workflows/runtime-tests.yml | 77 +++++++++++++++++------------ 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/.github/workflows/runtime-tests.yml b/.github/workflows/runtime-tests.yml index 82ed4d1..d6cb25a 100644 --- a/.github/workflows/runtime-tests.yml +++ b/.github/workflows/runtime-tests.yml @@ -129,47 +129,57 @@ jobs: id: errors continue-on-error: true run: | + $failed = $false + Write-Host "Testing --pid with non-existent PID (99999)..." -ForegroundColor Cyan $ErrorActionPreference = 'Continue' - cmd /c "win-witr.exe --pid 99999 2>&1" > $null - $exitCode = $LASTEXITCODE - if ($exitCode -eq 0) { - (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt - throw "❌ Should fail with non-existent PID" + $output = cmd /c "win-witr.exe --pid 99999 2>&1" + if ($LASTEXITCODE -eq 0) { + Write-Host "❌ Should fail with non-existent PID" -ForegroundColor Red + $failed = $true + } else { + Write-Host "✅ Correctly failed with non-existent PID" -ForegroundColor Green } Write-Host "Testing --pid with non-numeric argument..." -ForegroundColor Cyan $output = cmd /c "win-witr.exe --pid notanumber 2>&1" - $exitCode = $LASTEXITCODE - if ($exitCode -eq 0) { - (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt - throw "❌ Should fail with non-numeric PID" - } - if (($output -join " ") -notmatch "not a valid number") { - (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt - throw "❌ Missing proper error message" + if ($LASTEXITCODE -eq 0) { + Write-Host "❌ Should fail with non-numeric PID" -ForegroundColor Red + $failed = $true + } elseif (($output -join " ") -notmatch "not a valid number") { + Write-Host "❌ Missing proper error message for non-numeric PID" -ForegroundColor Red + $failed = $true + } else { + Write-Host "✅ Correctly failed with non-numeric PID" -ForegroundColor Green } Write-Host "Testing --pid without argument..." -ForegroundColor Cyan $output = cmd /c "win-witr.exe --pid 2>&1" - $exitCode = $LASTEXITCODE - if ($exitCode -eq 0) { - (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt - throw "❌ Should fail when --pid has no argument" + if ($LASTEXITCODE -eq 0) { + Write-Host "❌ Should fail when --pid has no argument" -ForegroundColor Red + $failed = $true + } elseif (($output -join " ") -notmatch "requires an argument") { + Write-Host "❌ Missing 'requires argument' error" -ForegroundColor Red + $failed = $true + } else { + Write-Host "✅ Correctly failed with missing argument" -ForegroundColor Green } - if (($output -join " ") -notmatch "requires an argument") { + + if ($failed) { (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=❌' | Set-Content test-results.txt - throw "❌ Missing 'requires argument' error" + Write-Host "❌ Error handling tests failed" -ForegroundColor Red + } else { + (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=✅' | Set-Content test-results.txt + Write-Host "✅ Error handling tests passed" -ForegroundColor Green } - - (Get-Content test-results.txt) -replace 'ERROR_HANDLING=⏳', 'ERROR_HANDLING=✅' | Set-Content test-results.txt - Write-Host "✅ Error handling tests passed" -ForegroundColor Green # ============ PROCESS NAME LOOKUP TESTS ============ - name: Test process name lookup id: lookup continue-on-error: true run: | + $failed = $false + Write-Host "Testing process name lookup for svchost.exe..." -ForegroundColor Cyan ./win-witr.exe svchost.exe 2>&1 | Out-Null @@ -179,18 +189,23 @@ jobs: Write-Host "Testing with non-existent process name..." -ForegroundColor Cyan $ErrorActionPreference = 'Continue' $output = cmd /c "win-witr.exe totallyFakeProcess.exe 2>&1" - $exitCode = $LASTEXITCODE - if ($exitCode -eq 0) { - (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=❌' | Set-Content test-results.txt - throw "❌ Should fail for non-existent process" + if ($LASTEXITCODE -eq 0) { + Write-Host "❌ Should fail for non-existent process" -ForegroundColor Red + $failed = $true + } elseif (($output -join " ") -notmatch "Could not find process") { + Write-Host "❌ Missing proper error message for non-existent process" -ForegroundColor Red + $failed = $true + } else { + Write-Host "✅ Correctly failed with non-existent process" -ForegroundColor Green } - if (($output -join " ") -notmatch "Could not find process") { + + if ($failed) { (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=❌' | Set-Content test-results.txt - throw "❌ Missing proper error message" + Write-Host "❌ Process lookup tests failed" -ForegroundColor Red + } else { + (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=✅' | Set-Content test-results.txt + Write-Host "✅ Process lookup tests passed" -ForegroundColor Green } - - (Get-Content test-results.txt) -replace 'PROCESS_LOOKUP=⏳', 'PROCESS_LOOKUP=✅' | Set-Content test-results.txt - Write-Host "✅ Process lookup tests passed" -ForegroundColor Green # ============ OUTPUT FORMAT VALIDATION ============ - name: Test output validation