mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-31 01:35:11 +02:00
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
106
.azdo/ci.yml
106
.azdo/ci.yml
@ -10,12 +10,12 @@ pr:
|
|||||||
include:
|
include:
|
||||||
- latestw_all
|
- latestw_all
|
||||||
|
|
||||||
resources:
|
#resources:
|
||||||
repositories:
|
# repositories:
|
||||||
- repository: ComplianceRepo
|
# - repository: ComplianceRepo
|
||||||
type: github
|
# type: github
|
||||||
endpoint: ComplianceGHRepo
|
# endpoint: ComplianceGHRepo
|
||||||
name: PowerShell/compliance
|
# name: PowerShell/compliance
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- stage: Build
|
- stage: Build
|
||||||
@ -24,7 +24,7 @@ stages:
|
|||||||
- job: BuildPkg
|
- job: BuildPkg
|
||||||
displayName: Build Package
|
displayName: Build Package
|
||||||
pool:
|
pool:
|
||||||
name: 1ES
|
name: PS-PowerShell-x64
|
||||||
demands:
|
demands:
|
||||||
- ImageOverride -equals PSMMS2019-OpenSSH-Secure
|
- ImageOverride -equals PSMMS2019-OpenSSH-Secure
|
||||||
|
|
||||||
@ -53,19 +53,39 @@ stages:
|
|||||||
|
|
||||||
- pwsh: |
|
- pwsh: |
|
||||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||||
|
#
|
||||||
|
# Copy build artifacts
|
||||||
$BuildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH"
|
$BuildDestPath = "$(Build.SourcesDirectory)/Win32-OpenSSH"
|
||||||
if (Test-Path -Path $BuildDestPath) {
|
if (Test-Path -Path $BuildDestPath) {
|
||||||
Remove-Item -Path $BuildDestPath -Recurse -Force -ErrorAction SilentlyContinue
|
Remove-Item -Path $BuildDestPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
$null = New-Item -ItemType Directory -Path $BuildDestPath -Force
|
$null = New-Item -ItemType Directory -Path $BuildDestPath -Force
|
||||||
# Copy build artifacts
|
|
||||||
$BuildDestx86Path = Join-Path -Path $BuildDestPath -ChildPath 'x86/Release'
|
$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'
|
$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
|
# Upload build artifacts
|
||||||
|
Write-Verbose -Verbose -Message "Uploading build artifacts"
|
||||||
$artifactName = 'Win32-OpenSSH'
|
$artifactName = 'Win32-OpenSSH'
|
||||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$BuildDestPath"
|
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
|
displayName: Upload Win32-OpenSSH build artifacts
|
||||||
|
|
||||||
#- stage: Compliance
|
#- stage: Compliance
|
||||||
@ -91,8 +111,10 @@ stages:
|
|||||||
displayName: Test Win32-OpenSSH
|
displayName: Test Win32-OpenSSH
|
||||||
dependsOn: Build
|
dependsOn: Build
|
||||||
jobs:
|
jobs:
|
||||||
|
- job: TestPkgWin32OpenSSH
|
||||||
pool:
|
pool:
|
||||||
vmImage: windows-latest
|
vmImage: windows-latest
|
||||||
|
displayName: Win32-OpenSSH On Windows
|
||||||
steps:
|
steps:
|
||||||
- powershell: |
|
- powershell: |
|
||||||
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
|
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
|
||||||
@ -101,7 +123,7 @@ stages:
|
|||||||
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
|
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
|
||||||
Write-Host "sending " + $vstsCommandString
|
Write-Host "sending " + $vstsCommandString
|
||||||
Write-Host "##$vstsCommandString"
|
Write-Host "##$vstsCommandString"
|
||||||
displayName: Install PowerShell Core
|
displayName: 'Install PowerShell Core'
|
||||||
|
|
||||||
- task: DownloadBuildArtifacts@0
|
- task: DownloadBuildArtifacts@0
|
||||||
displayName: 'Download build artifacts'
|
displayName: 'Download build artifacts'
|
||||||
@ -111,25 +133,81 @@ stages:
|
|||||||
artifactName: Win32-OpenSSH
|
artifactName: Win32-OpenSSH
|
||||||
downloadPath: '$(System.ArtifactsDirectory)'
|
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: |
|
- 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
|
displayName: Capture downloaded artifact directory
|
||||||
|
|
||||||
- pwsh: |
|
- pwsh: |
|
||||||
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
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
|
displayName: Install Win32-OpenSSH
|
||||||
|
|
||||||
- pwsh: |
|
- 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
|
Import-Module -Name "$(Build.SourcesDirectory)/contrib/win32/openssh/AzDOBuildTools" -Force
|
||||||
Invoke-OpenSSHTests -OpenSSHBinPath "$env:SystemDrive/OpenSSH"
|
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
|
# Copy test results to results directory
|
||||||
$ResultsDirectory = "$(Build.SourcesDirectory)/Win32OpenSSHTestResults"
|
$ResultsDirectory = "$(Build.SourcesDirectory)/Win32OpenSSHTestResults"
|
||||||
Copy-OpenSSHTestResults -ResultsPath $ResultsDirectory
|
Copy-OpenSSHTestResults -ResultsPath $ResultsDirectory
|
||||||
|
#
|
||||||
# Upload test results artifact
|
# Upload test results artifact
|
||||||
if (Test-Path -Path $ResultsDirectory)
|
if (Test-Path -Path $ResultsDirectory)
|
||||||
{
|
{
|
||||||
$artifactName = 'Win32-OpenSSH-TestResults'
|
$artifactName = 'Win32-OpenSSH-TestResults'
|
||||||
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$ResultsDirectory"
|
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')
|
'../OpenSSHTestHelper.psm1')
|
||||||
|
|
||||||
FunctionsToExport = @(
|
FunctionsToExport = @(
|
||||||
'Invoke-AllLocally',
|
|
||||||
'Invoke-AzDOBuild',
|
'Invoke-AzDOBuild',
|
||||||
'Install-OpenSSH',
|
'Install-OpenSSH',
|
||||||
'Invoke-OpenSSHTests',
|
'Invoke-OpenSSHTests',
|
||||||
'Copy-OpenSSHTestResults')
|
'Copy-OpenSSHTestResults',
|
||||||
|
'Copy-BuildResults',
|
||||||
|
'Copy-UnitTests',
|
||||||
|
'Install-UnitTests',
|
||||||
|
'Clear-TestEnvironmentSetup')
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
## [Add appropriate copyright]
|
## [Add appropriate copyright]
|
||||||
##
|
##
|
||||||
|
|
||||||
Set-StrictMode -Version Latest
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
$repoRoot = Get-RepositoryRoot
|
$repoRoot = Get-RepositoryRoot
|
||||||
@ -16,12 +15,11 @@ function Write-BuildMessage
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string] $Message,
|
[string] $Message,
|
||||||
|
|
||||||
[Parameter(Mandatory=$true)]
|
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string] $Category
|
[string] $Category = "Information"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Write message to verbos stream.
|
# Write message to verbose stream.
|
||||||
Write-Verbose -Verbose -Message "$Category--$Message"
|
Write-Verbose -Verbose -Message "$Category--$Message"
|
||||||
|
|
||||||
# Write it to the log file, if present.
|
# Write it to the log file, if present.
|
||||||
@ -33,85 +31,10 @@ function Write-BuildMessage
|
|||||||
|
|
||||||
<#
|
<#
|
||||||
.Synopsis
|
.Synopsis
|
||||||
Adds a build log to the list of published artifacts.
|
Implements the AzDO build package step
|
||||||
.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.
|
|
||||||
#>
|
#>
|
||||||
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
|
function Invoke-AzDOBuild
|
||||||
{
|
{
|
||||||
Set-BuildVariable TestPassed True
|
|
||||||
Start-OpenSSHBuild -Configuration Release -NativeHostArch x64 -Verbose
|
Start-OpenSSHBuild -Configuration Release -NativeHostArch x64 -Verbose
|
||||||
Start-OpenSSHBuild -Configuration Release -NativeHostArch x86 -Verbose
|
Start-OpenSSHBuild -Configuration Release -NativeHostArch x86 -Verbose
|
||||||
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
|
Write-BuildMessage -Message "OpenSSH binaries build success!" -Category Information
|
||||||
@ -124,8 +47,7 @@ function Invoke-AzDOBuild
|
|||||||
function Install-OpenSSH
|
function Install-OpenSSH
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param (
|
||||||
(
|
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$SourceDir,
|
[string]$SourceDir,
|
||||||
|
|
||||||
@ -137,7 +59,8 @@ function Install-OpenSSH
|
|||||||
if (! (Test-Path -Path $OpenSSHDir)) {
|
if (! (Test-Path -Path $OpenSSHDir)) {
|
||||||
$null = New-Item -Path $OpenSSHDir -ItemType Directory -Force
|
$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
|
Push-Location $OpenSSHDir
|
||||||
|
|
||||||
@ -172,13 +95,12 @@ function Install-OpenSSH
|
|||||||
|
|
||||||
<#
|
<#
|
||||||
.Synopsis
|
.Synopsis
|
||||||
uninstalled sshd
|
Uninstalled sshd
|
||||||
#>
|
#>
|
||||||
function UnInstall-OpenSSH
|
function UnInstall-OpenSSH
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param (
|
||||||
(
|
|
||||||
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
|
[string]$OpenSSHDir = "$env:SystemDrive\OpenSSH"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -217,71 +139,17 @@ function UnInstall-OpenSSH
|
|||||||
Remove-Item -Path $OpenSSHDir -Recurse -Force -ErrorAction SilentlyContinue
|
Remove-Item -Path $OpenSSHDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
#
|
||||||
.Synopsis
|
# Install CygWin from Chocolatey and fix up install directory if needed.
|
||||||
Publishes package build artifacts.
|
#
|
||||||
.Parameter artifacts
|
function Install-CygWin
|
||||||
An array list to add the fully qualified build log path
|
|
||||||
.Parameter FileToAdd
|
|
||||||
Path to the file
|
|
||||||
#>
|
|
||||||
function Add-Artifact
|
|
||||||
{
|
{
|
||||||
param
|
param (
|
||||||
(
|
[string] $InstallLocation
|
||||||
[ValidateNotNull()]
|
|
||||||
[System.Collections.ArrayList] $artifacts,
|
|
||||||
[string] $FileToAdd
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($FileToAdd) -or (-not (Test-Path $FileToAdd -PathType Leaf)) )
|
Write-Verbose -Verbose -Message "Installing CygWin from Chocolately to location: ${InstallLocation} ..."
|
||||||
{
|
choco install cygwin -y --params "/InstallDir:${InstallLocation} /NoStartMenu"
|
||||||
Write-Host "Skip publishing package artifacts. $FileToAdd does not exist"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$null = $artifacts.Add($FileToAdd)
|
|
||||||
Write-Host "Added $FileToAdd to publishing package artifacts"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<#
|
|
||||||
.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"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -292,113 +160,177 @@ function Invoke-OpenSSHTests
|
|||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
[string] $OpenSSHBinPath
|
[string] $OpenSSHBinPath
|
||||||
)
|
)
|
||||||
|
|
||||||
Set-BasicTestInfo -OpenSSHBinPath $OpenSSHBinPath -Confirm:$false
|
Set-BasicTestInfo -OpenSSHBinPath $OpenSSHBinPath -Confirm:$false
|
||||||
|
|
||||||
|
Write-Verbose -Verbose -Message "Running OpenSSH Set up Tests..."
|
||||||
|
|
||||||
|
$AllTestsPassed = $true
|
||||||
|
|
||||||
Invoke-OpenSSHSetupTest
|
Invoke-OpenSSHSetupTest
|
||||||
|
|
||||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["SetupTestResultsFile"])))
|
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
|
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!"
|
Write-Warning "Stop running further tests!"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$xml = [xml](Get-Content $OpenSSHTestInfo["SetupTestResultsFile"] | out-string)
|
$xml = [xml](Get-Content $OpenSSHTestInfo["SetupTestResultsFile"] | out-string)
|
||||||
if ([int]$xml.'test-results'.failures -gt 0)
|
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"])."
|
$errorMessage = "$($xml.'test-results'.failures) Setup Tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["SetupTestResultsFile"])."
|
||||||
Write-Warning $errorMessage
|
|
||||||
Write-BuildMessage -Message $errorMessage -Category Error
|
Write-BuildMessage -Message $errorMessage -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $False
|
||||||
Write-Warning "Stop running further tests!"
|
Write-Warning "Stop running further tests!"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Start running unit tests"
|
Write-BuildMessage -Message "All Setup tests passed!" -Category Information
|
||||||
$unitTestFailed = Invoke-OpenSSHUnitTest
|
$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)
|
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
|
Write-BuildMessage "At least one of the unit tests failed!" -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $false
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Write-Host "All Unit tests passed!"
|
|
||||||
Write-BuildMessage -Message "All Unit tests passed!" -Category Information
|
Write-BuildMessage -Message "All Unit tests passed!" -Category Information
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run all E2E tests.
|
# Run all E2E tests.
|
||||||
|
Write-Verbose -Verbose -Message "Running E2E Tests..."
|
||||||
Set-OpenSSHTestEnvironment -Confirm:$false
|
Set-OpenSSHTestEnvironment -Confirm:$false
|
||||||
Invoke-OpenSSHE2ETest
|
Invoke-OpenSSHE2ETest
|
||||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["E2ETestResultsFile"])))
|
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
|
Write-BuildMessage -Message "Test result file $OpenSSHTestInfo["E2ETestResultsFile"] not found after tests." -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $false
|
||||||
Write-Warning "Stop running further tests!"
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$xml = [xml](Get-Content $OpenSSHTestInfo["E2ETestResultsFile"] | out-string)
|
$xml = [xml](Get-Content $OpenSSHTestInfo["E2ETestResultsFile"] | out-string)
|
||||||
if ([int]$xml.'test-results'.failures -gt 0)
|
if ([int]$xml.'test-results'.failures -gt 0)
|
||||||
{
|
{
|
||||||
$errorMessage = "$($xml.'test-results'.failures) tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["E2ETestResultsFile"])."
|
$errorMessage = "$($xml.'test-results'.failures) E2E tests in regress\pesterTests failed. Detail test log is at $($OpenSSHTestInfo["E2ETestResultsFile"])."
|
||||||
Write-Warning $errorMessage
|
|
||||||
Write-BuildMessage -Message $errorMessage -Category Error
|
Write-BuildMessage -Message $errorMessage -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $false
|
||||||
Write-Warning "Stop running further tests!"
|
}
|
||||||
return
|
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.
|
# Run UNIX bash tests.
|
||||||
|
if ($cygwinInstalled)
|
||||||
|
{
|
||||||
|
Write-Verbose -Verbose -Message "Starting Bash Tests..."
|
||||||
Invoke-OpenSSHBashTests
|
Invoke-OpenSSHBashTests
|
||||||
if (-not $Global:bash_tests_summary)
|
if (-not $Global:bash_tests_summary)
|
||||||
{
|
{
|
||||||
$errorMessage = "Failed to start OpenSSH bash tests"
|
$errorMessage = "Failed to start OpenSSH bash tests"
|
||||||
Write-Warning $errorMessage
|
|
||||||
Write-BuildMessage -Message $errorMessage -Category Error
|
Write-BuildMessage -Message $errorMessage -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $false
|
||||||
Write-Warning "Stop running further tests!"
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0)
|
if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0)
|
||||||
{
|
{
|
||||||
$total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"]
|
$total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"]
|
||||||
$total_bash_tests = $Global:bash_tests_summary["TotalBashTests"]
|
$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]"
|
$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
|
Write-BuildMessage -Message $errorMessage -Category Error
|
||||||
Set-BuildVariable TestPassed False
|
$AllTestsPassed = $false
|
||||||
Write-Warning "Stop running further tests!"
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$OpenSSHTestInfo["BashTestSummaryFile"] = $Global:bash_tests_summary["BashTestSummaryFile"]
|
||||||
|
$OpenSSHTestInfo["BashTestLogFile"] = $Global:bash_tests_summary["BashTestLogFile"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# OpenSSH Uninstall Tests
|
||||||
Invoke-OpenSSHUninstallTest
|
Invoke-OpenSSHUninstallTest
|
||||||
if (($OpenSSHTestInfo -eq $null) -or (-not (Test-Path $OpenSSHTestInfo["UninstallTestResultsFile"])))
|
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
|
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)
|
$xml = [xml](Get-Content $OpenSSHTestInfo["UninstallTestResultsFile"] | out-string)
|
||||||
if ([int]$xml.'test-results'.failures -gt 0)
|
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"])."
|
$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
|
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.
|
# Writing out warning when the $Error.Count is non-zero. Tests Should clean $Error after success.
|
||||||
if ($Error.Count -gt 0)
|
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"
|
Write-Verbose -Verbose "Creating test results directory for artifacts upload: $ResultsPath"
|
||||||
$null = New-Item -Path $ResultsPath -ItemType Directory -Force
|
$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
|
Write-BuildMessage -Message "Unable to write to test results path for test artifacts upload: $ResultsPath" -Category Error
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$OpenSSHTestInfo = $null
|
||||||
|
$openSSHTestInfoFilePath = "$repoRoot/OpenSSHTestInfo.xml"
|
||||||
|
if (Test-Path -Path $openSSHTestInfoFilePath)
|
||||||
|
{
|
||||||
|
$OpenSSHTestInfo = Import-Clixml -Path $openSSHTestInfoFilePath
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $OpenSSHTestInfo)
|
||||||
|
{
|
||||||
|
Write-BuildMessage -Message "Unable to get OpenSSHTestInfo object from: ${openSSHTestInfoFilePath}"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try { $setupresultFile = Resolve-Path -Path $OpenSSHTestInfo["SetupTestResultsFile"] -ErrorAction Ignore } catch { }
|
||||||
if ($setupresultFile)
|
if ($setupresultFile)
|
||||||
{
|
{
|
||||||
Write-Verbose -Verbose "Copying set-up test results file, $setupresultFile, to results directory"
|
Write-Verbose -Verbose -Message "Copying set-up test results file, $setupresultFile, to results directory"
|
||||||
Copy-Item -Path $setupresultFile -Destination $ResultsPath
|
Copy-Item -Path $setupresultFile -Destination $ResultsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
$E2EresultFile = Resolve-Path $Global:OpenSSHTestInfo["E2ETestResultsFile"] -ErrorAction Ignore
|
try { $E2EresultFile = Resolve-Path -Path $OpenSSHTestInfo["E2ETestResultsFile"] -ErrorAction Ignore } catch { }
|
||||||
if ($E2EresultFile)
|
if ($E2EresultFile)
|
||||||
{
|
{
|
||||||
Write-Verbose -Verbose "Copying end-to-end test results file, $E2EresultFile, to results directory"
|
Write-Verbose -Verbose -Message "Copying end-to-end test results file, $E2EresultFile, to results directory"
|
||||||
Copy-Item -Path $E2EresultFile -Destination $ResultsPath
|
Copy-Item -Path $E2EresultFile -Destination $ResultsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
$uninstallResultFile = Resolve-Path $Global:OpenSSHTestInfo["UninstallTestResultsFile"] -ErrorAction Ignore
|
try { $uninstallResultFile = Resolve-Path $OpenSSHTestInfo["UninstallTestResultsFile"] -ErrorAction Ignore } catch { }
|
||||||
if ($uninstallResultFile)
|
if ($uninstallResultFile)
|
||||||
{
|
{
|
||||||
Write-Verbose -Verbose "Copying uninstall test results file, $uninstallResultFile, to results directory"
|
Write-Verbose -Verbose -Message "Copying uninstall test results file, $uninstallResultFile, to results directory"
|
||||||
Copy-Item -Path $uninstallResultFile -Destination $ResultsPath
|
Copy-Item -Path $uninstallResultFile -Destination $ResultsPath
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
try { $bashTestsSummaryFile = Resolve-Path -Path $OpenSSHTestInfo["BashTestSummaryFile"] -ErrorAction Ignore } catch { }
|
||||||
|
if ($bashTestsSummaryFile)
|
||||||
{
|
{
|
||||||
Write-Verbose -Verbose "Unable to write test results path for test artifacts upload: $ResultsPath"
|
Write-Verbose -Verbose -Message "Copying bash tests summary file, $bashTestsSummaryFile, to results directory"
|
||||||
|
Copy-Item -Path $bashTestsSummaryFile -Destination $ResultsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($env:DebugMode)
|
try { $bashTestsLogFile = Resolve-Path -Path $OpenSSHTestInfo["BashTestLogFile"] -ErrorAction Ignore } catch { }
|
||||||
|
if ($bashTestsLogFile)
|
||||||
{
|
{
|
||||||
Remove-Item $env:DebugMode
|
Write-Verbose -Verbose -Message "Copying bash tests log file, $bashTestsLogFile, to results directory"
|
||||||
}
|
Copy-Item -Path $bashTestsLogFile -Destination $ResultsPath
|
||||||
|
|
||||||
if($env:TestPassed -ieq 'True')
|
|
||||||
{
|
|
||||||
Write-BuildMessage -Message "The checkin validation tests succeeded!" -Category Information
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-BuildMessage -Message "The checkin validation tests failed!" -Category Error
|
|
||||||
throw "The checkin validation tests failed!"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 2>&1 >> $Script:TestSetupLogFile
|
||||||
}
|
}
|
||||||
|
|
||||||
$isModuleAvailable = Get-Module 'Pester' -ListAvailable
|
# Pester 5.x is not compatible with tests.
|
||||||
if (-not ($isModuleAvailable))
|
$InstalledPesters = Get-Module -Name 'Pester' -ListAvailable | Where-Object { $_.Version -lt '5.0' }
|
||||||
|
if ($InstalledPesters.Count -eq 0)
|
||||||
{
|
{
|
||||||
Write-Log -Message "Installing Pester..."
|
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
|
choco install Pester --version 3.4.6 -y --force --limitoutput 2>&1 >> $Script:TestSetupLogFile
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +525,9 @@ function Get-UserSID
|
|||||||
#>
|
#>
|
||||||
function 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?"
|
throw "OpenSSHTestInfo is not set. Did you run Set-OpenSShTestEnvironment?"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,8 +643,10 @@ function Get-UnitTestDirectory
|
|||||||
#>
|
#>
|
||||||
function Invoke-OpenSSHSetupTest
|
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.
|
# Discover all CI tests and run them.
|
||||||
Import-Module pester -force -global
|
|
||||||
Push-Location $Script:E2ETestDirectory
|
Push-Location $Script:E2ETestDirectory
|
||||||
Write-Log -Message "Running OpenSSH Setup tests..."
|
Write-Log -Message "Running OpenSSH Setup tests..."
|
||||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
||||||
@ -654,8 +660,10 @@ function Invoke-OpenSSHSetupTest
|
|||||||
#>
|
#>
|
||||||
function Invoke-OpenSSHUninstallTest
|
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.
|
# Discover all CI tests and run them.
|
||||||
Import-Module pester -force -global
|
|
||||||
Push-Location $Script:E2ETestDirectory
|
Push-Location $Script:E2ETestDirectory
|
||||||
Write-Log -Message "Running OpenSSH Uninstall tests..."
|
Write-Log -Message "Running OpenSSH Uninstall tests..."
|
||||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
||||||
@ -670,12 +678,15 @@ function Invoke-OpenSSHUninstallTest
|
|||||||
function Invoke-OpenSSHE2ETest
|
function Invoke-OpenSSHE2ETest
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param (
|
||||||
(
|
|
||||||
[ValidateSet('CI', 'Scenario')]
|
[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.
|
# Discover all CI tests and run them.
|
||||||
Import-Module pester -force -global
|
|
||||||
Push-Location $Script:E2ETestDirectory
|
Push-Location $Script:E2ETestDirectory
|
||||||
Write-Log -Message "Running OpenSSH E2E tests..."
|
Write-Log -Message "Running OpenSSH E2E tests..."
|
||||||
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
|
$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"
|
$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
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -721,11 +732,21 @@ function Invoke-OpenSSHBashTests
|
|||||||
#>
|
#>
|
||||||
function Invoke-OpenSSHUnitTest
|
function Invoke-OpenSSHUnitTest
|
||||||
{
|
{
|
||||||
|
param (
|
||||||
|
[string] $UnitTestDirectory = ""
|
||||||
|
)
|
||||||
|
|
||||||
# Discover all CI tests and run them.
|
# 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"]
|
$Script:UnitTestDirectory = $OpenSSHTestInfo["UnitTestDirectory"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Push-Location $Script:UnitTestDirectory
|
Push-Location $Script:UnitTestDirectory
|
||||||
Write-Log -Message "Running OpenSSH unit tests..."
|
Write-Log -Message "Running OpenSSH unit tests..."
|
||||||
if (Test-Path $Script:UnitTestResultsFile)
|
if (Test-Path $Script:UnitTestResultsFile)
|
||||||
@ -793,14 +814,19 @@ function Write-Log
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string] $Message
|
[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
|
$null = New-Item -ItemType Directory -Path (Split-Path $Script:TestSetupLogFile) -Force -ErrorAction SilentlyContinue | out-null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not ([string]::IsNullOrEmpty($Script:TestSetupLogFile)))
|
if (-not ([string]::IsNullOrEmpty($Script:TestSetupLogFile)))
|
||||||
{
|
{
|
||||||
Add-Content -Path $Script:TestSetupLogFile -Value $Message
|
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
|
Export-ModuleMember -Function Set-BasicTestInfo, Set-OpenSSHTestEnvironment, Clear-OpenSSHTestEnvironment, Invoke-OpenSSHSetupTest, Invoke-OpenSSHUnitTest, Invoke-OpenSSHE2ETest, Invoke-OpenSSHUninstallTest, Invoke-OpenSSHBashTests
|
@ -25,7 +25,7 @@ start_client()
|
|||||||
if test $n -gt 60; then
|
if test $n -gt 60; then
|
||||||
if [ "$os" == "windows" ]; then
|
if [ "$os" == "windows" ]; then
|
||||||
# We can't kill windows process from cygwin / wsl so use "stop-process"
|
# 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
|
else
|
||||||
kill $client_pid
|
kill $client_pid
|
||||||
fi
|
fi
|
||||||
@ -39,8 +39,8 @@ stop_client()
|
|||||||
pid=`cat $pidfile`
|
pid=`cat $pidfile`
|
||||||
if [ "$os" == "windows" ]; then
|
if [ "$os" == "windows" ]; then
|
||||||
# We can't kill windows process from cygwin / wsl so use "stop-process"
|
# 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 -id $pid -Force" >/dev/null 2>&1
|
||||||
powershell.exe /c "stop-process -name sleep" >/dev/null 2>&1
|
powershell.exe /c "stop-process -name sleep -Force" >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
if [ ! -z "$pid" ]; then
|
if [ ! -z "$pid" ]; then
|
||||||
kill $pid
|
kill $pid
|
||||||
|
@ -715,7 +715,8 @@ for t in ${SSH_HOSTKEY_TYPES}; do
|
|||||||
(umask 077; $SUDO cp $OBJ/$t $OBJ/host.$t)
|
(umask 077; $SUDO cp $OBJ/$t $OBJ/host.$t)
|
||||||
if [ "$os" == "windows" ]; then
|
if [ "$os" == "windows" ]; then
|
||||||
# set the file permissions (ACLs) properly
|
# 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
|
fi
|
||||||
|
|
||||||
echo HostKey $OBJ/host.$t >> $OBJ/sshd_config
|
echo HostKey $OBJ/host.$t >> $OBJ/sshd_config
|
||||||
@ -726,7 +727,8 @@ done
|
|||||||
|
|
||||||
if [ "$os" == "windows" ]; then
|
if [ "$os" == "windows" ]; then
|
||||||
# set the file permissions (ACLs) properly
|
# 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
|
fi
|
||||||
|
|
||||||
# Activate Twisted Conch tests if the binary is present
|
# Activate Twisted Conch tests if the binary is present
|
||||||
|
Loading…
x
Reference in New Issue
Block a user