Test script for attaching Windows VM to vhost scsi or vhost blk controller and creating various filesystem types on the attached devices. FIO integrtity test as a possible improvement in the future. Change-Id: I5bd784398551742a9226b9a7ba16a45edd27f474 Signed-off-by: Karol Latecki <karol.latecki@intel.com> Reviewed-on: https://review.gerrithub.io/c/443359 Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
79 lines
2.5 KiB
PowerShell
79 lines
2.5 KiB
PowerShell
# Get the ID and security principal of the current user account
|
|
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
|
|
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
|
|
|
|
# Get the security principal for the Administrator role
|
|
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
|
|
|
# Check to see if we are currently running "as Administrator"
|
|
if ($myWindowsPrincipal.IsInRole($adminRole)) {
|
|
# We are running "as Administrator" - so change the title and background color to indicate this
|
|
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"
|
|
$Host.UI.RawUI.BackgroundColor = "DarkBlue"
|
|
clear-host
|
|
} else
|
|
{
|
|
# We are not running "as Administrator" - so relaunch as administrator
|
|
|
|
# Create a new process object that starts PowerShell
|
|
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
|
|
|
|
# Specify the current script path and name as a parameter
|
|
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
|
|
|
|
# Indicate that the process should be elevated
|
|
$newProcess.Verb = "runas";
|
|
|
|
# Start the new process
|
|
[System.Diagnostics.Process]::Start($newProcess);
|
|
|
|
# Exit from the current, unelevated, process
|
|
exit
|
|
}
|
|
|
|
# Set bash -e equivalent
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$filesystems=@("NTFS", "FAT32", "FAT")
|
|
$disks = get-disk | Where-Object FriendlyName -NotMatch "QEMU"
|
|
Start-Sleep 2
|
|
foreach($disk in $disks)
|
|
{
|
|
$size = $disk.Size
|
|
$number = $disk.Number
|
|
$serial = $disk.SerialNumber
|
|
$model = $disk.model.Trim()
|
|
$size = $size -replace " ", "_"
|
|
$model = $model -replace " ", "_"
|
|
|
|
$label = "${number}_${model}_${serial}_${size}"
|
|
echo "Running tests for disk $label"
|
|
start-sleep 2
|
|
|
|
Try {
|
|
Initialize-Disk -Number $disk.Number -PartitionStyle MBR
|
|
} Catch {
|
|
Clear-Disk -Number $disk.Number -RemoveData -Confirm:$false
|
|
Initialize-Disk -Number $disk.Number -PartitionStyle MBR
|
|
}
|
|
echo "`tDisk initialized"
|
|
start-sleep 2
|
|
|
|
$part = New-Partition -DiskNumber $disk.Number -UseMaximumSize -AssignDriveLetter
|
|
echo "`tCreated partition $($part.DriveLetter)"
|
|
start-sleep 2
|
|
|
|
foreach($fs in $filesystems) {
|
|
echo "`tTrying to format $($part.DriveLetter) with $fs"
|
|
Try {
|
|
$vol = Format-Volume -DriveLetter $part.DriveLetter -FileSystem $fs -Confirm:$false
|
|
} Catch [Exception] {
|
|
echo $_.Exception.GetType().FullName, $_.Exception.Message
|
|
echo $_.Exception | format-list -force
|
|
exit 1
|
|
}
|
|
echo "`tPartition $($part.DriveLetter) formatted with $fs filesystem"
|
|
start-sleep 2
|
|
}
|
|
}
|