Skip to content

Commit d517ba4

Browse files
updates on checking with test
1 parent 85e887d commit d517ba4

1 file changed

Lines changed: 162 additions & 125 deletions

File tree

.github/workflows/windows-cert-store-test.yml

Lines changed: 162 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ jobs:
5757
working-directory: ${{ github.workspace }}\wolfssl
5858
run: msbuild /m /p:PlatformToolset=v142 /p:Platform=${{env.BUILD_PLATFORM}} /p:Configuration=${{env.WOLFSSL_BUILD_CONFIGURATION}} /t:wolfssl ${{env.WOLFSSL_SOLUTION_FILE_PATH}}
5959

60+
- name: Upload wolfSSL build artifacts
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: wolfssl-windows-build
64+
if-no-files-found: warn
65+
retention-days: 1
66+
path: |
67+
wolfssl/IDE/WIN/${{env.WOLFSSL_BUILD_CONFIGURATION}}/${{env.BUILD_PLATFORM}}/**
68+
wolfssl/IDE/WIN/${{env.WOLFSSL_BUILD_CONFIGURATION}}/**
69+
wolfssl/${{env.WOLFSSL_BUILD_CONFIGURATION}}/${{env.BUILD_PLATFORM}}/**
70+
wolfssl/${{env.WOLFSSL_BUILD_CONFIGURATION}}/**
71+
6072
- name: Restore NuGet packages
6173
working-directory: ${{ github.workspace }}\wolfssh\ide\winvs
6274
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
@@ -172,6 +184,12 @@ jobs:
172184
name: wolfssh-windows-build
173185
path: .
174186

187+
- name: Download wolfSSL build artifacts
188+
uses: actions/download-artifact@v4
189+
with:
190+
name: wolfssl-windows-build
191+
path: .
192+
175193
- name: Set up test environment - ${{ matrix.test_name }}
176194
working-directory: ${{ github.workspace }}\wolfssh
177195
shell: pwsh
@@ -307,7 +325,7 @@ jobs:
307325
Write-Host "WARNING: wolfssh.exe not found (SSH client test will be skipped)"
308326
}
309327
310-
- name: Copy wolfSSL DLL to executable directory
328+
- name: Copy wolfSSL DLL to executable directory (if dynamic build)
311329
working-directory: ${{ github.workspace }}
312330
shell: pwsh
313331
run: |
@@ -320,15 +338,18 @@ jobs:
320338
$sshdDir = Split-Path -Parent $sshdPath
321339
Write-Host "wolfsshd.exe directory: $sshdDir"
322340
323-
# Check common wolfSSL build output paths
341+
# If wolfssl.lib is already next to wolfsshd.exe, it's a static build - no DLL needed
342+
$libInSshdDir = Join-Path $sshdDir "wolfssl.lib"
343+
if (Test-Path $libInSshdDir) {
344+
Write-Host "wolfssl.lib present beside wolfsshd.exe - static build; wolfssl.dll not required"
345+
exit 0
346+
}
347+
348+
# Dynamic build: find and copy wolfssl.dll
324349
$wolfsslRoot = "${{ github.workspace }}\wolfssl"
325350
$buildConfig = "${{env.WOLFSSL_BUILD_CONFIGURATION}}"
326351
$buildPlatform = "${{env.BUILD_PLATFORM}}"
327352
328-
Write-Host "Searching for wolfSSL DLL in: $wolfsslRoot"
329-
Write-Host "Build configuration: $buildConfig, Platform: $buildPlatform"
330-
331-
# Try common output paths first
332353
$commonPaths = @(
333354
"$wolfsslRoot\IDE\WIN\$buildConfig\$buildPlatform\wolfssl.dll",
334355
"$wolfsslRoot\IDE\WIN\$buildConfig\wolfssl.dll",
@@ -338,75 +359,18 @@ jobs:
338359
339360
$wolfsslDll = $null
340361
foreach ($path in $commonPaths) {
341-
if (Test-Path $path) {
342-
$wolfsslDll = Get-Item $path
343-
Write-Host "Found wolfssl.dll at common path: $($wolfsslDll.FullName)"
344-
break
345-
}
362+
if (Test-Path $path) { $wolfsslDll = Get-Item $path; break }
346363
}
347-
348-
# If not found in common paths, search recursively
349364
if (-not $wolfsslDll) {
350-
Write-Host "Not found in common paths, searching recursively..."
351-
$wolfsslDll = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "wolfssl.dll" -ErrorAction SilentlyContinue |
352-
Where-Object {
353-
$_.FullName -like "*$buildConfig*" -and
354-
($_.FullName -like "*$buildPlatform*" -or $_.DirectoryName -notlike "*Debug*")
355-
} |
356-
Select-Object -First 1
365+
$wolfsslDll = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "wolfssl.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
357366
}
358367
359368
if ($wolfsslDll) {
360369
$targetDll = Join-Path $sshdDir "wolfssl.dll"
361-
Write-Host "Copying wolfssl.dll from: $($wolfsslDll.FullName)"
362-
Write-Host "Copying to: $targetDll"
363370
Copy-Item -Path $wolfsslDll.FullName -Destination $targetDll -Force
364-
if (Test-Path $targetDll) {
365-
Write-Host "Successfully copied wolfssl.dll"
366-
} else {
367-
Write-Host "ERROR: Copy failed - target file not found after copy"
368-
exit 1
369-
}
371+
Write-Host "Copied wolfssl.dll to $targetDll"
370372
} else {
371-
Write-Host "WARNING: wolfssl.dll not found"
372-
Write-Host "Listing all DLL files in wolfSSL directory:"
373-
Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "*.dll" -ErrorAction SilentlyContinue |
374-
Where-Object { $_.FullName -like "*$buildConfig*" } |
375-
Select-Object FullName | Format-Table
376-
}
377-
378-
# Also copy wolfssl.lib if found
379-
$wolfsslLib = $null
380-
foreach ($path in $commonPaths) {
381-
$libPath = $path -replace "\.dll$", ".lib"
382-
if (Test-Path $libPath) {
383-
$wolfsslLib = Get-Item $libPath
384-
Write-Host "Found wolfssl.lib at common path: $($wolfsslLib.FullName)"
385-
break
386-
}
387-
}
388-
389-
if (-not $wolfsslLib) {
390-
$wolfsslLib = Get-ChildItem -Path $wolfsslRoot -Recurse -Filter "wolfssl.lib" -ErrorAction SilentlyContinue |
391-
Where-Object {
392-
$_.FullName -like "*$buildConfig*" -and
393-
($_.FullName -like "*$buildPlatform*" -or $_.DirectoryName -notlike "*Debug*")
394-
} |
395-
Select-Object -First 1
396-
}
397-
398-
if ($wolfsslLib) {
399-
$targetLib = Join-Path $sshdDir "wolfssl.lib"
400-
Write-Host "Copying wolfssl.lib from: $($wolfsslLib.FullName)"
401-
Write-Host "Copying to: $targetLib"
402-
Copy-Item -Path $wolfsslLib.FullName -Destination $targetLib -Force
403-
if (Test-Path $targetLib) {
404-
Write-Host "Successfully copied wolfssl.lib"
405-
} else {
406-
Write-Host "WARNING: wolfssl.lib copy may have failed"
407-
}
408-
} else {
409-
Write-Host "INFO: wolfssl.lib not found (may be static build or not needed)"
373+
Write-Host "wolfssl.dll not found; if build is static (wolfssl.lib in output), this is OK"
410374
}
411375
412376
- name: Verify host key configuration
@@ -475,65 +439,44 @@ jobs:
475439
476440
Write-Host "Host key configuration verified: OK"
477441
478-
- name: Test wolfSSHd startup (diagnostic)
442+
- name: Verify dependencies and environment
479443
working-directory: ${{ github.workspace }}\wolfssh
480444
shell: pwsh
481445
run: |
482446
$sshdPath = (Get-Content env:SSHD_PATH)
483-
if (-not (Test-Path $sshdPath)) {
484-
Write-Host "ERROR: wolfsshd.exe not found at $sshdPath"
485-
exit 1
447+
$sshdDir = Split-Path -Parent $sshdPath
448+
449+
Write-Host "=== Verifying wolfsshd.exe environment ==="
450+
Write-Host "Executable: $sshdPath"
451+
Write-Host "Directory: $sshdDir"
452+
453+
# Check if DLL is present
454+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
455+
if (Test-Path $dllPath) {
456+
Write-Host "✓ wolfssl.dll found"
457+
$dllInfo = Get-Item $dllPath
458+
Write-Host " Size: $($dllInfo.Length) bytes"
459+
Write-Host " Modified: $($dllInfo.LastWriteTime)"
460+
} else {
461+
Write-Host "✗ wolfssl.dll NOT FOUND in $sshdDir"
462+
Write-Host "Files in directory:"
463+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length | Format-Table
486464
}
487465
466+
# Check config file
488467
$configPath = "sshd_config_test"
489-
if (-not (Test-Path $configPath)) {
490-
Write-Host "ERROR: Config file not found: $configPath"
491-
exit 1
468+
if (Test-Path $configPath) {
469+
Write-Host "✓ Config file found: $configPath"
470+
} else {
471+
Write-Host "✗ Config file NOT FOUND: $configPath"
492472
}
493473
494-
Write-Host "=== Testing wolfsshd.exe startup (direct run) ==="
495-
Write-Host "Executable: $sshdPath"
496-
Write-Host "Config: $configPath"
497-
498-
# Try to run it directly to see error messages
499-
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
500-
$processInfo.FileName = $sshdPath
501-
$processInfo.Arguments = "-f $configPath -p ${{env.TEST_PORT}}"
502-
$processInfo.UseShellExecute = $false
503-
$processInfo.RedirectStandardOutput = $true
504-
$processInfo.RedirectStandardError = $true
505-
$processInfo.CreateNoWindow = $true
506-
507-
$process = New-Object System.Diagnostics.Process
508-
$process.StartInfo = $processInfo
509-
510-
try {
511-
$process.Start() | Out-Null
512-
Start-Sleep -Seconds 2
513-
514-
if (-not $process.HasExited) {
515-
Write-Host "Process is running (good sign)"
516-
$process.Kill()
517-
$process.WaitForExit(5000)
518-
} else {
519-
Write-Host "Process exited immediately (exit code: $($process.ExitCode))"
520-
$stdout = $process.StandardOutput.ReadToEnd()
521-
$stderr = $process.StandardError.ReadToEnd()
522-
if ($stdout) {
523-
Write-Host "STDOUT: $stdout"
524-
}
525-
if ($stderr) {
526-
Write-Host "STDERR: $stderr"
527-
}
528-
}
529-
} catch {
530-
Write-Host "ERROR running process: $_"
531-
} finally {
532-
if (-not $process.HasExited) {
533-
$process.Kill()
534-
}
535-
$process.Dispose()
536-
}
474+
# Note: Direct execution will fail with "StartServiceCtrlDispatcher failed"
475+
# This is expected - the executable is built as a service and must run via SCM
476+
Write-Host ""
477+
Write-Host "Note: wolfsshd.exe is built as a Windows service."
478+
Write-Host "Direct execution will fail (this is expected)."
479+
Write-Host "It must be started via Service Control Manager (sc.exe)."
537480
538481
- name: Start wolfSSHd as Windows service
539482
working-directory: ${{ github.workspace }}\wolfssh
@@ -564,8 +507,47 @@ jobs:
564507
Start-Sleep -Seconds 2
565508
}
566509
510+
# Pre-service checks
511+
$sshdDir = Split-Path -Parent $sshdPathFull
512+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
513+
$libPath = Join-Path $sshdDir "wolfssl.lib"
514+
Write-Host "=== Pre-service checks ==="
515+
Write-Host "Executable: $sshdPathFull"
516+
Write-Host "Config: $configPathFull"
517+
Write-Host "Working directory (sshd dir): $sshdDir"
518+
519+
# wolfSSL: either DLL (dynamic) or static (.lib linked into exe)
520+
if (Test-Path $dllPath) {
521+
Write-Host "✓ wolfssl.dll found (dynamic build)"
522+
$dllInfo = Get-Item $dllPath
523+
Write-Host " Size: $($dllInfo.Length) bytes"
524+
} elseif (Test-Path $libPath) {
525+
Write-Host "✓ wolfssl.lib present, no wolfssl.dll - static build (no DLL required)"
526+
} else {
527+
Write-Host "WARNING: Neither wolfssl.dll nor wolfssl.lib in $sshdDir"
528+
Write-Host "Files present:"
529+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length | Format-Table
530+
# Continue anyway; service may still start if wolfssl is linked another way
531+
}
532+
533+
if (-not (Test-Path $configPathFull)) {
534+
Write-Host "ERROR: Config file not found: $configPathFull"
535+
exit 1
536+
} else {
537+
Write-Host "✓ Config file found"
538+
# Verify config file is readable
539+
try {
540+
$configContent = Get-Content $configPathFull -Raw
541+
Write-Host " Size: $($configContent.Length) bytes"
542+
} catch {
543+
Write-Host "ERROR: Cannot read config file: $_"
544+
exit 1
545+
}
546+
}
547+
567548
# Create the service with proper binpath
568-
# binpath format: "path\to\exe" -f "config" -p port
549+
# Note: sc.exe requires the binPath to have the executable path and arguments
550+
# The entire command line goes in binPath, with the exe path in quotes
569551
$binPath = "`"$sshdPathFull`" -f `"$configPathFull`" -p ${{env.TEST_PORT}}"
570552
Write-Host "Creating service with binpath: $binPath"
571553
@@ -577,6 +559,10 @@ jobs:
577559
}
578560
Write-Host "Service created: $createResult"
579561
562+
# Set service to auto-start on failure (for debugging)
563+
# This won't help if it exits cleanly, but might help with crashes
564+
sc.exe failure $serviceName reset= 86400 actions= restart/5000/restart/5000/restart/5000 | Out-Null
565+
580566
# Start the service
581567
Write-Host "Starting $serviceName service"
582568
$startResult = sc.exe start $serviceName
@@ -590,7 +576,7 @@ jobs:
590576
Write-Host "Service started: $startResult"
591577
592578
# Wait a bit for service to start
593-
Start-Sleep -Seconds 3
579+
Start-Sleep -Seconds 5
594580
595581
# Check service status
596582
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
@@ -601,21 +587,72 @@ jobs:
601587
602588
if ($service.Status -ne 'Running') {
603589
Write-Host "ERROR: Service is not running. Status: $($service.Status)"
604-
# Get more details
590+
591+
# Get detailed service information
605592
Write-Host "=== Service Query ==="
606593
sc.exe query $serviceName
607-
Write-Host "=== Event Log (last 20 entries) ==="
608-
Get-EventLog -LogName Application -Source "wolfsshd" -Newest 20 -ErrorAction SilentlyContinue | Format-List
609-
Get-EventLog -LogName System -Source "Service Control Manager" -Newest 10 -ErrorAction SilentlyContinue |
610-
Where-Object { $_.Message -like "*wolfsshd*" } | Format-List
594+
595+
# Get service configuration to see the actual command
596+
Write-Host "=== Service Configuration ==="
597+
sc.exe qc $serviceName
598+
599+
# Check service error code and details
600+
Write-Host "=== Service Error Code ==="
601+
$serviceInfo = Get-CimInstance -ClassName Win32_Service -Filter "Name='$serviceName'" -ErrorAction SilentlyContinue
602+
if ($serviceInfo) {
603+
Write-Host "ExitCode: $($serviceInfo.ExitCode)"
604+
Write-Host "State: $($serviceInfo.State)"
605+
Write-Host "Status: $($serviceInfo.Status)"
606+
Write-Host "PathName: $($serviceInfo.PathName)"
607+
Write-Host "StartMode: $($serviceInfo.StartMode)"
608+
}
609+
610+
# Try to get process exit code if it ran briefly
611+
Write-Host "=== Checking for recent process exit ==="
612+
$recentProcesses = Get-WinEvent -FilterHashtable @{LogName='System'; ID=7034,7035,7036} -MaxEvents 50 -ErrorAction SilentlyContinue |
613+
Where-Object { $_.Message -like "*wolfsshd*" } |
614+
Select-Object -First 5
615+
if ($recentProcesses) {
616+
Write-Host "Recent service events:"
617+
$recentProcesses | ForEach-Object { Write-Host " $($_.TimeCreated): $($_.Message)" }
618+
}
619+
620+
# Check event logs for errors
621+
Write-Host "=== System Event Log (Service Control Manager) ==="
622+
Get-EventLog -LogName System -Source "Service Control Manager" -Newest 20 -ErrorAction SilentlyContinue |
623+
Where-Object { $_.Message -like "*wolfsshd*" -or $_.Message -like "*$serviceName*" } |
624+
Select-Object TimeGenerated, EntryType, Message | Format-List
625+
626+
Write-Host "=== Application Event Log ==="
627+
Get-EventLog -LogName Application -Newest 30 -ErrorAction SilentlyContinue |
628+
Where-Object { $_.Source -like "*wolf*" -or $_.Message -like "*wolf*" } |
629+
Select-Object TimeGenerated, Source, EntryType, Message | Format-List
630+
631+
# Check wolfSSL: DLL (dynamic) or .lib (static)
632+
Write-Host "=== Checking wolfSSL (DLL or static) ==="
633+
$sshdDir = Split-Path -Parent $sshdPathFull
634+
$dllPath = Join-Path $sshdDir "wolfssl.dll"
635+
$libPath = Join-Path $sshdDir "wolfssl.lib"
636+
if (Test-Path $dllPath) {
637+
Write-Host "wolfssl.dll: YES (dynamic build)"
638+
} elseif (Test-Path $libPath) {
639+
Write-Host "wolfssl.dll: NO; wolfssl.lib: YES (static build - OK)"
640+
} else {
641+
Write-Host "wolfssl.dll: NO; wolfssl.lib: NO"
642+
Write-Host "Files in $sshdDir :"
643+
Get-ChildItem -Path $sshdDir | Select-Object Name, Length | Format-Table
644+
}
645+
646+
# Check if process is running
611647
Write-Host "=== Checking if process is running ==="
612648
$processes = Get-Process | Where-Object { $_.ProcessName -like "*wolfsshd*" }
613649
if ($processes) {
614650
Write-Host "Found processes:"
615-
$processes | Format-Table Id, ProcessName, StartTime
651+
$processes | Format-Table Id, ProcessName, StartTime, Path
616652
} else {
617653
Write-Host "No wolfsshd processes found"
618654
}
655+
619656
exit 1
620657
}
621658

0 commit comments

Comments
 (0)