From 06bf7fe79106e1dc8f8a2c6b3b00dec4b56ebf9d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:12:55 +0000 Subject: [PATCH 1/9] Initial plan From 6f5311c47473e455fd10442e68da66d1caf0ba72 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:15:23 +0000 Subject: [PATCH 2/9] Add 19 new miscellaneous tests across multiple categories Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/edge_cases/case_sensitivity.ps1 | 32 +++++++++++++++++++ tests/edge_cases/sequential_lookups.bat | 8 +++++ tests/edge_cases/short_option_aliases.ps1 | 23 +++++++++++++ tests/edge_cases/special_pids.bat | 10 ++++++ tests/edge_cases/special_process_names.bat | 13 ++++++++ tests/edge_cases/validate_help_output.ps1 | 18 +++++++++++ tests/edge_cases/validate_version_output.ps1 | 17 ++++++++++ tests/error_handling/invalid_options.bat | 10 ++++++ tests/error_handling/invalid_pid.bat | 14 ++++++++ tests/error_handling/invalid_port.bat | 13 ++++++++ tests/error_handling/nonexistent_process.bat | 6 ++++ tests/performance/perf_port_lookup.ps1 | 22 +++++++++++++ tests/performance/perf_process_lookup.ps1 | 22 +++++++++++++ tests/performance/stress_mixed_operations.ps1 | 32 +++++++++++++++++++ tests/performance/stress_rapid_lookups.ps1 | 20 ++++++++++++ tests/pid/pid_comprehensive.ps1 | 32 +++++++++++++++++++ tests/port/port_basic.bat | 8 +++++ tests/port/port_nonexistent.bat | 3 ++ tests/process/process_comprehensive.ps1 | 27 ++++++++++++++++ 19 files changed, 330 insertions(+) create mode 100644 tests/edge_cases/case_sensitivity.ps1 create mode 100644 tests/edge_cases/sequential_lookups.bat create mode 100644 tests/edge_cases/short_option_aliases.ps1 create mode 100644 tests/edge_cases/special_pids.bat create mode 100644 tests/edge_cases/special_process_names.bat create mode 100644 tests/edge_cases/validate_help_output.ps1 create mode 100644 tests/edge_cases/validate_version_output.ps1 create mode 100644 tests/error_handling/invalid_options.bat create mode 100644 tests/error_handling/invalid_pid.bat create mode 100644 tests/error_handling/invalid_port.bat create mode 100644 tests/error_handling/nonexistent_process.bat create mode 100644 tests/performance/perf_port_lookup.ps1 create mode 100644 tests/performance/perf_process_lookup.ps1 create mode 100644 tests/performance/stress_mixed_operations.ps1 create mode 100644 tests/performance/stress_rapid_lookups.ps1 create mode 100644 tests/pid/pid_comprehensive.ps1 create mode 100644 tests/port/port_basic.bat create mode 100644 tests/port/port_nonexistent.bat create mode 100644 tests/process/process_comprehensive.ps1 diff --git a/tests/edge_cases/case_sensitivity.ps1 b/tests/edge_cases/case_sensitivity.ps1 new file mode 100644 index 0000000..5fe29de --- /dev/null +++ b/tests/edge_cases/case_sensitivity.ps1 @@ -0,0 +1,32 @@ +# Test case sensitivity in process names +# Windows process names are case-insensitive + +Write-Host "Testing case sensitivity in process names..." -ForegroundColor Yellow + +# Test with different cases +& win-witr explorer.exe | Out-Null +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed: explorer.exe" + exit 1 +} + +& win-witr EXPLORER.EXE | Out-Null +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed: EXPLORER.EXE" + exit 1 +} + +& win-witr Explorer.exe | Out-Null +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed: Explorer.exe" + exit 1 +} + +& win-witr ExPlOrEr.ExE | Out-Null +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed: ExPlOrEr.ExE" + exit 1 +} + +Write-Host "Case sensitivity test passed" -ForegroundColor Green +exit 0 diff --git a/tests/edge_cases/sequential_lookups.bat b/tests/edge_cases/sequential_lookups.bat new file mode 100644 index 0000000..32cfe23 --- /dev/null +++ b/tests/edge_cases/sequential_lookups.bat @@ -0,0 +1,8 @@ +REM Test multiple processes in sequence +REM Verifies the tool can handle sequential lookups + +win-witr explorer.exe +win-witr svchost.exe +win-witr csrss.exe +win-witr lsass.exe +win-witr winlogon.exe diff --git a/tests/edge_cases/short_option_aliases.ps1 b/tests/edge_cases/short_option_aliases.ps1 new file mode 100644 index 0000000..ac320f7 --- /dev/null +++ b/tests/edge_cases/short_option_aliases.ps1 @@ -0,0 +1,23 @@ +# Test short option aliases +# Verify that short options work the same as long options + +Write-Host "Testing short option aliases..." -ForegroundColor Yellow + +# Test -h vs --help +$helpShort = & win-witr -h 2>&1 | Out-String +$helpLong = & win-witr --help 2>&1 | Out-String + +if ($helpShort -ne $helpLong) { + Write-Warning "Short and long help options produce different output" +} + +# Test -v vs --version +$versionShort = & win-witr -v 2>&1 | Out-String +$versionLong = & win-witr --version 2>&1 | Out-String + +if ($versionShort -ne $versionLong) { + Write-Warning "Short and long version options produce different output" +} + +Write-Host "Short option aliases test completed" -ForegroundColor Green +exit 0 diff --git a/tests/edge_cases/special_pids.bat b/tests/edge_cases/special_pids.bat new file mode 100644 index 0000000..d65664a --- /dev/null +++ b/tests/edge_cases/special_pids.bat @@ -0,0 +1,10 @@ +REM Test with special PID values + +REM PID 0 - System Idle Process +win-witr --pid 0 + +REM PID 4 - System process +win-witr --pid 4 + +REM PID 1 (usually doesn't exist on Windows) +win-witr --pid 1 diff --git a/tests/edge_cases/special_process_names.bat b/tests/edge_cases/special_process_names.bat new file mode 100644 index 0000000..91ce8c0 --- /dev/null +++ b/tests/edge_cases/special_process_names.bat @@ -0,0 +1,13 @@ +REM Test edge cases with process names + +REM Process name with space (should handle gracefully) +win-witr "Windows Defender.exe" + +REM Process name without .exe extension (should still work based on repo memory) +win-witr explorer + +REM System process (PID 0 or 4) +win-witr System + +REM Idle process +win-witr Idle diff --git a/tests/edge_cases/validate_help_output.ps1 b/tests/edge_cases/validate_help_output.ps1 new file mode 100644 index 0000000..dd38566 --- /dev/null +++ b/tests/edge_cases/validate_help_output.ps1 @@ -0,0 +1,18 @@ +# Output validation test for --help +# Verifies that help output contains expected sections + +Write-Host "Testing help output format..." -ForegroundColor Yellow + +$output = & win-witr --help 2>&1 | Out-String + +# Check if output contains expected help sections +$hasUsage = $output -match "usage|Usage|USAGE" +$hasOptions = $output -match "options|Options|help|--help|-h" + +if (-not $hasUsage -and -not $hasOptions) { + Write-Error "Help output doesn't contain expected sections" + exit 1 +} + +Write-Host "Help output format is valid" -ForegroundColor Green +exit 0 diff --git a/tests/edge_cases/validate_version_output.ps1 b/tests/edge_cases/validate_version_output.ps1 new file mode 100644 index 0000000..eec9248 --- /dev/null +++ b/tests/edge_cases/validate_version_output.ps1 @@ -0,0 +1,17 @@ +# Output validation test for --version +# Verifies that version output contains expected information + +Write-Host "Testing version output format..." -ForegroundColor Yellow + +$output = & win-witr --version 2>&1 | Out-String + +# Check if output contains version-related keywords +$hasVersion = $output -match "version|v\d+\.\d+|win-witr" + +if (-not $hasVersion) { + Write-Error "Version output doesn't contain expected information" + exit 1 +} + +Write-Host "Version output format is valid" -ForegroundColor Green +exit 0 diff --git a/tests/error_handling/invalid_options.bat b/tests/error_handling/invalid_options.bat new file mode 100644 index 0000000..fc1a2d1 --- /dev/null +++ b/tests/error_handling/invalid_options.bat @@ -0,0 +1,10 @@ +REM Test with unknown/invalid command-line options + +REM Unknown long option +win-witr --unknown-option + +REM Unknown short option +win-witr -x + +REM Invalid combination +win-witr --pid --port diff --git a/tests/error_handling/invalid_pid.bat b/tests/error_handling/invalid_pid.bat new file mode 100644 index 0000000..8746ec3 --- /dev/null +++ b/tests/error_handling/invalid_pid.bat @@ -0,0 +1,14 @@ +REM Test error handling with invalid PID arguments +REM These should handle gracefully and not crash + +REM Invalid PID (negative number) +win-witr --pid -1 + +REM Invalid PID (not a number) +win-witr --pid notanumber + +REM Invalid PID (too large) +win-witr --pid 999999999 + +REM Missing PID argument +win-witr --pid diff --git a/tests/error_handling/invalid_port.bat b/tests/error_handling/invalid_port.bat new file mode 100644 index 0000000..14ab457 --- /dev/null +++ b/tests/error_handling/invalid_port.bat @@ -0,0 +1,13 @@ +REM Test error handling with invalid port arguments + +REM Invalid port (negative number) +win-witr --port -1 + +REM Invalid port (not a number) +win-witr --port notanumber + +REM Invalid port (too large, max is 65535) +win-witr --port 999999 + +REM Missing port argument +win-witr --port diff --git a/tests/error_handling/nonexistent_process.bat b/tests/error_handling/nonexistent_process.bat new file mode 100644 index 0000000..514b2f9 --- /dev/null +++ b/tests/error_handling/nonexistent_process.bat @@ -0,0 +1,6 @@ +REM Test with non-existent process names +REM These should not crash the program + +win-witr ThisProcessDoesNotExist123456.exe +win-witr NonExistentProcess.exe +win-witr FakeProcess999.exe diff --git a/tests/performance/perf_port_lookup.ps1 b/tests/performance/perf_port_lookup.ps1 new file mode 100644 index 0000000..30cc8ad --- /dev/null +++ b/tests/performance/perf_port_lookup.ps1 @@ -0,0 +1,22 @@ +# Performance test for port lookup +# Measures time taken to lookup a process by port number + +Write-Host "Testing port lookup performance..." -ForegroundColor Yellow + +# Warm-up run - Port 135 is a common Windows service port +& win-witr --port 135 | Out-Null + +# Measure performance +$result = Measure-Command { + & win-witr --port 135 | Out-Null +} + +Write-Host "Performance: Port lookup took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan + +# Verify it worked (exit code should be 0 regardless of whether port was found) +if ($LASTEXITCODE -ne 0) { + Write-Error "Port lookup command failed" + exit 1 +} + +exit 0 diff --git a/tests/performance/perf_process_lookup.ps1 b/tests/performance/perf_process_lookup.ps1 new file mode 100644 index 0000000..3bc8ac8 --- /dev/null +++ b/tests/performance/perf_process_lookup.ps1 @@ -0,0 +1,22 @@ +# Performance test for process name lookup +# Measures time taken to lookup a process by name + +Write-Host "Testing process lookup performance..." -ForegroundColor Yellow + +# Warm-up run - explorer.exe is always running on Windows +& win-witr explorer.exe | Out-Null + +# Measure performance +$result = Measure-Command { + & win-witr explorer.exe | Out-Null +} + +Write-Host "Performance: Process lookup took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan + +# Verify it worked +if ($LASTEXITCODE -ne 0) { + Write-Error "Process lookup command failed" + exit 1 +} + +exit 0 diff --git a/tests/performance/stress_mixed_operations.ps1 b/tests/performance/stress_mixed_operations.ps1 new file mode 100644 index 0000000..e5aaec5 --- /dev/null +++ b/tests/performance/stress_mixed_operations.ps1 @@ -0,0 +1,32 @@ +# Stress test: Mixed operation types +# Tests switching between different lookup modes rapidly + +Write-Host "Running mixed operation stress test..." -ForegroundColor Yellow + +$iterations = 30 + +for ($i = 0; $i -lt $iterations; $i++) { + # Alternate between different lookup modes + switch ($i % 4) { + 0 { + & win-witr --pid 4 | Out-Null + } + 1 { + & win-witr --port 135 | Out-Null + } + 2 { + & win-witr explorer.exe | Out-Null + } + 3 { + & win-witr --help | Out-Null + } + } + + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed on iteration $i" + exit 1 + } +} + +Write-Host "Successfully completed $iterations mixed operations" -ForegroundColor Green +exit 0 diff --git a/tests/performance/stress_rapid_lookups.ps1 b/tests/performance/stress_rapid_lookups.ps1 new file mode 100644 index 0000000..a4d5d1d --- /dev/null +++ b/tests/performance/stress_rapid_lookups.ps1 @@ -0,0 +1,20 @@ +# Stress test: Rapid sequential process lookups +# Tests if the tool can handle many rapid calls without crashing + +Write-Host "Running rapid sequential lookup stress test..." -ForegroundColor Yellow + +$iterations = 50 +$processes = @("explorer.exe", "svchost.exe", "csrss.exe") + +for ($i = 0; $i -lt $iterations; $i++) { + $proc = $processes[$i % $processes.Length] + & win-witr $proc | Out-Null + + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed on iteration $i with process $proc" + exit 1 + } +} + +Write-Host "Successfully completed $iterations rapid lookups" -ForegroundColor Green +exit 0 diff --git a/tests/pid/pid_comprehensive.ps1 b/tests/pid/pid_comprehensive.ps1 new file mode 100644 index 0000000..b775109 --- /dev/null +++ b/tests/pid/pid_comprehensive.ps1 @@ -0,0 +1,32 @@ +# Comprehensive PID lookup test +# Tests PID lookups with various system processes + +Write-Host "Running comprehensive PID lookup test..." -ForegroundColor Yellow + +# Get some actual PIDs from running processes +$systemPIDs = @(4) # System process always exists + +# Try to get explorer.exe PID (usually running) +$explorerProc = Get-Process -Name "explorer" -ErrorAction SilentlyContinue | Select-Object -First 1 +if ($explorerProc) { + $systemPIDs += $explorerProc.Id +} + +# Try to get a svchost.exe PID (always running) +$svchostProc = Get-Process -Name "svchost" -ErrorAction SilentlyContinue | Select-Object -First 1 +if ($svchostProc) { + $systemPIDs += $svchostProc.Id +} + +foreach ($pid in $systemPIDs) { + Write-Host " Testing PID $pid..." -ForegroundColor Cyan + & win-witr --pid $pid | Out-Null + + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to lookup PID $pid" + exit 1 + } +} + +Write-Host "All PID lookups successful" -ForegroundColor Green +exit 0 diff --git a/tests/port/port_basic.bat b/tests/port/port_basic.bat new file mode 100644 index 0000000..8dcb279 --- /dev/null +++ b/tests/port/port_basic.bat @@ -0,0 +1,8 @@ +REM Test basic --port functionality with common Windows ports +REM Windows should have some services listening on these ports + +REM Port 135 - RPC Endpoint Mapper (Windows service) +win-witr --port 135 + +REM Port 445 - SMB (Windows file sharing) +win-witr --port 445 diff --git a/tests/port/port_nonexistent.bat b/tests/port/port_nonexistent.bat new file mode 100644 index 0000000..0b9529b --- /dev/null +++ b/tests/port/port_nonexistent.bat @@ -0,0 +1,3 @@ +REM Test --port with a port that likely doesn't exist +REM Port 12345 is unlikely to be in use +win-witr --port 12345 diff --git a/tests/process/process_comprehensive.ps1 b/tests/process/process_comprehensive.ps1 new file mode 100644 index 0000000..d4fd30b --- /dev/null +++ b/tests/process/process_comprehensive.ps1 @@ -0,0 +1,27 @@ +# Comprehensive process name test +# Tests process name lookups with various Windows system processes + +Write-Host "Running comprehensive process name lookup test..." -ForegroundColor Yellow + +# Common Windows system processes that should exist +$processes = @( + "explorer.exe", + "svchost.exe", + "csrss.exe", + "winlogon.exe", + "lsass.exe", + "System" +) + +foreach ($proc in $processes) { + Write-Host " Testing process $proc..." -ForegroundColor Cyan + & win-witr $proc | Out-Null + + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to lookup process $proc" + exit 1 + } +} + +Write-Host "All process lookups successful" -ForegroundColor Green +exit 0 From eaca98118f780a54b795c0f93b0167f00c087b6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:22:32 +0000 Subject: [PATCH 3/9] Remove redundant tests and fix help output validation Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/edge_cases/sequential_lookups.bat | 8 -------- tests/edge_cases/short_option_aliases.ps1 | 23 ----------------------- tests/edge_cases/validate_help_output.ps1 | 11 ++++++----- 3 files changed, 6 insertions(+), 36 deletions(-) delete mode 100644 tests/edge_cases/sequential_lookups.bat delete mode 100644 tests/edge_cases/short_option_aliases.ps1 diff --git a/tests/edge_cases/sequential_lookups.bat b/tests/edge_cases/sequential_lookups.bat deleted file mode 100644 index 32cfe23..0000000 --- a/tests/edge_cases/sequential_lookups.bat +++ /dev/null @@ -1,8 +0,0 @@ -REM Test multiple processes in sequence -REM Verifies the tool can handle sequential lookups - -win-witr explorer.exe -win-witr svchost.exe -win-witr csrss.exe -win-witr lsass.exe -win-witr winlogon.exe diff --git a/tests/edge_cases/short_option_aliases.ps1 b/tests/edge_cases/short_option_aliases.ps1 deleted file mode 100644 index ac320f7..0000000 --- a/tests/edge_cases/short_option_aliases.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -# Test short option aliases -# Verify that short options work the same as long options - -Write-Host "Testing short option aliases..." -ForegroundColor Yellow - -# Test -h vs --help -$helpShort = & win-witr -h 2>&1 | Out-String -$helpLong = & win-witr --help 2>&1 | Out-String - -if ($helpShort -ne $helpLong) { - Write-Warning "Short and long help options produce different output" -} - -# Test -v vs --version -$versionShort = & win-witr -v 2>&1 | Out-String -$versionLong = & win-witr --version 2>&1 | Out-String - -if ($versionShort -ne $versionLong) { - Write-Warning "Short and long version options produce different output" -} - -Write-Host "Short option aliases test completed" -ForegroundColor Green -exit 0 diff --git a/tests/edge_cases/validate_help_output.ps1 b/tests/edge_cases/validate_help_output.ps1 index dd38566..7ffbc68 100644 --- a/tests/edge_cases/validate_help_output.ps1 +++ b/tests/edge_cases/validate_help_output.ps1 @@ -5,12 +5,13 @@ Write-Host "Testing help output format..." -ForegroundColor Yellow $output = & win-witr --help 2>&1 | Out-String -# Check if output contains expected help sections -$hasUsage = $output -match "usage|Usage|USAGE" -$hasOptions = $output -match "options|Options|help|--help|-h" +# Check if output contains the exact expected help sections from main.cpp +$hasUsage = $output -match "Usage:" +$hasOptions = $output -match "Options:" +$hasHelp = $output -match "--help" -if (-not $hasUsage -and -not $hasOptions) { - Write-Error "Help output doesn't contain expected sections" +if (-not $hasUsage -or -not $hasOptions -or -not $hasHelp) { + Write-Error "Help output doesn't contain expected sections (Usage:, Options:, --help)" exit 1 } From b0a35466b39d7562ae05344647e60cf4ef874490 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:24:16 +0000 Subject: [PATCH 4/9] Remove tests for unimplemented features and fix edge cases Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/edge_cases/special_pids.bat | 3 --- tests/edge_cases/special_process_names.bat | 10 ++------- tests/error_handling/invalid_options.bat | 10 --------- tests/error_handling/invalid_pid.bat | 14 ------------ tests/error_handling/invalid_port.bat | 13 ----------- tests/error_handling/nonexistent_process.bat | 6 ----- tests/performance/perf_port_lookup.ps1 | 22 ------------------- tests/performance/stress_mixed_operations.ps1 | 2 +- tests/port/port_basic.bat | 8 ------- tests/port/port_nonexistent.bat | 3 --- 10 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 tests/error_handling/invalid_options.bat delete mode 100644 tests/error_handling/invalid_pid.bat delete mode 100644 tests/error_handling/invalid_port.bat delete mode 100644 tests/error_handling/nonexistent_process.bat delete mode 100644 tests/performance/perf_port_lookup.ps1 delete mode 100644 tests/port/port_basic.bat delete mode 100644 tests/port/port_nonexistent.bat diff --git a/tests/edge_cases/special_pids.bat b/tests/edge_cases/special_pids.bat index d65664a..9887b9a 100644 --- a/tests/edge_cases/special_pids.bat +++ b/tests/edge_cases/special_pids.bat @@ -5,6 +5,3 @@ win-witr --pid 0 REM PID 4 - System process win-witr --pid 4 - -REM PID 1 (usually doesn't exist on Windows) -win-witr --pid 1 diff --git a/tests/edge_cases/special_process_names.bat b/tests/edge_cases/special_process_names.bat index 91ce8c0..40a6277 100644 --- a/tests/edge_cases/special_process_names.bat +++ b/tests/edge_cases/special_process_names.bat @@ -1,13 +1,7 @@ REM Test edge cases with process names -REM Process name with space (should handle gracefully) -win-witr "Windows Defender.exe" - -REM Process name without .exe extension (should still work based on repo memory) -win-witr explorer - REM System process (PID 0 or 4) win-witr System -REM Idle process -win-witr Idle +REM Registry process (exists on Windows) +win-witr Registry diff --git a/tests/error_handling/invalid_options.bat b/tests/error_handling/invalid_options.bat deleted file mode 100644 index fc1a2d1..0000000 --- a/tests/error_handling/invalid_options.bat +++ /dev/null @@ -1,10 +0,0 @@ -REM Test with unknown/invalid command-line options - -REM Unknown long option -win-witr --unknown-option - -REM Unknown short option -win-witr -x - -REM Invalid combination -win-witr --pid --port diff --git a/tests/error_handling/invalid_pid.bat b/tests/error_handling/invalid_pid.bat deleted file mode 100644 index 8746ec3..0000000 --- a/tests/error_handling/invalid_pid.bat +++ /dev/null @@ -1,14 +0,0 @@ -REM Test error handling with invalid PID arguments -REM These should handle gracefully and not crash - -REM Invalid PID (negative number) -win-witr --pid -1 - -REM Invalid PID (not a number) -win-witr --pid notanumber - -REM Invalid PID (too large) -win-witr --pid 999999999 - -REM Missing PID argument -win-witr --pid diff --git a/tests/error_handling/invalid_port.bat b/tests/error_handling/invalid_port.bat deleted file mode 100644 index 14ab457..0000000 --- a/tests/error_handling/invalid_port.bat +++ /dev/null @@ -1,13 +0,0 @@ -REM Test error handling with invalid port arguments - -REM Invalid port (negative number) -win-witr --port -1 - -REM Invalid port (not a number) -win-witr --port notanumber - -REM Invalid port (too large, max is 65535) -win-witr --port 999999 - -REM Missing port argument -win-witr --port diff --git a/tests/error_handling/nonexistent_process.bat b/tests/error_handling/nonexistent_process.bat deleted file mode 100644 index 514b2f9..0000000 --- a/tests/error_handling/nonexistent_process.bat +++ /dev/null @@ -1,6 +0,0 @@ -REM Test with non-existent process names -REM These should not crash the program - -win-witr ThisProcessDoesNotExist123456.exe -win-witr NonExistentProcess.exe -win-witr FakeProcess999.exe diff --git a/tests/performance/perf_port_lookup.ps1 b/tests/performance/perf_port_lookup.ps1 deleted file mode 100644 index 30cc8ad..0000000 --- a/tests/performance/perf_port_lookup.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -# Performance test for port lookup -# Measures time taken to lookup a process by port number - -Write-Host "Testing port lookup performance..." -ForegroundColor Yellow - -# Warm-up run - Port 135 is a common Windows service port -& win-witr --port 135 | Out-Null - -# Measure performance -$result = Measure-Command { - & win-witr --port 135 | Out-Null -} - -Write-Host "Performance: Port lookup took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan - -# Verify it worked (exit code should be 0 regardless of whether port was found) -if ($LASTEXITCODE -ne 0) { - Write-Error "Port lookup command failed" - exit 1 -} - -exit 0 diff --git a/tests/performance/stress_mixed_operations.ps1 b/tests/performance/stress_mixed_operations.ps1 index e5aaec5..baa116a 100644 --- a/tests/performance/stress_mixed_operations.ps1 +++ b/tests/performance/stress_mixed_operations.ps1 @@ -12,7 +12,7 @@ for ($i = 0; $i -lt $iterations; $i++) { & win-witr --pid 4 | Out-Null } 1 { - & win-witr --port 135 | Out-Null + & win-witr svchost.exe | Out-Null } 2 { & win-witr explorer.exe | Out-Null diff --git a/tests/port/port_basic.bat b/tests/port/port_basic.bat deleted file mode 100644 index 8dcb279..0000000 --- a/tests/port/port_basic.bat +++ /dev/null @@ -1,8 +0,0 @@ -REM Test basic --port functionality with common Windows ports -REM Windows should have some services listening on these ports - -REM Port 135 - RPC Endpoint Mapper (Windows service) -win-witr --port 135 - -REM Port 445 - SMB (Windows file sharing) -win-witr --port 445 diff --git a/tests/port/port_nonexistent.bat b/tests/port/port_nonexistent.bat deleted file mode 100644 index 0b9529b..0000000 --- a/tests/port/port_nonexistent.bat +++ /dev/null @@ -1,3 +0,0 @@ -REM Test --port with a port that likely doesn't exist -REM Port 12345 is unlikely to be in use -win-witr --port 12345 From fbcc44bba2f7848f70019f3bf5d92bacc4860b0e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:24:57 +0000 Subject: [PATCH 5/9] Simplify help output validation logic Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/edge_cases/validate_help_output.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/edge_cases/validate_help_output.ps1 b/tests/edge_cases/validate_help_output.ps1 index 7ffbc68..40a44e5 100644 --- a/tests/edge_cases/validate_help_output.ps1 +++ b/tests/edge_cases/validate_help_output.ps1 @@ -8,10 +8,9 @@ $output = & win-witr --help 2>&1 | Out-String # Check if output contains the exact expected help sections from main.cpp $hasUsage = $output -match "Usage:" $hasOptions = $output -match "Options:" -$hasHelp = $output -match "--help" -if (-not $hasUsage -or -not $hasOptions -or -not $hasHelp) { - Write-Error "Help output doesn't contain expected sections (Usage:, Options:, --help)" +if (-not $hasUsage -or -not $hasOptions) { + Write-Error "Help output doesn't contain expected sections (Usage: and Options:)" exit 1 } From 34a9a8d0c6eb7fd00475c51aa1d899c266176186 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:43:13 +0000 Subject: [PATCH 6/9] Remove all new test files and expand process.bat with more Windows apps Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/edge_cases/case_sensitivity.ps1 | 32 ----------------- tests/edge_cases/special_pids.bat | 7 ---- tests/edge_cases/special_process_names.bat | 7 ---- tests/edge_cases/validate_help_output.ps1 | 18 ---------- tests/edge_cases/validate_version_output.ps1 | 17 ---------- tests/performance/perf_process_lookup.ps1 | 22 ------------ tests/performance/stress_mixed_operations.ps1 | 32 ----------------- tests/performance/stress_rapid_lookups.ps1 | 20 ----------- tests/pid/pid_comprehensive.ps1 | 32 ----------------- tests/process/process.bat | 34 +++++++++++++++++++ tests/process/process_comprehensive.ps1 | 27 --------------- 11 files changed, 34 insertions(+), 214 deletions(-) delete mode 100644 tests/edge_cases/case_sensitivity.ps1 delete mode 100644 tests/edge_cases/special_pids.bat delete mode 100644 tests/edge_cases/special_process_names.bat delete mode 100644 tests/edge_cases/validate_help_output.ps1 delete mode 100644 tests/edge_cases/validate_version_output.ps1 delete mode 100644 tests/performance/perf_process_lookup.ps1 delete mode 100644 tests/performance/stress_mixed_operations.ps1 delete mode 100644 tests/performance/stress_rapid_lookups.ps1 delete mode 100644 tests/pid/pid_comprehensive.ps1 delete mode 100644 tests/process/process_comprehensive.ps1 diff --git a/tests/edge_cases/case_sensitivity.ps1 b/tests/edge_cases/case_sensitivity.ps1 deleted file mode 100644 index 5fe29de..0000000 --- a/tests/edge_cases/case_sensitivity.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -# Test case sensitivity in process names -# Windows process names are case-insensitive - -Write-Host "Testing case sensitivity in process names..." -ForegroundColor Yellow - -# Test with different cases -& win-witr explorer.exe | Out-Null -if ($LASTEXITCODE -ne 0) { - Write-Error "Failed: explorer.exe" - exit 1 -} - -& win-witr EXPLORER.EXE | Out-Null -if ($LASTEXITCODE -ne 0) { - Write-Error "Failed: EXPLORER.EXE" - exit 1 -} - -& win-witr Explorer.exe | Out-Null -if ($LASTEXITCODE -ne 0) { - Write-Error "Failed: Explorer.exe" - exit 1 -} - -& win-witr ExPlOrEr.ExE | Out-Null -if ($LASTEXITCODE -ne 0) { - Write-Error "Failed: ExPlOrEr.ExE" - exit 1 -} - -Write-Host "Case sensitivity test passed" -ForegroundColor Green -exit 0 diff --git a/tests/edge_cases/special_pids.bat b/tests/edge_cases/special_pids.bat deleted file mode 100644 index 9887b9a..0000000 --- a/tests/edge_cases/special_pids.bat +++ /dev/null @@ -1,7 +0,0 @@ -REM Test with special PID values - -REM PID 0 - System Idle Process -win-witr --pid 0 - -REM PID 4 - System process -win-witr --pid 4 diff --git a/tests/edge_cases/special_process_names.bat b/tests/edge_cases/special_process_names.bat deleted file mode 100644 index 40a6277..0000000 --- a/tests/edge_cases/special_process_names.bat +++ /dev/null @@ -1,7 +0,0 @@ -REM Test edge cases with process names - -REM System process (PID 0 or 4) -win-witr System - -REM Registry process (exists on Windows) -win-witr Registry diff --git a/tests/edge_cases/validate_help_output.ps1 b/tests/edge_cases/validate_help_output.ps1 deleted file mode 100644 index 40a44e5..0000000 --- a/tests/edge_cases/validate_help_output.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# Output validation test for --help -# Verifies that help output contains expected sections - -Write-Host "Testing help output format..." -ForegroundColor Yellow - -$output = & win-witr --help 2>&1 | Out-String - -# Check if output contains the exact expected help sections from main.cpp -$hasUsage = $output -match "Usage:" -$hasOptions = $output -match "Options:" - -if (-not $hasUsage -or -not $hasOptions) { - Write-Error "Help output doesn't contain expected sections (Usage: and Options:)" - exit 1 -} - -Write-Host "Help output format is valid" -ForegroundColor Green -exit 0 diff --git a/tests/edge_cases/validate_version_output.ps1 b/tests/edge_cases/validate_version_output.ps1 deleted file mode 100644 index eec9248..0000000 --- a/tests/edge_cases/validate_version_output.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# Output validation test for --version -# Verifies that version output contains expected information - -Write-Host "Testing version output format..." -ForegroundColor Yellow - -$output = & win-witr --version 2>&1 | Out-String - -# Check if output contains version-related keywords -$hasVersion = $output -match "version|v\d+\.\d+|win-witr" - -if (-not $hasVersion) { - Write-Error "Version output doesn't contain expected information" - exit 1 -} - -Write-Host "Version output format is valid" -ForegroundColor Green -exit 0 diff --git a/tests/performance/perf_process_lookup.ps1 b/tests/performance/perf_process_lookup.ps1 deleted file mode 100644 index 3bc8ac8..0000000 --- a/tests/performance/perf_process_lookup.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -# Performance test for process name lookup -# Measures time taken to lookup a process by name - -Write-Host "Testing process lookup performance..." -ForegroundColor Yellow - -# Warm-up run - explorer.exe is always running on Windows -& win-witr explorer.exe | Out-Null - -# Measure performance -$result = Measure-Command { - & win-witr explorer.exe | Out-Null -} - -Write-Host "Performance: Process lookup took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan - -# Verify it worked -if ($LASTEXITCODE -ne 0) { - Write-Error "Process lookup command failed" - exit 1 -} - -exit 0 diff --git a/tests/performance/stress_mixed_operations.ps1 b/tests/performance/stress_mixed_operations.ps1 deleted file mode 100644 index baa116a..0000000 --- a/tests/performance/stress_mixed_operations.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -# Stress test: Mixed operation types -# Tests switching between different lookup modes rapidly - -Write-Host "Running mixed operation stress test..." -ForegroundColor Yellow - -$iterations = 30 - -for ($i = 0; $i -lt $iterations; $i++) { - # Alternate between different lookup modes - switch ($i % 4) { - 0 { - & win-witr --pid 4 | Out-Null - } - 1 { - & win-witr svchost.exe | Out-Null - } - 2 { - & win-witr explorer.exe | Out-Null - } - 3 { - & win-witr --help | Out-Null - } - } - - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed on iteration $i" - exit 1 - } -} - -Write-Host "Successfully completed $iterations mixed operations" -ForegroundColor Green -exit 0 diff --git a/tests/performance/stress_rapid_lookups.ps1 b/tests/performance/stress_rapid_lookups.ps1 deleted file mode 100644 index a4d5d1d..0000000 --- a/tests/performance/stress_rapid_lookups.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -# Stress test: Rapid sequential process lookups -# Tests if the tool can handle many rapid calls without crashing - -Write-Host "Running rapid sequential lookup stress test..." -ForegroundColor Yellow - -$iterations = 50 -$processes = @("explorer.exe", "svchost.exe", "csrss.exe") - -for ($i = 0; $i -lt $iterations; $i++) { - $proc = $processes[$i % $processes.Length] - & win-witr $proc | Out-Null - - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed on iteration $i with process $proc" - exit 1 - } -} - -Write-Host "Successfully completed $iterations rapid lookups" -ForegroundColor Green -exit 0 diff --git a/tests/pid/pid_comprehensive.ps1 b/tests/pid/pid_comprehensive.ps1 deleted file mode 100644 index b775109..0000000 --- a/tests/pid/pid_comprehensive.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -# Comprehensive PID lookup test -# Tests PID lookups with various system processes - -Write-Host "Running comprehensive PID lookup test..." -ForegroundColor Yellow - -# Get some actual PIDs from running processes -$systemPIDs = @(4) # System process always exists - -# Try to get explorer.exe PID (usually running) -$explorerProc = Get-Process -Name "explorer" -ErrorAction SilentlyContinue | Select-Object -First 1 -if ($explorerProc) { - $systemPIDs += $explorerProc.Id -} - -# Try to get a svchost.exe PID (always running) -$svchostProc = Get-Process -Name "svchost" -ErrorAction SilentlyContinue | Select-Object -First 1 -if ($svchostProc) { - $systemPIDs += $svchostProc.Id -} - -foreach ($pid in $systemPIDs) { - Write-Host " Testing PID $pid..." -ForegroundColor Cyan - & win-witr --pid $pid | Out-Null - - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to lookup PID $pid" - exit 1 - } -} - -Write-Host "All PID lookups successful" -ForegroundColor Green -exit 0 diff --git a/tests/process/process.bat b/tests/process/process.bat index 3882df9..d3b8741 100644 --- a/tests/process/process.bat +++ b/tests/process/process.bat @@ -16,4 +16,38 @@ win-witr cmd.exe win-witr pwsh.exe win-witr Runner.Worker.exe win-witr hosted-compute-agent +win-witr conhost.exe +win-witr dwm.exe +win-witr RuntimeBroker.exe +win-witr SearchIndexer.exe +win-witr spoolsv.exe +win-witr taskhostw.exe +win-witr dllhost.exe +win-witr sihost.exe +win-witr ctfmon.exe +win-witr rdpclip.exe +win-witr SearchHost.exe +win-witr StartMenuExperienceHost.exe +win-witr ShellExperienceHost.exe +win-witr TextInputHost.exe +win-witr audiodg.exe +win-witr wininit.exe +win-witr wudfhost.exe +win-witr Memory Compression +win-witr Secure System +win-witr SearchProtocolHost.exe +win-witr SearchFilterHost.exe +win-witr msedge.exe +win-witr chrome.exe +win-witr firefox.exe +win-witr notepad.exe +win-witr mspaint.exe +win-witr calc.exe +win-witr taskmgr.exe +win-witr regedit.exe +win-witr mmc.exe +win-witr WmiPrvSE.exe +win-witr svchost.exe +win-witr lsm.exe +win-witr LogonUI.exe diff --git a/tests/process/process_comprehensive.ps1 b/tests/process/process_comprehensive.ps1 deleted file mode 100644 index d4fd30b..0000000 --- a/tests/process/process_comprehensive.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -# Comprehensive process name test -# Tests process name lookups with various Windows system processes - -Write-Host "Running comprehensive process name lookup test..." -ForegroundColor Yellow - -# Common Windows system processes that should exist -$processes = @( - "explorer.exe", - "svchost.exe", - "csrss.exe", - "winlogon.exe", - "lsass.exe", - "System" -) - -foreach ($proc in $processes) { - Write-Host " Testing process $proc..." -ForegroundColor Cyan - & win-witr $proc | Out-Null - - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to lookup process $proc" - exit 1 - } -} - -Write-Host "All process lookups successful" -ForegroundColor Green -exit 0 From 4e834450d6a1e3ad1e7b5cee65c0a37259585695 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 20:22:03 +0000 Subject: [PATCH 7/9] Start apps before testing them in process.bat Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/process/process.bat | 60 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tests/process/process.bat b/tests/process/process.bat index d3b8741..92fa092 100644 --- a/tests/process/process.bat +++ b/tests/process/process.bat @@ -1,3 +1,4 @@ +REM Test system processes that should always be running win-witr winlogon.exe win-witr lsass.exe win-witr win-witr.exe @@ -9,7 +10,6 @@ win-witr fontdrvhost.exe win-witr svchost.exe win-witr smss.exe win-witr services.exe -win-witr MsMpEng.exe win-witr powershell.exe win-witr Runner.Listener.exe win-witr cmd.exe @@ -23,31 +23,39 @@ win-witr SearchIndexer.exe win-witr spoolsv.exe win-witr taskhostw.exe win-witr dllhost.exe -win-witr sihost.exe -win-witr ctfmon.exe -win-witr rdpclip.exe -win-witr SearchHost.exe -win-witr StartMenuExperienceHost.exe -win-witr ShellExperienceHost.exe -win-witr TextInputHost.exe -win-witr audiodg.exe -win-witr wininit.exe -win-witr wudfhost.exe -win-witr Memory Compression -win-witr Secure System -win-witr SearchProtocolHost.exe -win-witr SearchFilterHost.exe -win-witr msedge.exe -win-witr chrome.exe -win-witr firefox.exe + +REM Start notepad and test it, then close +start /B notepad.exe +timeout /t 1 /nobreak >nul win-witr notepad.exe -win-witr mspaint.exe +taskkill /F /IM notepad.exe >nul 2>&1 + +REM Start calc and test it, then close +start /B calc.exe +timeout /t 1 /nobreak >nul win-witr calc.exe -win-witr taskmgr.exe -win-witr regedit.exe -win-witr mmc.exe -win-witr WmiPrvSE.exe -win-witr svchost.exe -win-witr lsm.exe -win-witr LogonUI.exe +taskkill /F /IM calc.exe >nul 2>&1 + +REM Start mspaint and test it, then close +start /B mspaint.exe +timeout /t 1 /nobreak >nul +win-witr mspaint.exe +taskkill /F /IM mspaint.exe >nul 2>&1 + +REM Start another cmd instance and test it, then close +start /B cmd.exe +timeout /t 1 /nobreak >nul +win-witr cmd.exe +taskkill /F /IM cmd.exe /FI "PID ne %CMDPID%" >nul 2>&1 + +REM Start PowerShell and test it +start /B powershell.exe -NoProfile -Command "Start-Sleep -Seconds 5" +timeout /t 1 /nobreak >nul +win-witr powershell.exe +REM PowerShell will exit on its own + +REM Start another instance of win-witr to test self-lookup +start /B win-witr.exe --help +timeout /t 1 /nobreak >nul +win-witr win-witr.exe From 67662614c0e13821025097d9b6e1c79d61a928dd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 20:22:53 +0000 Subject: [PATCH 8/9] Fix cleanup issues: add taskkill for all started apps Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- tests/process/process.bat | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/process/process.bat b/tests/process/process.bat index 92fa092..6fd1b2e 100644 --- a/tests/process/process.bat +++ b/tests/process/process.bat @@ -42,20 +42,16 @@ timeout /t 1 /nobreak >nul win-witr mspaint.exe taskkill /F /IM mspaint.exe >nul 2>&1 -REM Start another cmd instance and test it, then close -start /B cmd.exe -timeout /t 1 /nobreak >nul -win-witr cmd.exe -taskkill /F /IM cmd.exe /FI "PID ne %CMDPID%" >nul 2>&1 - -REM Start PowerShell and test it +REM Start PowerShell and test it, then close start /B powershell.exe -NoProfile -Command "Start-Sleep -Seconds 5" timeout /t 1 /nobreak >nul win-witr powershell.exe -REM PowerShell will exit on its own +taskkill /F /IM powershell.exe >nul 2>&1 -REM Start another instance of win-witr to test self-lookup +REM Start another instance of win-witr to test self-lookup, then close start /B win-witr.exe --help timeout /t 1 /nobreak >nul win-witr win-witr.exe +timeout /t 1 /nobreak >nul +taskkill /F /IM win-witr.exe >nul 2>&1 From b2e71908e5537de67b56a4d2191663ce5e34afd8 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:26:47 -0500 Subject: [PATCH 9/9] Apply suggestion from @supervoidcoder --- tests/process/process.bat | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/process/process.bat b/tests/process/process.bat index 6fd1b2e..081af6b 100644 --- a/tests/process/process.bat +++ b/tests/process/process.bat @@ -48,10 +48,4 @@ timeout /t 1 /nobreak >nul win-witr powershell.exe taskkill /F /IM powershell.exe >nul 2>&1 -REM Start another instance of win-witr to test self-lookup, then close -start /B win-witr.exe --help -timeout /t 1 /nobreak >nul -win-witr win-witr.exe -timeout /t 1 /nobreak >nul -taskkill /F /IM win-witr.exe >nul 2>&1