diff --git a/test/powershell/Host/Startup.Tests.ps1 b/test/powershell/Host/Startup.Tests.ps1 index 87704901f42..9a4cf05da0a 100644 --- a/test/powershell/Host/Startup.Tests.ps1 +++ b/test/powershell/Host/Startup.Tests.ps1 @@ -103,7 +103,7 @@ Describe "Validate start of console host" -Tag CI { } It "No new assemblies are loaded" { - if ( (Get-PlatformInfo) -eq "alpine" ) { + if ( (Get-PlatformInfo).Platform -eq "alpine" ) { Set-ItResult -Pending -Because "Missing MI library causes list to be different" return } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 index 822f97166dd..20634b1dd67 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -64,7 +64,7 @@ Describe "Test-Connection" -tags "CI" { { $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } | Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand" # Error code = 11001 - Host not found. - if ((Get-PlatformInfo) -match "raspbian") { + if ((Get-PlatformInfo).Platform -match "raspbian") { $code = 11 } elseif (!$IsWindows) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 index a71fe68ccb3..fbf71dead4f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1 @@ -35,7 +35,7 @@ Describe "Get-Date DRT Unit Tests" -Tags "CI" { $seconds | Should -Be "1577836800" if ($IsLinux) { $dateString = "01/01/2020 UTC" - if ( (Get-PlatformInfo) -eq "alpine" ) { + if ( (Get-PlatformInfo).Platform -eq "alpine" ) { $dateString = "2020-01-01" } $expected = date --date=${dateString} +%s diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 b/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 index 092cef295b7..771f9f86e42 100644 --- a/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 +++ b/test/powershell/Modules/PSDesiredStateConfiguration/MOF-Compilation.Tests.ps1 @@ -7,7 +7,12 @@ Describe "DSC MOF Compilation" -tags "CI" { } BeforeAll { - $SkipAdditionalPlatforms = (Get-PlatformInfo) -match "alpine|raspbian" + $platformInfo = Get-PlatformInfo + $SkipAdditionalPlatforms = + ($platformInfo.Platform -match "alpine|raspbian") -or + ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + Import-Module PSDesiredStateConfiguration $dscModule = Get-Module PSDesiredStateConfiguration $baseSchemaPath = Join-Path $dscModule.ModuleBase 'Configuration' diff --git a/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 b/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 index fd0d0a09742..fd51ff77012 100644 --- a/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 +++ b/test/powershell/Modules/PSDesiredStateConfiguration/PSDesiredStateConfiguration.Tests.ps1 @@ -28,7 +28,12 @@ Function Test-IsInvokeDscResourceEnable { Describe "Test PSDesiredStateConfiguration" -tags CI { BeforeAll { $MissingLibmi = $false - if ((Get-PlatformInfo) -match "alpine|raspbian") { + $platformInfo = Get-PlatformInfo + if ( + ($platformInfo.Platform -match "alpine|raspbian") -or + ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + ) { $MissingLibmi = $true } } diff --git a/test/powershell/engine/Remoting/PSSession.Tests.ps1 b/test/powershell/engine/Remoting/PSSession.Tests.ps1 index 4207c914fee..7d17a7f444d 100644 --- a/test/powershell/engine/Remoting/PSSession.Tests.ps1 +++ b/test/powershell/engine/Remoting/PSSession.Tests.ps1 @@ -74,8 +74,12 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS param ($scriptBlock, $expectedErrorCode) $platformInfo = Get-PlatformInfo - if (($platformInfo -eq "alpine") -or ($platformInfo -eq "raspbian")) { - Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi" + if ( + ($platformInfo.Platform -match "alpine|raspbian") -or + ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + ) { + Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8" return } diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index 91b1fa02e4e..7277735e115 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -6,8 +6,12 @@ Import-Module HelpersCommon Describe "New-PSSession basic test" -Tag @("CI") { It "New-PSSession should not crash powershell" { $platformInfo = Get-PlatformInfo - if (($platformInfo -eq "alpine") -or ($platformInfo -eq "raspbian")) { - Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi" + if ( + ($platformInfo.Platform -match "alpine|raspbian") -or + ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + ) { + Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8" return } @@ -19,8 +23,12 @@ Describe "New-PSSession basic test" -Tag @("CI") { Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") { It "New-PSSession should throw when specifying Basic Auth over HTTP on Unix" -skip:($IsWindows) { $platformInfo = Get-PlatformInfo - if (($platformInfo -eq "alpine") -or ($platformInfo -eq "raspbian")) { - Set-ItResult -Skipped -Because "MI library not available for Alpine or Raspberry Pi" + if ( + ($platformInfo.Platform -match "alpine|raspbian") -or + ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + ) { + Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8" return } diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index 195e17f0d62..c9de2db3f51 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -365,18 +365,26 @@ function New-ComplexPassword } # return a specific string with regard to platform information -function Get-PlatformInfo -{ +function Get-PlatformInfo { if ( $IsWindows ) { - return "windows" + return @{Platform = "windows"; Version = '' } } if ( $IsMacOS ) { - return "macos" + return @{Platform = "macos"; Version = '' } } if ( $IsLinux ) { $osrelease = Get-Content /etc/os-release | ConvertFrom-StringData if ( -not [string]::IsNullOrEmpty($osrelease.ID) ) { - return $osrelease.ID + + $versionId = if (-not $osrelease.Version_ID ) { + '' + } else { + $osrelease.Version_ID.trim('"') + } + + $platform = $osrelease.ID.trim('"') + + return @{Platform = $platform; Version = $versionId } } return "unknown" }