Skip to content

Commit

Permalink
dasharo-compatibility: usb-hid-msc: fix tests on Windows & Linux
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Iwanicki <[email protected]>
  • Loading branch information
m-iwanicki committed Jul 4, 2024
1 parent fa45f3f commit 5a4dd95
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
6 changes: 4 additions & 2 deletions dasharo-compatibility/usb-hid-and-msc-support.robot
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ USB003.002 Upload 1GB file on USB storage (Windows)
Generate 1GB File In Windows
# Work only with one attached USB storage
${drive_letter}= Get Drive Letter Of USB
Execute Command In Terminal Copy-Item -Path C:\\Users\\user\\test_file.txt ${drive_letter}:
Execute Command In Terminal
... Copy-Item -Path C:\\Users\\user\\test_file.txt ${drive_letter}: 120
${hash1}= Get Hash Of File test_file.txt
${hash2}= Get Hash Of File ${drive_letter}:\\test_file.txt
Execute Command In Terminal Remove-Item -Path C:\\Users\\user\\test_file.txt
Execute Command In Terminal Remove-Item -Path ${drive_letter}:\\test_file.txt
Execute Command In Terminal
... Remove-Item -Path ${drive_letter}:\\test_file.txt 120
Should Be Equal ${hash1} ${hash2}


Expand Down
29 changes: 21 additions & 8 deletions keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -1543,22 +1543,34 @@ Remove Entry From List

Generate 1GB File In Windows
[Documentation] Generates 1G file in Windows in .txt format.
Execute Command In Terminal
... if (Test-Path test_file.txt) { Remove-Item test_file.txt }
${out}= Execute Command In Terminal fsutil file createnew test_file.txt 1073741824
Should Contain ${out} is created

Get Drive Letter Of USB
[Documentation] Gets drive letter of attached USB, work with only one USB
... attached.
${drive_letter}= Execute Command In Terminal
... (Get-Volume | where drivetype -eq removable | where filesystemtype -eq FAT32).driveletter
${drive_letter}= Fetch From Left ${drive_letter} \r
[Documentation] Gets drive letter of attached USB, returns first letter
... on list.
${drive_letter_cmd}= Set Variable
... (Get-Volume | where DriveType -eq removable | where FileSystemType -eq FAT32).DriveLetter
${drive_count}= Execute Command In Terminal ${drive_letter_cmd}.Count
${drive_count}= Fetch From Right ${drive_count} \n
IF ${drive_count} > 0
${drive_letter}= Execute Command In Terminal
... ${drive_letter_cmd}\[0\]
ELSE
Fail Couldn't find any USB drive letter
END
${drive_letter}= Fetch From Right ${drive_letter} \n
RETURN ${drive_letter}

Get Hash Of File
[Documentation] Gets line with hash of file.
[Arguments] ${path_file}
${out}= Execute Command In Terminal Get-FileHash -Path ${path_file} | Format-List
${hash}= Get Lines Containing String ${out} Hash
${start_index}= Call Method ${out} rindex Hash
${hash}= Get Substring ${out} ${start_index}
${hash}= Fetch From Left ${hash} \r
RETURN ${hash}

Identify Path To USB
Expand All @@ -1574,9 +1586,10 @@ Identify Path To USB
Set Local Variable ${usb_disk} ${disk}
IF '${model_name}' == '${USB_MODEL}' BREAK
END
${out}= Execute Linux Command lsblk | grep ${usb_disk} | grep part | cat
${out}= Execute Linux Command
... lsblk --list --noheadings --output NAME,TYPE,PATH | grep ${usb_disk} | grep part
${split}= Split String ${out}
${path_to_usb}= Get From List ${split} 7
${path_to_usb}= Get From List ${split} 2
RETURN ${path_to_usb}

Get Intel ME Mode State
Expand Down

0 comments on commit 5a4dd95

Please sign in to comment.