Add build, deploy and test sources
This commit is contained in:
1 parent
825be27efd
commit
b8dfcda031
115 files changed
+8548
No files matched your search
@@ -0,0 +1,207 @@
|
||||
; Автотест РЕАЛЬНОЙ разметки на виртуальном диске (VHD).
|
||||
; Требует прав администратора (запускается через run-vhd.ps1).
|
||||
Opt("WinTitleMatchMode", 2)
|
||||
Opt("SendKeyDelay", 50)
|
||||
#include <MsgBoxConstants.au3>
|
||||
#include <GuiComboBox.au3>
|
||||
|
||||
Global $dir = @ScriptDir
|
||||
Global $logF = $dir & "\vhd-result.txt"
|
||||
Global $vhd = $dir & "\pf-test.vhdx"
|
||||
Global $hMain = 0
|
||||
Global $fail = 0
|
||||
|
||||
FileDelete($logF)
|
||||
Global $f = FileOpen($logF, 2 + 8)
|
||||
|
||||
Func L($s)
|
||||
FileWriteLine($f, $s)
|
||||
EndFunc
|
||||
|
||||
Func Dp($cmds, $tag)
|
||||
Local $sp = $dir & "\dp-" & $tag & ".txt"
|
||||
Local $lf = $dir & "\dp-" & $tag & ".log"
|
||||
Local $h = FileOpen($sp, 2 + 128)
|
||||
FileWrite($h, $cmds)
|
||||
FileClose($h)
|
||||
RunWait(@ComSpec & ' /c diskpart.exe /s "' & $sp & '" > "' & $lf & '" 2>&1', "", @SW_HIDE)
|
||||
Return FileRead($lf)
|
||||
EndFunc
|
||||
|
||||
Func Cleanup($tag)
|
||||
Dp('select vdisk file="' & $vhd & '"' & @CRLF & 'detach vdisk noerr' & @CRLF & 'exit' & @CRLF, $tag)
|
||||
Sleep(2500)
|
||||
If FileExists($vhd) Then FileDelete($vhd)
|
||||
L("cleanup: vhd deleted = " & (Not FileExists($vhd)))
|
||||
EndFunc
|
||||
|
||||
; --- 0. убрать остатки прошлого прогона
|
||||
Cleanup("clean0")
|
||||
|
||||
; --- 1. создать и подключить VHD 20 ГБ
|
||||
L("=== create/attach vdisk ===")
|
||||
L(Dp('create vdisk file="' & $vhd & '" maximum=20480 type=expandable' & @CRLF & _
|
||||
'select vdisk file="' & $vhd & '"' & @CRLF & 'attach vdisk' & @CRLF & 'exit' & @CRLF, "make"))
|
||||
|
||||
; --- 2. номер диска: MSFT_Disk, BusType = 15 (File Backed Virtual)
|
||||
Local $num = -1
|
||||
Local $oStorage = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\Microsoft\Windows\Storage")
|
||||
Local $tries = 0
|
||||
While $num < 0 And $tries < 20
|
||||
If IsObj($oStorage) Then
|
||||
Local $col = $oStorage.ExecQuery("SELECT * FROM MSFT_Disk")
|
||||
If IsObj($col) Then
|
||||
For $d In $col
|
||||
If Number($d.BusType) = 15 Then $num = Number($d.Number)
|
||||
Next
|
||||
EndIf
|
||||
EndIf
|
||||
If $num < 0 Then
|
||||
Sleep(1000)
|
||||
$tries = $tries + 1
|
||||
EndIf
|
||||
WEnd
|
||||
L("disk number: " & $num & " (попыток: " & $tries & ")")
|
||||
|
||||
If $num < 0 Then
|
||||
L("FAIL: виртуальный диск не найден")
|
||||
$fail = 1
|
||||
EndIf
|
||||
|
||||
If $fail = 0 Then
|
||||
; --- 3. вывести в online
|
||||
L("=== online ===")
|
||||
L(Dp('select disk ' & $num & @CRLF & 'online disk' & @CRLF & 'attributes disk clear readonly' & @CRLF & 'exit' & @CRLF, "online"))
|
||||
|
||||
; --- 4. реальная разметка + распаковка WIM через утилиту
|
||||
Local $extra = ""
|
||||
If FileExists($dir & "\use7z.flag") Then $extra = " /use7z"
|
||||
Run($dir & "\test.exe /testdisk=" & $num & ' /wim=C:\PF\TEST_i\PF.esd' & $extra)
|
||||
$hMain = WinWait("PARAVIS FLASH", "", 25)
|
||||
If $hMain = 0 Then
|
||||
L("FAIL: окно утилиты не появилось")
|
||||
$fail = 1
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
If $fail = 0 Then
|
||||
Sleep(1500)
|
||||
|
||||
ControlClick($hMain, "", "[CLASS:Static; TEXT:ЗАПИСАТЬ]")
|
||||
Sleep(1200)
|
||||
|
||||
Local $hC = WinWait("Подтверждение", "", 10)
|
||||
If $hC = 0 Then
|
||||
L("FAIL: подтверждение не появилось")
|
||||
$fail = 1
|
||||
Else
|
||||
L("--- подтверждение ---")
|
||||
L(WinGetText($hC))
|
||||
ControlClick($hC, "", "[CLASS:Button; INSTANCE:1]")
|
||||
|
||||
; --- 5. финальное окно утилиты
|
||||
Local $hR = WinWait("Готово", "", 1800)
|
||||
If $hR = 0 Then $hR = WinWait("Ошибка", "", 20)
|
||||
If $hR = 0 Then
|
||||
L("FAIL: окно результата не появилось")
|
||||
$fail = 1
|
||||
Else
|
||||
L("=== результат: " & WinGetTitle($hR) & " ===")
|
||||
L(WinGetText($hR))
|
||||
ControlClick($hR, "", "[CLASS:Button; INSTANCE:1]")
|
||||
EndIf
|
||||
EndIf
|
||||
Sleep(1500)
|
||||
|
||||
; --- 5б. проверка, что файлы легли на разделы
|
||||
If $fail = 0 Then
|
||||
Local $oWMI = ObjGet("winmgmts:\\.\root\cimv2")
|
||||
Local $i
|
||||
For $i = 0 To 2
|
||||
Local $letter = _PartLetter($oWMI, $num, $i)
|
||||
If $letter = "" Then
|
||||
L("раздел " & ($i + 1) & ": буква не найдена")
|
||||
$fail = 1
|
||||
ContinueLoop
|
||||
EndIf
|
||||
Local $cnt = _DirCount($letter & "\")
|
||||
L("раздел " & ($i + 1) & " (" & $letter & "): файлов " & $cnt)
|
||||
If $i = 0 Then
|
||||
L(" efi\Paravis\KRD на месте: " & FileExists($letter & "\efi\Paravis\KRD"))
|
||||
L(" efi\Paravis\Linux нет: " & (Not FileExists($letter & "\efi\Paravis\Linux")))
|
||||
L(" *.iso в PARAVIS: " & _IsoCount($letter & "\"))
|
||||
EndIf
|
||||
If $i = 2 Then
|
||||
L(" папка ISO на месте: " & FileExists($letter & "\ISO"))
|
||||
L(" ISO\Ventoy\NOT.DEL: " & FileExists($letter & "\ISO\Ventoy\NOT.DEL"))
|
||||
EndIf
|
||||
Next
|
||||
EndIf
|
||||
|
||||
; --- 6. независимая проверка таблицы разделов
|
||||
L("=== list partition ===")
|
||||
L(Dp('select disk ' & $num & @CRLF & 'list partition' & @CRLF & 'exit' & @CRLF, "check"))
|
||||
L("=== list volume ===")
|
||||
L(Dp('list volume' & @CRLF & 'exit' & @CRLF, "vol"))
|
||||
|
||||
WinClose($hMain)
|
||||
Sleep(1500)
|
||||
EndIf
|
||||
|
||||
; --- 7. убрать VHD
|
||||
Cleanup("clean1")
|
||||
Local $verdict = "FAIL"
|
||||
If $fail = 0 Then $verdict = "PASS"
|
||||
L("RESULT: " & $verdict)
|
||||
L("DONE")
|
||||
FileClose($f)
|
||||
|
||||
Func _PartLetter($oWMI, $disk, $idx)
|
||||
Local $parts = $oWMI.ExecQuery("SELECT * FROM Win32_DiskPartition WHERE DiskIndex=" & $disk & " AND Index=" & $idx)
|
||||
If Not IsObj($parts) Then Return ""
|
||||
For $p In $parts
|
||||
Local $ld = $oWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $p.DeviceID & "'} WHERE AssocClass=Win32_LogicalDiskToPartition")
|
||||
If IsObj($ld) Then
|
||||
For $l In $ld
|
||||
Local $d = String($l.DeviceID)
|
||||
If StringLen($d) = 2 Then Return $d
|
||||
Next
|
||||
EndIf
|
||||
Next
|
||||
Return ""
|
||||
EndFunc
|
||||
|
||||
Func _DirCount($path)
|
||||
Local $o = @TempDir & "\pf_count.txt"
|
||||
FileDelete($o)
|
||||
RunWait(@ComSpec & ' /c dir /s /b /a-d "' & $path & '" > "' & $o & '" 2>nul', "", @SW_HIDE)
|
||||
Return _Lines($o)
|
||||
EndFunc
|
||||
|
||||
Func _IsoCount($path)
|
||||
Local $o = @TempDir & "\pf_iso.txt"
|
||||
FileDelete($o)
|
||||
RunWait(@ComSpec & ' /c dir /s /b /a-d "' & $path & '*.iso" > "' & $o & '" 2>nul', "", @SW_HIDE)
|
||||
Return _Lines($o)
|
||||
EndFunc
|
||||
|
||||
Func _Lines($file)
|
||||
If Not FileExists($file) Then Return 0
|
||||
Local $n = 0
|
||||
Local $h = FileOpen($file, 0)
|
||||
If $h = -1 Then Return 0
|
||||
While 1
|
||||
Local $l = FileReadLine($h)
|
||||
If @error Then ExitLoop
|
||||
If StringStripWS($l, 3) <> "" Then $n = $n + 1
|
||||
WEnd
|
||||
FileClose($h)
|
||||
FileDelete($file)
|
||||
Return $n
|
||||
EndFunc
|
||||
|
||||
Func _ComboCount($h)
|
||||
Local $hw = ControlGetHandle($h, "", "ComboBox1")
|
||||
If $hw = 0 Then Return 0
|
||||
Return _GUICtrlComboBox_GetCount($hw)
|
||||
EndFunc
|
||||
Reference in new issue
Block a user