mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-10 00:44:55 -06:00
Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016. The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021: Number of commits on the main branch: 2930 Number of contributors: 31 Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
58 lines
2.1 KiB
PowerShell
58 lines
2.1 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Copies linux unit tests to a given WSL distribution.
|
|
.PARAMETER WslTestDirPath
|
|
The absolute path to the location of the \wsl-build\test\linux directory.
|
|
.PARAMETER DistroName
|
|
The name of the WSL distribution to copy the unit tests inside of.
|
|
Defaults to "test_distro"
|
|
#>
|
|
|
|
param (
|
|
[Parameter( ValueFromPipeline = $true,
|
|
ValueFromPipelineByPropertyName = $true,
|
|
ParameterSetName = "WslTestDirPath",
|
|
HelpMessage = "Path to \wsl-build\test\linux\ location")]
|
|
[Parameter( ParameterSetName = "CopyTestAll ")]
|
|
[Alias('testpath')]
|
|
[string[]]$WslTestDirPath,
|
|
[Parameter( ValueFromPipeline = $true,
|
|
ValueFromPipelineByPropertyName = $true,
|
|
Mandatory = $false,
|
|
ParameterSetName = "DistroName",
|
|
HelpMessage = "Name of WSL distro to run tests in; defaults to test_distro")]
|
|
[Parameter( ParameterSetName = "CopyTestAll ")]
|
|
[Alias('distro')]
|
|
[string[]]$DistroName = 'test_distro'
|
|
)
|
|
|
|
Write-Output "WslTestDirPath: $WslTestDirPath"
|
|
Write-Output "DistroName: $DistroName"
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
Set-StrictMode -Version Latest
|
|
|
|
function Run {
|
|
[CmdletBinding()]
|
|
param([ScriptBlock]$cmd)
|
|
|
|
Invoke-Command -ScriptBlock $cmd
|
|
if ($LastExitCode -ne 0) {
|
|
throw ("$cmd failed with exit code: " + $lastexitcode)
|
|
}
|
|
}
|
|
|
|
$DistroPath = "$env:LocalAppData\lxss"
|
|
|
|
Write-Output "Copying unit tests to $DistroPath\rootfs\data\test"
|
|
|
|
# get wslpath to unit tests
|
|
$WslUnitTestPath = Run { wsl.exe --exec wslpath "$WslTestDirPath\unit_tests" }
|
|
|
|
# set-up the folder structure for the tests and copy them into the linux distro
|
|
Run { wsl.exe --distribution $DistroName --user root --exec bash -c "umask 0; mkdir -p /data;" }
|
|
Run { wsl.exe --distribution $DistroName --user root --exec bash -c "umask 0; cp -r $WslUnitTestPath /data/test" }
|
|
Run { wsl.exe --distribution $DistroName --user root --exec bash -c "umask 0; mkdir -p /data/test/log; ls -la /data/test" }
|
|
|
|
# ensure that /etc/fstab exists for the unit tests that expect it
|
|
Run { wsl.exe --distribution $DistroName --user root --exec bash -c "( [ -e `"/etc/fstab`" ] || touch `"/etc/fstab`" )" } |