mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 15:54:22 +02:00
Enable Appverifier tests (#191)
1. Enable Appverifier tests and fix of #839 and #841 2. Enabled Postmortem Debugging
This commit is contained in:
parent
3c90af89a2
commit
3a092cbb5d
@ -20,6 +20,8 @@ $Script:UnitTestResultsFile = Join-Path $TestDataPath $UnitTestResultsFileName
|
|||||||
$Script:TestSetupLogFile = Join-Path $TestDataPath $TestSetupLogFileName
|
$Script:TestSetupLogFile = Join-Path $TestDataPath $TestSetupLogFileName
|
||||||
$Script:E2ETestDirectory = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests"
|
$Script:E2ETestDirectory = Join-Path $repositoryRoot.FullName -ChildPath "regress\pesterTests"
|
||||||
$Script:WindowsInBox = $false
|
$Script:WindowsInBox = $false
|
||||||
|
$Script:EnableAppVerifier = $true
|
||||||
|
$Script:PostmortemDebugging = $false
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.Synopsis
|
.Synopsis
|
||||||
@ -33,7 +35,9 @@ function Set-OpenSSHTestEnvironment
|
|||||||
(
|
(
|
||||||
[string] $OpenSSHBinPath,
|
[string] $OpenSSHBinPath,
|
||||||
[string] $TestDataPath = "$env:SystemDrive\OpenSSHTests",
|
[string] $TestDataPath = "$env:SystemDrive\OpenSSHTests",
|
||||||
[Boolean] $DebugMode = $false
|
[Boolean] $DebugMode = $false,
|
||||||
|
[Switch] $NoAppVerifier,
|
||||||
|
[Switch] $PostmortemDebugging
|
||||||
)
|
)
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("Verbose"))
|
if($PSBoundParameters.ContainsKey("Verbose"))
|
||||||
@ -51,7 +55,11 @@ function Set-OpenSSHTestEnvironment
|
|||||||
$Script:UnitTestResultsFile = Join-Path $TestDataPath "UnitTestResults.txt"
|
$Script:UnitTestResultsFile = Join-Path $TestDataPath "UnitTestResults.txt"
|
||||||
$Script:TestSetupLogFile = Join-Path $TestDataPath "TestSetupLog.txt"
|
$Script:TestSetupLogFile = Join-Path $TestDataPath "TestSetupLog.txt"
|
||||||
$Script:UnitTestDirectory = Get-UnitTestDirectory
|
$Script:UnitTestDirectory = Get-UnitTestDirectory
|
||||||
|
$Script:EnableAppVerifier = -not ($NoAppVerifier.IsPresent)
|
||||||
|
if($Script:EnableAppVerifier)
|
||||||
|
{
|
||||||
|
$Script:PostmortemDebugging = $PostmortemDebugging.IsPresent
|
||||||
|
}
|
||||||
|
|
||||||
$Global:OpenSSHTestInfo = @{
|
$Global:OpenSSHTestInfo = @{
|
||||||
"Target"= "localhost"; # test listener name
|
"Target"= "localhost"; # test listener name
|
||||||
@ -67,6 +75,8 @@ function Set-OpenSSHTestEnvironment
|
|||||||
"E2ETestDirectory" = $Script:E2ETestDirectory # the directory of E2E tests
|
"E2ETestDirectory" = $Script:E2ETestDirectory # the directory of E2E tests
|
||||||
"UnitTestDirectory" = $Script:UnitTestDirectory # the directory of unit tests
|
"UnitTestDirectory" = $Script:UnitTestDirectory # the directory of unit tests
|
||||||
"DebugMode" = $DebugMode # run openssh E2E in debug mode
|
"DebugMode" = $DebugMode # run openssh E2E in debug mode
|
||||||
|
"EnableAppVerifier" = $Script:EnableAppVerifier
|
||||||
|
"PostmortemDebugging" = $Script:PostmortemDebugging
|
||||||
}
|
}
|
||||||
|
|
||||||
#if user does not set path, pick it up
|
#if user does not set path, pick it up
|
||||||
@ -237,6 +247,24 @@ WARNING: Following changes will be made to OpenSSH configuration
|
|||||||
cmd /c "ssh-add -D 2>&1 >> $Script:TestSetupLogFile"
|
cmd /c "ssh-add -D 2>&1 >> $Script:TestSetupLogFile"
|
||||||
Repair-UserKeyPermission -FilePath $testPriKeypath -confirm:$false
|
Repair-UserKeyPermission -FilePath $testPriKeypath -confirm:$false
|
||||||
cmd /c "ssh-add $testPriKeypath 2>&1 >> $Script:TestSetupLogFile"
|
cmd /c "ssh-add $testPriKeypath 2>&1 >> $Script:TestSetupLogFile"
|
||||||
|
|
||||||
|
#Enable AppVerifier
|
||||||
|
if($EnableAppVerifier)
|
||||||
|
{
|
||||||
|
# clear all applications in application verifier first
|
||||||
|
& $env:windir\System32\appverif.exe -disable * -for * | out-null
|
||||||
|
Get-ChildItem "$($script:OpenSSHBinPath)\*.exe" | % {
|
||||||
|
& $env:windir\System32\appverif.exe -verify $_.Name | out-null
|
||||||
|
}
|
||||||
|
|
||||||
|
if($Script:PostmortemDebugging -and (Test-path $Script:WindbgPath))
|
||||||
|
{
|
||||||
|
# enable Postmortem debugger
|
||||||
|
New-ItemProperty "HKLM:Software\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -Type String -Value "`"$Script:WindbgPath`" -p %ld -e %ld -g" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
New-ItemProperty "HKLM:Software\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Auto -Type String -Value "1" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Backup-OpenSSHTestInfo
|
Backup-OpenSSHTestInfo
|
||||||
}
|
}
|
||||||
#TODO - this is Windows specific. Need to be in PAL
|
#TODO - this is Windows specific. Need to be in PAL
|
||||||
@ -294,6 +322,31 @@ function Install-OpenSSHTestDependencies
|
|||||||
Write-Log -Message "Installing Pester..."
|
Write-Log -Message "Installing Pester..."
|
||||||
choco install Pester -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
choco install Pester -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($Script:PostmortemDebugging -or (($OpenSSHTestInfo -ne $null) -and ($OpenSSHTestInfo["PostmortemDebugging"])))
|
||||||
|
{
|
||||||
|
$folderName = "x86"
|
||||||
|
$pathroot = $env:ProgramFiles
|
||||||
|
if($env:PROCESSOR_ARCHITECTURE -ieq "AMD64")
|
||||||
|
{
|
||||||
|
$folderName = "x64"
|
||||||
|
$pathroot = ${env:ProgramFiles(x86)}
|
||||||
|
}
|
||||||
|
$Script:WindbgPath = "$pathroot\Windows Kits\8.1\Debuggers\$folderName\windbg.exe"
|
||||||
|
if(-not (Test-Path $Script:WindbgPath))
|
||||||
|
{
|
||||||
|
$Script:WindbgPath = "$pathroot\Windows Kits\10\Debuggers\$folderName\windbg.exe"
|
||||||
|
if(-not (Test-Path $Script:WindbgPath))
|
||||||
|
{
|
||||||
|
choco install windbg -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($Script:EnableAppVerifier -or (($OpenSSHTestInfo -ne $null) -and ($OpenSSHTestInfo["EnableAppVerifier"]))) -and (-not (Test-path $env:windir\System32\appverif.exe)))
|
||||||
|
{
|
||||||
|
choco install appverifier -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Install-OpenSSHUtilsModule
|
function Install-OpenSSHUtilsModule
|
||||||
@ -397,6 +450,18 @@ function Clear-OpenSSHTestEnvironment
|
|||||||
ssh-add-hostkey.ps1 -Delete_key $_.FullName
|
ssh-add-hostkey.ps1 -Delete_key $_.FullName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($Global:OpenSSHTestInfo["EnableAppVerifier"] -and (Test-path $env:windir\System32\appverif.exe))
|
||||||
|
{
|
||||||
|
# clear all applications in application verifier
|
||||||
|
& $env:windir\System32\appverif.exe -disable * -for * | out-null
|
||||||
|
}
|
||||||
|
|
||||||
|
if($Global:OpenSSHTestInfo["PostmortemDebugging"])
|
||||||
|
{
|
||||||
|
Remove-ItemProperty "HKLM:Software\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -ErrorAction SilentlyContinue -Force | Out-Null
|
||||||
|
Remove-ItemProperty "HKLM:Software\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Auto -ErrorAction SilentlyContinue -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
Remove-Item $sshBinPath\sshtest*hostkey* -Force -ErrorAction SilentlyContinue
|
Remove-Item $sshBinPath\sshtest*hostkey* -Force -ErrorAction SilentlyContinue
|
||||||
#Restore sshd_config
|
#Restore sshd_config
|
||||||
$backupConfigPath = Join-Path $sshBinPath sshd_config.ori
|
$backupConfigPath = Join-Path $sshBinPath sshd_config.ori
|
||||||
|
@ -109,6 +109,7 @@ ReadThread(_In_ LPVOID lpParameter)
|
|||||||
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
||||||
read_status.error = GetLastError();
|
read_status.error = GetLastError();
|
||||||
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
@ -128,6 +129,7 @@ ReadThread(_In_ LPVOID lpParameter)
|
|||||||
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
pio->read_details.buf_size, &read_status.transferred, NULL)) {
|
||||||
read_status.error = GetLastError();
|
read_status.error = GetLastError();
|
||||||
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
debug("ReadThread - ReadFile failed %d, io:%p", GetLastError(), pio);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
|
if (0 == QueueUserAPC(ReadAPCProc, main_thread, (ULONG_PTR)pio)) {
|
||||||
|
1
sftp.c
1
sftp.c
@ -2518,6 +2518,7 @@ main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
|
|
||||||
userhost = xstrdup(argv[optind]);
|
userhost = xstrdup(argv[optind]);
|
||||||
|
if(argc > optind + 1)
|
||||||
file2 = argv[optind+1];
|
file2 = argv[optind+1];
|
||||||
|
|
||||||
if ((host = strrchr(userhost, '@')) == NULL)
|
if ((host = strrchr(userhost, '@')) == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user