Add AzDevOps CI implementations (#631)
* Fix yaml indentation * More format fixes * Temporarily remove compliance reference * Fix test job * Fix job name * Update image pool * Add build results copy * Fix build copy typo * Param fix * Fix build artifact download * Remove unneeded dir from install * Fix Pester version comaptible with tests * Fix unit tests * Fix unit test location * Fix unit test path * Disable Bash tests * Fix testpassed * Re-enable CygWin bash tests * Fix cygwin check error * Typo * Debug bash tests * Save config.h from build for bash tests * Fix config.h copy * Change test clean up * Allow some tests to run after others fail * Reinstate Invoke-AzDOBuild * Fix syntax errors * Restore opensshtestinfo * Fix typo * Upload bash test results * Debug bash tests 1 * Debug 2 * Remove debug code * Fix test path error * Set Pester version to 3.4.6 for AppVeyor runs
This commit is contained in:
parent
5124f3dcd4
commit
d9a9b3ce88
116
.azdo/ci.yml
116
.azdo/ci.yml
|
@ -10,12 +10,12 @@ pr:
|
|||
include:
|
||||
- latestw_all
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: ComplianceRepo
|
||||
type: github
|
||||
endpoint: ComplianceGHRepo
|
||||
name: PowerShell/compliance
|
||||
#resources:
|
||||
# repositories:
|
||||
# - repository: ComplianceRepo
|
||||
# type: github
|
||||
# endpoint: ComplianceGHRepo
|
||||
# name: PowerShell/compliance
|
||||
|
||||
stages:
|
||||
- stage: Build
|
||||
|
@ -24,7 +24,7 @@ stages:
|
|||
- job: BuildPkg
|
||||
displayName: Build Package
|
||||
pool:
|
||||
name: 1ES
|
||||
name: PS-PowerShell-x64
|
||||
demands:
|
||||
- ImageOverride -equals PSMMS2019-OpenSSH-Secure
|
||||
|
||||
|
@ -53,19 +53,39 @@ stages:
|
|||
|
||||
- pwsh: |
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
#
|
||||
# Copy build artifacts
|
||||
$BuildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH"
|
||||
if (Test-Path -Path $BuildDestPath) {
|
||||
Remove-Item -Path $BuildDestPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
$null = New-Item -ItemType Directory -Path $BuildDestPath -Force
|
||||
# Copy build artifacts
|
||||
$BuildDestx86Path = Join-Path -Path $BuildDestPath -ChildPath 'x86/Release'
|
||||
Start-OpenSSHPackage -NativeHostArch x86 -Configuration Release -DestinationPath $BuildDestx86Path
|
||||
Copy-BuildResults -BuildResultsPath $BuildDestx86Path -NativeHostArch x86 -Configuration Release
|
||||
$BuildDestX64Path = Join-Path -Path $BuildDestPath -ChildPath 'x64/Release'
|
||||
Start-OpenSSHPackage -NativeHostArch x64 -Configuration Release -DestinationPath $BuildDestx64Path
|
||||
Copy-BuildResults -BuildResultsPath $BuildDestx64Path -NativeHostArch x64 -Configuration Release
|
||||
#
|
||||
# Upload build artifacts
|
||||
Write-Verbose -Verbose -Message "Uploading build artifacts"
|
||||
$artifactName = 'Win32-OpenSSH'
|
||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$BuildDestPath"
|
||||
#
|
||||
# Copy unit tests
|
||||
$BuildOutPath = "$(Build.SourcesDirectory)/bin"
|
||||
$UnitTestDestPath = "$(Build.SourcesDirectory)/UnitTests"
|
||||
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x86 -Configuration Release
|
||||
Copy-UnitTests -UnitTestsSrcDir $BuildOutPath -UnitTestsDestDir $UnitTestDestPath -NativeHostArch x64 -Configuration Release
|
||||
#
|
||||
# Upload unit test artifacts
|
||||
Write-Verbose -Verbose -Message "Uploading unit test artifacts"
|
||||
$artifactName = 'UnitTests'
|
||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$UnitTestDestPath"
|
||||
#
|
||||
# Upload bash tests config.h file
|
||||
Write-Verbose -Verbose -Message "Uploading config.h file for bash tests"
|
||||
$artifactName = 'ConfigFile'
|
||||
$configFilePath = "$(Build.SourcesDirectory)/config.h"
|
||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$configFilePath"
|
||||
displayName: Upload Win32-OpenSSH build artifacts
|
||||
|
||||
#- stage: Compliance
|
||||
|
@ -91,17 +111,19 @@ stages:
|
|||
displayName: Test Win32-OpenSSH
|
||||
dependsOn: Build
|
||||
jobs:
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- powershell: |
|
||||
- job: TestPkgWin32OpenSSH
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
displayName: Win32-OpenSSH On Windows
|
||||
steps:
|
||||
- powershell: |
|
||||
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
|
||||
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
|
||||
./install-powershell.ps1 -Destination $powerShellPath
|
||||
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
|
||||
Write-Host "sending " + $vstsCommandString
|
||||
Write-Host "##$vstsCommandString"
|
||||
displayName: Install PowerShell Core
|
||||
displayName: 'Install PowerShell Core'
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: 'Download build artifacts'
|
||||
|
@ -111,25 +133,81 @@ stages:
|
|||
artifactName: Win32-OpenSSH
|
||||
downloadPath: '$(System.ArtifactsDirectory)'
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: 'Download unit test artifacts'
|
||||
inputs:
|
||||
buildType: current
|
||||
downloadType: single
|
||||
artifactName: UnitTests
|
||||
downloadPath: '$(System.ArtifactsDirectory)'
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: 'Download bash test config file artifact'
|
||||
inputs:
|
||||
buildType: current
|
||||
downloadType: single
|
||||
artifactName: ConfigFile
|
||||
downloadPath: '$(System.ArtifactsDirectory)'
|
||||
|
||||
- pwsh: |
|
||||
Get-ChildItem -Path "$(System.ArtifactsDirectory)/* -Recurse"
|
||||
$artifactDir = "$(System.ArtifactsDirectory)"
|
||||
Write-Verbose -Verbose -Message "Artifacts directory: $artifactDir"
|
||||
Get-ChildItem -Path $artifactDir -Recurse
|
||||
displayName: Capture downloaded artifact directory
|
||||
|
||||
- pwsh: |
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH/x64/Release/*" -OpenSSHDir "$env:SystemDrive/OpenSSH" -NativeHostArch x64 -Configuration Release -Verbose
|
||||
Install-OpenSSH -SourceDir "$(System.ArtifactsDirectory)/Win32-OpenSSH/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
|
||||
displayName: Install Win32-OpenSSH
|
||||
|
||||
|
||||
- pwsh: |
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
Install-UnitTests -SourceDir "$(System.ArtifactsDirectory)/UnitTests/x64/Release" -OpenSSHDir "$env:SystemDrive/OpenSSH" -Verbose
|
||||
displayName: Install Unit Tests
|
||||
|
||||
- pwsh: |
|
||||
$configFileSrc = "$(System.ArtifactsDirectory)/ConfigFile/config.h"
|
||||
$configFileDest = "$(Build.SourcesDirectory)"
|
||||
Write-Verbose -Verbose -Message "Copying config file from: ${configFileSrc} to: ${configFileDest}"
|
||||
Copy-Item -Path $configFileSrc -Dest $configFileDest -Force
|
||||
displayName: Copy config file artifact for bash tests
|
||||
|
||||
- pwsh: |
|
||||
$sourceDir = "$(Build.SourcesDirectory)"
|
||||
Write-Verbose -Verbose -Message "Source repo directory: $sourceDir"
|
||||
Get-ChildItem -Path $sourceDir
|
||||
displayName: Capture source repo directory for test
|
||||
|
||||
- pwsh: |
|
||||
$installedOpenSSHDir = "$env:SystemDrive/OpenSSH"
|
||||
Write-Verbose -Verbose -Message "Installed OpenSSH directory: $installedOpenSSHDir"
|
||||
Get-ChildItem -Path $installedOpenSSHDir -Recurse
|
||||
displayName: Capture installed OpenSSH directory
|
||||
|
||||
- pwsh: |
|
||||
# Run OpenSSH tests
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
Invoke-OpenSSHTests -OpenSSHBinPath "$env:SystemDrive/OpenSSH"
|
||||
displayName: Run tests
|
||||
|
||||
- pwsh: |
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
#
|
||||
# Copy test results to results directory
|
||||
$ResultsDirectory = "$(Build.SourcesDirectory)/Win32OpenSSHTestResults"
|
||||
Copy-OpenSSHTestResults -ResultsPath $ResultsDirectory
|
||||
#
|
||||
# Upload test results artifact
|
||||
if (Test-Path -Path $ResultsDirectory)
|
||||
{
|
||||
$artifactName = 'Win32-OpenSSH-TestResults'
|
||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$ResultsDirectory"
|
||||
}
|
||||
displayName: Run tests and publish results
|
||||
displayName: Upload test results
|
||||
condition: always()
|
||||
|
||||
- pwsh: |
|
||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||
Clear-TestEnvironmentSetup
|
||||
displayName: Clean up OpenSSH test environment
|
||||
condition: always()
|
||||
|
|
|
@ -28,10 +28,12 @@ NestedModules = @(
|
|||
'../OpenSSHTestHelper.psm1')
|
||||
|
||||
FunctionsToExport = @(
|
||||
'Invoke-AllLocally',
|
||||
'Invoke-AzDOBuild',
|
||||
'Install-OpenSSH',
|
||||
'Invoke-OpenSSHTests',
|
||||
'Copy-OpenSSHTestResults')
|
||||
|
||||
'Copy-OpenSSHTestResults',
|
||||
'Copy-BuildResults',
|
||||
'Copy-UnitTests',
|
||||
'Install-UnitTests',
|
||||
'Clear-TestEnvironmentSetup')
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
## [Add appropriate copyright]
|
||||
##
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$repoRoot = Get-RepositoryRoot
|
||||
|
@ -16,12 +15,11 @@ function Write-BuildMessage
|
|||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Message,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Category
|
||||
[string] $Category = "Information"
|
||||
)
|
||||
|
||||
# Write message to verbos stream.
|
||||
# Write message to verbose stream.
|
||||
Write-Verbose -Verbose -Message "$Category--$Message"
|
||||
|
||||
# Write it to the log file, if present.
|
||||
|
@ -33,85 +31,10 @@ function Write-BuildMessage
|
|||
|
||||
<#
|
||||
.Synopsis
|
||||
Adds a build log to the list of published artifacts.
|
||||
.Description
|
||||
If a build log exists, it is renamed to reflect the associated CLR runtime then added to the list of
|
||||
artifacts to publish. If it doesn't exist, a warning is written and the file is skipped.
|
||||
The rename is needed since publishing overwrites the artifact if it already exists.
|
||||
.Parameter artifacts
|
||||
An array list to add the fully qualified build log path
|
||||
.Parameter buildLog
|
||||
The build log file produced by the build.
|
||||
Implements the AzDO build package step
|
||||
#>
|
||||
function Add-BuildLog
|
||||
{
|
||||
param (
|
||||
[ValidateNotNull()]
|
||||
[System.Collections.ArrayList] $artifacts,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $buildLog
|
||||
)
|
||||
|
||||
if (Test-Path -Path $buildLog)
|
||||
{
|
||||
$null = $artifacts.Add($buildLog)
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Warning "Skip publishing build log. $buildLog does not exist"
|
||||
}
|
||||
}
|
||||
|
||||
function Set-BuildVariable
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Name,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Value
|
||||
)
|
||||
|
||||
Set-Item -Path env:$Name -Value $Value
|
||||
}
|
||||
|
||||
# Emulates running all of AzDO functions locally.
|
||||
# This should not be used within an actual AzDO build.
|
||||
function Invoke-AllLocally
|
||||
{
|
||||
param (
|
||||
[switch] $CleanRepo
|
||||
)
|
||||
|
||||
if ($CleanRepo)
|
||||
{
|
||||
Clear-PSRepo
|
||||
}
|
||||
|
||||
# TODO: Set up any build environment state here.
|
||||
|
||||
try
|
||||
{
|
||||
Invoke-AzDOBuild
|
||||
Install-OpenSSH
|
||||
Set-OpenSSHTestEnvironment -confirm:$false
|
||||
Invoke-OpenSSHTests
|
||||
Publish-Artifact
|
||||
}
|
||||
finally
|
||||
{
|
||||
# TODO: Clean up any build environment state here.
|
||||
}
|
||||
}
|
||||
|
||||
# Implements the AzDO build package step
|
||||
function Invoke-AzDOBuild
|
||||
{
|
||||
Set-BuildVariable TestPassed True
|
||||
Start-OpenSSHBuild -Configuration Release -NativeHostArch x64 -Verbose
|
||||
Start-OpenSSHBuild -Configuration Release -NativeHostArch x86 -Verbose
|
||||
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
|
||||
|
@ -124,8 +47,7 @@ function Invoke-AzDOBuild
|
|||
function Install-OpenSSH
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$SourceDir,
|
||||
|
||||
|
@ -137,7 +59,8 @@ function Install-OpenSSH
|
|||
if (! (Test-Path -Path $OpenSSHDir)) {
|
||||
$null = New-Item -Path $OpenSSHDir -ItemType Directory -Force
|
||||
}
|
||||
Copy-Item -Path $SourceDir -Destination $OpenSSHDir -Recurse -Force -Verbose
|
||||
|
||||
Copy-Item -Path "$SourceDir/*" -Destination $OpenSSHDir -Recurse -Force -Verbose
|
||||
|
||||
Push-Location $OpenSSHDir
|
||||
|
||||
|
@ -172,13 +95,12 @@ function Install-OpenSSH
|
|||
|
||||
<#
|
||||
.Synopsis
|
||||
uninstalled sshd
|
||||
Uninstalled sshd
|
||||
#>
|
||||
function UnInstall-OpenSSH
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
param (
|
||||
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
|
||||
)
|
||||
|
||||
|
@ -217,71 +139,17 @@ function UnInstall-OpenSSH
|
|||
Remove-Item -Path $OpenSSHDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
<#
|
||||
.Synopsis
|
||||
Publishes package build artifacts.
|
||||
.Parameter artifacts
|
||||
An array list to add the fully qualified build log path
|
||||
.Parameter FileToAdd
|
||||
Path to the file
|
||||
#>
|
||||
function Add-Artifact
|
||||
#
|
||||
# Install CygWin from Chocolatey and fix up install directory if needed.
|
||||
#
|
||||
function Install-CygWin
|
||||
{
|
||||
param
|
||||
(
|
||||
[ValidateNotNull()]
|
||||
[System.Collections.ArrayList] $artifacts,
|
||||
[string] $FileToAdd
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrEmpty($FileToAdd) -or (-not (Test-Path $FileToAdd -PathType Leaf)) )
|
||||
{
|
||||
Write-Host "Skip publishing package artifacts. $FileToAdd does not exist"
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = $artifacts.Add($FileToAdd)
|
||||
Write-Host "Added $FileToAdd to publishing package artifacts"
|
||||
}
|
||||
}
|
||||
param (
|
||||
[string] $InstallLocation
|
||||
)
|
||||
|
||||
<#
|
||||
.Synopsis
|
||||
After build and test run completes, upload all artifacts from the build machine.
|
||||
#>
|
||||
function Publish-Artifact
|
||||
{
|
||||
Write-Host -ForegroundColor Yellow "Publishing project artifacts"
|
||||
[System.Collections.ArrayList] $artifacts = new-object System.Collections.ArrayList
|
||||
|
||||
# Get the build.log file for each build configuration
|
||||
Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Release -NativeHostArch x64)
|
||||
Add-BuildLog -artifacts $artifacts -buildLog (Get-BuildLogFile -root $repoRoot.FullName -Configuration Release -NativeHostArch x86)
|
||||
|
||||
if($Global:OpenSSHTestInfo)
|
||||
{
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:OpenSSHTestInfo["SetupTestResultsFile"]
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:OpenSSHTestInfo["UnitTestResultsFile"]
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:OpenSSHTestInfo["E2ETestResultsFile"]
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:OpenSSHTestInfo["UninstallTestResultsFile"]
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:OpenSSHTestInfo["TestSetupLogFile"]
|
||||
}
|
||||
|
||||
if ($Global:bash_tests_summary)
|
||||
{
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:bash_tests_summary["BashTestSummaryFile"]
|
||||
Add-Artifact -artifacts $artifacts -FileToAdd $Global:bash_tests_summary["BashTestLogFile"]
|
||||
}
|
||||
|
||||
foreach ($artifact in $artifacts)
|
||||
{
|
||||
Write-Host "Publishing $artifact as AzDO artifact"
|
||||
|
||||
# TODO: Create an AzDO artificate upload function.
|
||||
# Push-AppveyorArtifact $artifact -ErrorAction Continue
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Yellow "End of publishing project artifacts"
|
||||
Write-Verbose -Verbose -Message "Installing CygWin from Chocolately to location: ${InstallLocation} ..."
|
||||
choco install cygwin -y --params "/InstallDir:${InstallLocation} /NoStartMenu"
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -292,113 +160,177 @@ function Invoke-OpenSSHTests
|
|||
{
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $OpenSSHBinPath
|
||||
)
|
||||
|
||||
Set-BasicTestInfo -OpenSSHBinPath $OpenSSHBinPath -Confirm:$false
|
||||
|
||||
Write-Verbose -Verbose -Message "Running OpenSSH Set up Tests..."
|
||||
|
||||
$AllTestsPassed = $true
|
||||
|
||||
Invoke-OpenSSHSetupTest
|
||||
|
||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["SetupTestResultsFile"])))
|
||||
{
|
||||
Write-Warning "Test result file $OpenSSHTestInfo["SetupTestResultsFile"] not found after tests."
|
||||
Write-BuildMessage -Message "Test result file $OpenSSHTestInfo["SetupTestResultsFile"] not found after tests." -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
$AllTestsPassed = $false
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
}
|
||||
|
||||
$xml = [xml](Get-Content $OpenSSHTestInfo["SetupTestResultsFile"] | out-string)
|
||||
if ([int]$xml.'test-results'.failures -gt 0)
|
||||
{
|
||||
$errorMessage = "$($xml.'test-results'.failures) setup tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["SetupTestResultsFile"])."
|
||||
Write-Warning $errorMessage
|
||||
$errorMessage = "$($xml.'test-results'.failures) Setup Tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["SetupTestResultsFile"])."
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
$AllTestsPassed = $False
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Start running unit tests"
|
||||
$unitTestFailed = Invoke-OpenSSHUnitTest
|
||||
Write-BuildMessage -Message "All Setup tests passed!" -Category Information
|
||||
$AllTestsPassed = $true
|
||||
|
||||
# Unit test directories are installed in the same directory as Open SSH binaries.
|
||||
# OpenSSH Directory
|
||||
# unittest-bitmap
|
||||
# unittest-hostkeys
|
||||
# ...
|
||||
# FixHostFilePermissions.ps1
|
||||
# ...
|
||||
Write-Verbose -Verbose -Message "Running Unit Tests..."
|
||||
Write-Verbose -Verbose -Message "Unit test directory is: ${OpenSSHBinPath}"
|
||||
|
||||
$unitTestFailed = Invoke-OpenSSHUnitTest -UnitTestDirectory $OpenSSHBinPath
|
||||
|
||||
if($unitTestFailed)
|
||||
{
|
||||
Write-Host "At least one of the unit tests failed!" -ForegroundColor Yellow
|
||||
Write-BuildMessage "At least one of the unit tests failed!" -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "All Unit tests passed!"
|
||||
Write-BuildMessage -Message "All Unit tests passed!" -Category Information
|
||||
}
|
||||
|
||||
# Run all E2E tests.
|
||||
Write-Verbose -Verbose -Message "Running E2E Tests..."
|
||||
Set-OpenSSHTestEnvironment -Confirm:$false
|
||||
Invoke-OpenSSHE2ETest
|
||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["E2ETestResultsFile"])))
|
||||
{
|
||||
Write-Warning "Test result file $OpenSSHTestInfo["E2ETestResultsFile"] not found after tests."
|
||||
Write-BuildMessage -Message "Test result file $OpenSSHTestInfo["E2ETestResultsFile"] not found after tests." -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
$xml = [xml](Get-Content $OpenSSHTestInfo["E2ETestResultsFile"] | out-string)
|
||||
if ([int]$xml.'test-results'.failures -gt 0)
|
||||
else
|
||||
{
|
||||
$errorMessage = "$($xml.'test-results'.failures) tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["E2ETestResultsFile"])."
|
||||
Write-Warning $errorMessage
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
$xml = [xml](Get-Content $OpenSSHTestInfo["E2ETestResultsFile"] | out-string)
|
||||
if ([int]$xml.'test-results'.failures -gt 0)
|
||||
{
|
||||
$errorMessage = "$($xml.'test-results'.failures) E2E tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["E2ETestResultsFile"])."
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-BuildMessage -Message "All E2E tests passed!" -Category Information
|
||||
}
|
||||
}
|
||||
|
||||
# Bash tests.
|
||||
Write-Verbose -Verbose -Message "Running Bash Tests..."
|
||||
|
||||
# Ensure CygWin is installed, and install from Chocolatey if needed.
|
||||
$cygwinInstalled = $true
|
||||
$cygwinInstallLocation = "$env:SystemDrive/cygwin"
|
||||
if (! (Test-Path -Path "$cygwinInstallLocation/bin/sh.exe"))
|
||||
{
|
||||
Write-Verbose -Verbose -Message "CygWin not found"
|
||||
Install-CygWin -InstallLocation $cygwinInstallLocation
|
||||
|
||||
# Hack to fix up mangled CygWin directory, if needed.
|
||||
$expectedCygWinPath = "$env:SystemDrive/cygwin/bin/sh.exe"
|
||||
if (! (Test-Path -Path $expectedCygWinPath))
|
||||
{
|
||||
Write-Verbose -Verbose -Message "CygWin did not install correctly, missing expected path: ${expectedCygWinPath}"
|
||||
|
||||
$cygWinDirs = Get-Item -Path "$env:SystemDrive/cygwin*"
|
||||
if ($cygWinDirs.Count -gt 1)
|
||||
{
|
||||
Write-Verbose -Verbose -Message "CygWin install failed with mangled folder locations: ${cygWinDirs}"
|
||||
Write-Verbose -Verbose -Message 'TODO: Add hack to fix up CygWin folder.'
|
||||
}
|
||||
|
||||
Write-BuildMessage -Message "All bash tests failed because CygWin install failed" -Category Error
|
||||
$AllTestsPassed = $false
|
||||
$cygwinInstalled = $false
|
||||
}
|
||||
}
|
||||
|
||||
# Run UNIX bash tests.
|
||||
Invoke-OpenSSHBashTests
|
||||
if (-not $Global:bash_tests_summary)
|
||||
if ($cygwinInstalled)
|
||||
{
|
||||
$errorMessage = "Failed to start OpenSSH bash tests"
|
||||
Write-Warning $errorMessage
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
}
|
||||
|
||||
if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0)
|
||||
{
|
||||
$total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"]
|
||||
$total_bash_tests = $Global:bash_tests_summary["TotalBashTests"]
|
||||
$errorMessage = "At least one of the bash tests failed. [$total_bash_failed_tests of $total_bash_tests]"
|
||||
Write-Warning $errorMessage
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
Write-Warning "Stop running further tests!"
|
||||
return
|
||||
Write-Verbose -Verbose -Message "Starting Bash Tests..."
|
||||
Invoke-OpenSSHBashTests
|
||||
if (-not $Global:bash_tests_summary)
|
||||
{
|
||||
$errorMessage = "Failed to start OpenSSH bash tests"
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0)
|
||||
{
|
||||
$total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"]
|
||||
$total_bash_tests = $Global:bash_tests_summary["TotalBashTests"]
|
||||
$errorMessage = "At least one of the bash tests failed. [$total_bash_failed_tests of $total_bash_tests]"
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
|
||||
$OpenSSHTestInfo["BashTestSummaryFile"] = $Global:bash_tests_summary["BashTestSummaryFile"]
|
||||
$OpenSSHTestInfo["BashTestLogFile"] = $Global:bash_tests_summary["BashTestLogFile"]
|
||||
}
|
||||
}
|
||||
|
||||
# OpenSSH Uninstall Tests
|
||||
Invoke-OpenSSHUninstallTest
|
||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["UninstallTestResultsFile"])))
|
||||
{
|
||||
Write-Warning "Test result file $OpenSSHTestInfo["UninstallTestResultsFile"] not found after tests."
|
||||
Write-BuildMessage -Message "Test result file $OpenSSHTestInfo["UninstallTestResultsFile"] not found after tests." -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
$xml = [xml](Get-Content $OpenSSHTestInfo["UninstallTestResultsFile"] | out-string)
|
||||
if ([int]$xml.'test-results'.failures -gt 0)
|
||||
{
|
||||
$errorMessage = "$($xml.'test-results'.failures) uninstall tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["UninstallTestResultsFile"])."
|
||||
Write-Warning $errorMessage
|
||||
Write-BuildMessage -Message $errorMessage -Category Error
|
||||
Set-BuildVariable TestPassed False
|
||||
$AllTestsPassed = $false
|
||||
}
|
||||
}
|
||||
|
||||
# Save OpenSSHTestInfo for later test results uploading.
|
||||
$OpenSSHTestInfo | Export-Clixml -Path "$repoRoot/OpenSSHTestInfo.xml" -Depth 10
|
||||
|
||||
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
|
||||
if ($Error.Count -gt 0)
|
||||
{
|
||||
Write-BuildMessage -Message "Tests Should clean $Error after success." -Category Warning
|
||||
Write-BuildMessage -Message "Tests Should always clean $Error variable after success." -Category Warning
|
||||
}
|
||||
|
||||
if ($AllTestsPassed)
|
||||
{
|
||||
Write-BuildMessage -Message "All OpenSSH validation tests have passed!" -Category Information
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-BuildMessage -Message "Some OpenSSH validation tests have failed." -Category Error
|
||||
throw "OpenSSH validation tests failed!"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,46 +353,161 @@ function Copy-OpenSSHTestResults
|
|||
Write-Verbose -Verbose "Creating test results directory for artifacts upload: $ResultsPath"
|
||||
$null = New-Item -Path $ResultsPath -ItemType Directory -Force
|
||||
|
||||
if (Test-Path -Path $ResultsPath)
|
||||
if (! (Test-Path -Path $ResultsPath))
|
||||
{
|
||||
$setupresultFile = Resolve-Path $Global:OpenSSHTestInfo["SetupTestResultsFile"] -ErrorAction Ignore
|
||||
if ($setupresultFile)
|
||||
{
|
||||
Write-Verbose -Verbose "Copying set-up test results file, $setupresultFile, to results directory"
|
||||
Copy-Item -Path $setupresultFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
$E2EresultFile = Resolve-Path $Global:OpenSSHTestInfo["E2ETestResultsFile"] -ErrorAction Ignore
|
||||
if ($E2EresultFile)
|
||||
{
|
||||
Write-Verbose -Verbose "Copying end-to-end test results file, $E2EresultFile, to results directory"
|
||||
Copy-Item -Path $E2EresultFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
$uninstallResultFile = Resolve-Path $Global:OpenSSHTestInfo["UninstallTestResultsFile"] -ErrorAction Ignore
|
||||
if ($uninstallResultFile)
|
||||
{
|
||||
Write-Verbose -Verbose "Copying uninstall test results file, $uninstallResultFile, to results directory"
|
||||
Copy-Item -Path $uninstallResultFile -Destination $ResultsPath
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Verbose -Verbose "Unable to write test results path for test artifacts upload: $ResultsPath"
|
||||
Write-BuildMessage -Message "Unable to write to test results path for test artifacts upload: $ResultsPath" -Category Error
|
||||
return
|
||||
}
|
||||
|
||||
if ($env:DebugMode)
|
||||
$OpenSSHTestInfo = $null
|
||||
$openSSHTestInfoFilePath = "$repoRoot/OpenSSHTestInfo.xml"
|
||||
if (Test-Path -Path $openSSHTestInfoFilePath)
|
||||
{
|
||||
Remove-Item $env:DebugMode
|
||||
$OpenSSHTestInfo = Import-Clixml -Path $openSSHTestInfoFilePath
|
||||
}
|
||||
|
||||
if($env:TestPassed -ieq 'True')
|
||||
|
||||
if (! $OpenSSHTestInfo)
|
||||
{
|
||||
Write-BuildMessage -Message "The checkin validation tests succeeded!" -Category Information
|
||||
Write-BuildMessage -Message "Unable to get OpenSSHTestInfo object from: ${openSSHTestInfoFilePath}"
|
||||
return
|
||||
}
|
||||
else
|
||||
|
||||
try { $setupresultFile = Resolve-Path -Path $OpenSSHTestInfo["SetupTestResultsFile"] -ErrorAction Ignore } catch { }
|
||||
if ($setupresultFile)
|
||||
{
|
||||
Write-BuildMessage -Message "The checkin validation tests failed!" -Category Error
|
||||
throw "The checkin validation tests failed!"
|
||||
Write-Verbose -Verbose -Message "Copying set-up test results file, $setupresultFile, to results directory"
|
||||
Copy-Item -Path $setupresultFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
try { $E2EresultFile = Resolve-Path -Path $OpenSSHTestInfo["E2ETestResultsFile"] -ErrorAction Ignore } catch { }
|
||||
if ($E2EresultFile)
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Copying end-to-end test results file, $E2EresultFile, to results directory"
|
||||
Copy-Item -Path $E2EresultFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
try { $uninstallResultFile = Resolve-Path $OpenSSHTestInfo["UninstallTestResultsFile"] -ErrorAction Ignore } catch { }
|
||||
if ($uninstallResultFile)
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Copying uninstall test results file, $uninstallResultFile, to results directory"
|
||||
Copy-Item -Path $uninstallResultFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
try { $bashTestsSummaryFile = Resolve-Path -Path $OpenSSHTestInfo["BashTestSummaryFile"] -ErrorAction Ignore } catch { }
|
||||
if ($bashTestsSummaryFile)
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Copying bash tests summary file, $bashTestsSummaryFile, to results directory"
|
||||
Copy-Item -Path $bashTestsSummaryFile -Destination $ResultsPath
|
||||
}
|
||||
|
||||
try { $bashTestsLogFile = Resolve-Path -Path $OpenSSHTestInfo["BashTestLogFile"] -ErrorAction Ignore } catch { }
|
||||
if ($bashTestsLogFile)
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Copying bash tests log file, $bashTestsLogFile, to results directory"
|
||||
Copy-Item -Path $bashTestsLogFile -Destination $ResultsPath
|
||||
}
|
||||
}
|
||||
|
||||
function Clear-TestEnvironmentSetup
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Running OpenSSH test environment cleanup..."
|
||||
|
||||
try
|
||||
{
|
||||
$null = Clear-OpenSSHTestEnvironment -ErrorAction Ignore
|
||||
$null = UnInstall-OpenSSH -ErrorAction Ignore
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
Write-Verbose -Verbose -Message "OpenSSH test environment cleanup complete."
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Copy build results package to provided destination path.
|
||||
#>
|
||||
function Copy-BuildResults
|
||||
{
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $BuildResultsPath,
|
||||
|
||||
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
|
||||
[string]$NativeHostArch = "x64",
|
||||
|
||||
[ValidateSet('Debug', 'Release')]
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
# Copy OpenSSH package to results directory
|
||||
Start-OpenSSHPackage -DestinationPath $BuildResultsPath -NativeHostArch $NativeHostArch -Configuration $Configuration
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Copy build unit tests to provided destination path.
|
||||
#>
|
||||
function Copy-UnitTests
|
||||
{
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $UnitTestsSrcDir,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $UnitTestsDestDir,
|
||||
|
||||
[ValidateSet('x86', 'x64', 'arm64', 'arm')]
|
||||
[string]$NativeHostArch = "x64",
|
||||
|
||||
[ValidateSet('Debug', 'Release')]
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
if (! (Test-Path -Path $UnitTestsDestDir))
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Creating Unit Test directory: $UnitTestsDestDir"
|
||||
$null = New-Item -Path $UnitTestsDestDir -ItemType Directory -Force
|
||||
}
|
||||
|
||||
if ($NativeHostArch -eq 'x86')
|
||||
{
|
||||
$unitTestsSrcPath = Join-Path -Path $UnitTestsSrcDir -ChildPath "Win32/${Configuration}"
|
||||
}
|
||||
else
|
||||
{
|
||||
$unitTestsSrcPath = Join-Path -Path $UnitTestsSrcDir -ChildPath "${NativeHostArch}/${Configuration}"
|
||||
}
|
||||
|
||||
$unitTestsDestPath = Join-Path -Path $UnitTestsDestDir -ChildPath "${NativeHostArch}/${Configuration}"
|
||||
|
||||
if (! (Test-Path -Path $unitTestsDestPath))
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Creating Unit Test directory: $unitTestsDestPath"
|
||||
$null = New-Item -Path $unitTestsDestPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Write-Verbose -Verbose -Message "Copying unit tests from: ${unitTestsSrcPath} to: ${unitTestsDestPath}"
|
||||
Copy-Item -Path "$unitTestsSrcPath/unittest-*" -Destination $unitTestsDestPath -Recurse -Force
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Install unit tests to provided destination.
|
||||
#>
|
||||
function Install-UnitTests
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$SourceDir,
|
||||
|
||||
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
|
||||
)
|
||||
|
||||
if (! (Test-Path -Path $OpenSSHDir)) {
|
||||
$null = New-Item -Path $OpenSSHDir -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Copy-Item -Path "$SourceDir/*" -Destination $OpenSSHDir -Recurse -Force
|
||||
}
|
||||
|
|
|
@ -401,10 +401,12 @@ function Install-OpenSSHTestDependencies
|
|||
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 2>&1 >> $Script:TestSetupLogFile
|
||||
}
|
||||
|
||||
$isModuleAvailable = Get-Module 'Pester' -ListAvailable
|
||||
if (-not ($isModuleAvailable))
|
||||
# Pester 5.x is not compatible with tests.
|
||||
$InstalledPesters = Get-Module -Name 'Pester' -ListAvailable | Where-Object { $_.Version -lt '5.0' }
|
||||
if ($InstalledPesters.Count -eq 0)
|
||||
{
|
||||
Write-Log -Message "Installing Pester..."
|
||||
# Install-Module -Name 'Pester' -RequiredVersion 3.4.6
|
||||
choco install Pester --version 3.4.6 -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
||||
}
|
||||
|
||||
|
@ -522,8 +524,10 @@ function Get-UserSID
|
|||
Clear-OpenSSHTestEnvironment
|
||||
#>
|
||||
function Clear-OpenSSHTestEnvironment
|
||||
{
|
||||
if($Global:OpenSSHTestInfo -eq $null) {
|
||||
{
|
||||
Write-Verbose -Verbose -Message "Running Clear-OpenSSHTestEnvironment..."
|
||||
|
||||
if ($Global:OpenSSHTestInfo -eq $null) {
|
||||
throw "OpenSSHTestInfo is not set. Did you run Set-OpenSShTestEnvironment?"
|
||||
}
|
||||
|
||||
|
@ -638,9 +642,11 @@ function Get-UnitTestDirectory
|
|||
Run OpenSSH Setup tests.
|
||||
#>
|
||||
function Invoke-OpenSSHSetupTest
|
||||
{
|
||||
{
|
||||
# Tests are not compatible with latest Pester 5.x.
|
||||
Import-Module -Name 'Pester' -MaximumVersion 4.9.9 -Force -Global
|
||||
|
||||
# Discover all CI tests and run them.
|
||||
Import-Module pester -force -global
|
||||
Push-Location $Script:E2ETestDirectory
|
||||
Write-Log -Message "Running OpenSSH Setup tests..."
|
||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
||||
|
@ -653,9 +659,11 @@ function Invoke-OpenSSHSetupTest
|
|||
Run OpenSSH uninstall tests.
|
||||
#>
|
||||
function Invoke-OpenSSHUninstallTest
|
||||
{
|
||||
{
|
||||
# Tests are not compatible with latest Pester 5.x.
|
||||
Import-Module -Name 'Pester' -MaximumVersion 4.9.9 -Force -Global
|
||||
|
||||
# Discover all CI tests and run them.
|
||||
Import-Module pester -force -global
|
||||
Push-Location $Script:E2ETestDirectory
|
||||
Write-Log -Message "Running OpenSSH Uninstall tests..."
|
||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
||||
|
@ -670,12 +678,15 @@ function Invoke-OpenSSHUninstallTest
|
|||
function Invoke-OpenSSHE2ETest
|
||||
{
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
param (
|
||||
[ValidateSet('CI', 'Scenario')]
|
||||
[string]$pri = "CI")
|
||||
[string]$pri = "CI"
|
||||
)
|
||||
|
||||
# Tests are not compatible with latest Pester 5.x.
|
||||
Import-Module -Name 'Pester' -MaximumVersion 4.9.9 -Force -Global
|
||||
|
||||
# Discover all CI tests and run them.
|
||||
Import-Module pester -force -global
|
||||
Push-Location $Script:E2ETestDirectory
|
||||
Write-Log -Message "Running OpenSSH E2E tests..."
|
||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
||||
|
@ -712,7 +723,7 @@ function Invoke-OpenSSHBashTests
|
|||
|
||||
$bashTestDirectory = Join-Path $repositoryRoot.FullName -ChildPath "regress"
|
||||
|
||||
&"$PSScriptRoot\bash_tests_iterator.ps1" -OpenSSHBinPath $Script:OpenSSHBinPath -BashTestsPath $bashTestDirectory -ShellPath $bashPath -ArtifactsDirectoryPath $bashTestDirectory
|
||||
& "$PSScriptRoot\bash_tests_iterator.ps1" -OpenSSHBinPath $Script:OpenSSHBinPath -BashTestsPath $bashTestDirectory -ShellPath $bashPath -ArtifactsDirectoryPath $bashTestDirectory
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -720,12 +731,22 @@ function Invoke-OpenSSHBashTests
|
|||
Run openssh unit tests.
|
||||
#>
|
||||
function Invoke-OpenSSHUnitTest
|
||||
{
|
||||
{
|
||||
param (
|
||||
[string] $UnitTestDirectory = ""
|
||||
)
|
||||
|
||||
# Discover all CI tests and run them.
|
||||
if([string]::Isnullorempty($Script:UnitTestDirectory))
|
||||
if (! [string]::IsNullOrEmpty($UnitTestDirectory) -and (Test-Path -Path $UnitTestDirectory))
|
||||
{
|
||||
$Script:UnitTestDirectory = $UnitTestDirectory
|
||||
$OpenSSHTestInfo["UnitTestDirectory"] = $UnitTestDirectory
|
||||
}
|
||||
elseif ([string]::Isnullorempty($Script:UnitTestDirectory))
|
||||
{
|
||||
$Script:UnitTestDirectory = $OpenSSHTestInfo["UnitTestDirectory"]
|
||||
}
|
||||
|
||||
Push-Location $Script:UnitTestDirectory
|
||||
Write-Log -Message "Running OpenSSH unit tests..."
|
||||
if (Test-Path $Script:UnitTestResultsFile)
|
||||
|
@ -793,14 +814,19 @@ function Write-Log
|
|||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Message
|
||||
)
|
||||
if(-not (Test-Path (Split-Path $Script:TestSetupLogFile) -PathType Container))
|
||||
|
||||
if (-not (Test-Path (Split-Path $Script:TestSetupLogFile) -PathType Container))
|
||||
{
|
||||
$null = New-Item -ItemType Directory -Path (Split-Path $Script:TestSetupLogFile) -Force -ErrorAction SilentlyContinue | out-null
|
||||
}
|
||||
|
||||
if (-not ([string]::IsNullOrEmpty($Script:TestSetupLogFile)))
|
||||
{
|
||||
Add-Content -Path $Script:TestSetupLogFile -Value $Message
|
||||
}
|
||||
}
|
||||
|
||||
# Write message to verbose stream.
|
||||
Write-Verbose -Verbose -Message $Message
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Set-BasicTestInfo, Set-OpenSSHTestEnvironment, Clear-OpenSSHTestEnvironment, Invoke-OpenSSHSetupTest, Invoke-OpenSSHUnitTest, Invoke-OpenSSHE2ETest, Invoke-OpenSSHUninstallTest, Invoke-OpenSSHBashTests
|
|
@ -24,7 +24,7 @@ if ($TestFilePath) {
|
|||
# convert to bash format
|
||||
$TestFilePath = $TestFilePath -replace "\\","/"
|
||||
}
|
||||
$OriginalSystemPath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
||||
$OriginalSystemPath = [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
# Make sure config.h exists. It is used in some bashstests (Ex - sftp-glob.sh, cfgparse.sh)
|
||||
# first check in $BashTestsPath folder. If not then it's parent folder. If not then in the $OpenSSHBinPath
|
||||
|
|
|
@ -25,7 +25,7 @@ start_client()
|
|||
if test $n -gt 60; then
|
||||
if [ "$os" == "windows" ]; then
|
||||
# We can't kill windows process from cygwin / wsl so use "stop-process"
|
||||
powershell.exe /c "stop-process -id $client_pid" >/dev/null 2>&1
|
||||
powershell.exe /c "stop-process -id $client_pid -Force" >/dev/null 2>&1
|
||||
else
|
||||
kill $client_pid
|
||||
fi
|
||||
|
@ -39,8 +39,8 @@ stop_client()
|
|||
pid=`cat $pidfile`
|
||||
if [ "$os" == "windows" ]; then
|
||||
# We can't kill windows process from cygwin / wsl so use "stop-process"
|
||||
powershell.exe /c "stop-process -id $pid" >/dev/null 2>&1
|
||||
powershell.exe /c "stop-process -name sleep" >/dev/null 2>&1
|
||||
powershell.exe /c "stop-process -id $pid -Force" >/dev/null 2>&1
|
||||
powershell.exe /c "stop-process -name sleep -Force" >/dev/null 2>&1
|
||||
else
|
||||
if [ ! -z "$pid" ]; then
|
||||
kill $pid
|
||||
|
|
|
@ -715,7 +715,8 @@ for t in ${SSH_HOSTKEY_TYPES}; do
|
|||
(umask 077; $SUDO cp $OBJ/$t $OBJ/host.$t)
|
||||
if [ "$os" == "windows" ]; then
|
||||
# set the file permissions (ACLs) properly
|
||||
powershell.exe /c "get-acl $OBJ_WIN_FORMAT/$t | set-acl $OBJ_WIN_FORMAT/host.$t"
|
||||
pwsh.exe /ExecutionPolicy Bypass /c "get-acl $OBJ_WIN_FORMAT/$t | set-acl $OBJ_WIN_FORMAT/host.$t"
|
||||
# powershell.exe /ExecutionPolicy Bypass /c "get-acl $OBJ_WIN_FORMAT/$t | set-acl $OBJ_WIN_FORMAT/host.$t"
|
||||
fi
|
||||
|
||||
echo HostKey $OBJ/host.$t >> $OBJ/sshd_config
|
||||
|
@ -726,7 +727,8 @@ done
|
|||
|
||||
if [ "$os" == "windows" ]; then
|
||||
# set the file permissions (ACLs) properly
|
||||
powershell.exe /c "get-acl $OBJ_WIN_FORMAT/$first_key_type | set-acl $OBJ_WIN_FORMAT/authorized_keys_$USER"
|
||||
pwsh.exe /ExecutionPolicy Bypass /c "get-acl $OBJ_WIN_FORMAT/$first_key_type | set-acl $OBJ_WIN_FORMAT/authorized_keys_$USER"
|
||||
# powershell.exe /ExecutionPolicy Bypass /c "get-acl $OBJ_WIN_FORMAT/$first_key_type | set-acl $OBJ_WIN_FORMAT/authorized_keys_$USER"
|
||||
fi
|
||||
|
||||
# Activate Twisted Conch tests if the binary is present
|
||||
|
|
Loading…
Reference in New Issue