diff --git a/dasharo-compatibility/usb-hid-and-msc-support.robot b/dasharo-compatibility/usb-hid-and-msc-support.robot index 1bb300291..2ccb22f98 100644 --- a/dasharo-compatibility/usb-hid-and-msc-support.robot +++ b/dasharo-compatibility/usb-hid-and-msc-support.robot @@ -18,7 +18,7 @@ Resource ../keys.robot # Required teardown keywords: # Log Out And Close Connection - elementary teardown keyword for all tests. Suite Setup Run Keyword -... Prepare Test Suite +... Prepare USB HID Test Suite Suite Teardown Run Keyword ... Log Out And Close Connection @@ -28,7 +28,7 @@ USB001.001 USB devices detected in FW [Documentation] Check whether USB devices are detected in Tianocore ... (edk2). Skip If not ${USB_DISKS_DETECTION_SUPPORT} USB001.001 not supported - Upload And Mount DTS Flash Iso + Skip If not ${HAS_USB_STORAGE} USB001.001 not supported Power On ${boot_menu}= Enter Boot Menu Tianocore And Return Construction Check That USB Devices Are Detected ${boot_menu} @@ -44,8 +44,8 @@ USB001.002 USB devices detected by OS (Ubuntu) Switch To Root User Detect Or Install Package usbutils ${out}= Execute Command In Terminal lsusb -v | grep bInterfaceClass - Should Contain ${out} Human Interface Device - Should Contain ${out} Mass Storage + IF ${HAS_KEYBOARD} Should Contain ${out} Human Interface Device + IF ${HAS_USB_STORAGE} Should Contain ${out} Mass Storage Exit From Root User USB001.003 USB devices detected by OS (Windows) @@ -55,15 +55,17 @@ USB001.003 USB devices detected by OS (Windows) Skip If not ${TESTS_IN_WINDOWS_SUPPORT} USB001.003 not supported Power On Login To Windows - ${out}= Execute Command In Terminal Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' } - Should Contain ${out} HIDClass - Should Contain ${out} DiskDrive + ${out}= Execute Command In Terminal + ... Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' } + IF ${HAS_KEYBOARD} Should Contain ${out} HIDClass + IF ${HAS_USB_STORAGE} Should Contain ${out} DiskDrive USB002.001 USB keyboard detected in FW [Documentation] Check whether the external USB keyboard is detected ... correctly by the firmware and all basic keys work ... according to their labels. [Tags] minimal-regression + Skip If not ${HAS_KEYBOARD} USB002.001 not supported Power On Enter UEFI Shell ${out}= Execute UEFI Shell Command devices @@ -71,12 +73,10 @@ USB002.001 USB keyboard detected in FW USB002.002 USB keyboard in OS (Ubuntu) [Documentation] Check whether the external USB keyboard is detected - ... correctly by the Linux OS and all basic keys work - ... according to their labels. - IF not ${USB_KEYBOARD_DETECTION_SUPPORT} - SKIP USB002.002 not supported - END - IF not ${TESTS_IN_UBUNTU_SUPPORT} SKIP USB002.002 not supported + ... correctly by the Linux OS. + Skip If not ${USB_KEYBOARD_DETECTION_SUPPORT} USB002.002 not supported + Skip If "${DEVICE_USB_KEYBOARD}" == "${EMPTY}" USB002.002 not supported + Skip If not ${TESTS_IN_UBUNTU_SUPPORT} USB002.002 not supported Power On Boot System Or From Connected Disk ubuntu Login To Linux @@ -87,10 +87,9 @@ USB002.002 USB keyboard in OS (Ubuntu) USB002.003 USB keyboard in OS (Windows) [Documentation] Check whether the external USB keyboard is detected ... correctly by the Windows OS. - IF not ${USB_KEYBOARD_DETECTION_SUPPORT} - SKIP USB002.003 not supported - END - IF not ${TESTS_IN_WINDOWS_SUPPORT} SKIP USB002.003 not supported + Skip If not ${USB_KEYBOARD_DETECTION_SUPPORT} USB002.003 not supported + Skip If not ${HAS_KEYBOARD} USB002.003 not supported + Skip If not ${TESTS_IN_WINDOWS_SUPPORT} USB002.003 not supported Power On Login To Windows ${out}= Execute Command In Terminal Get-CimInstance win32_KEYBOARD @@ -100,8 +99,9 @@ USB002.003 USB keyboard in OS (Windows) USB003.001 Upload 1GB file on USB storage (Ubuntu) [Documentation] Check whether the 1GB file can be transferred from the ... operating system to the USB storage. - IF not ${UPLOAD_ON_USB_SUPPORT} SKIP USB003.001 not supported - IF not ${TESTS_IN_UBUNTU_SUPPORT} SKIP USB003.001 not supported + Skip If not ${UPLOAD_ON_USB_SUPPORT} USB003.001 not supported + Skip If not ${HAS_USB_STORAGE} USB003.001 not supported + Skip If not ${TESTS_IN_UBUNTU_SUPPORT} USB003.001 not supported Power On Boot System Or From Connected Disk ubuntu Login To Linux @@ -116,16 +116,43 @@ USB003.001 Upload 1GB file on USB storage (Ubuntu) USB003.002 Upload 1GB file on USB storage (Windows) [Documentation] Check whether the 1GB file can be transferred from the ... operating system to the USB storage. - IF not ${UPLOAD_ON_USB_SUPPORT} SKIP USB003.002 not supported - IF not ${TESTS_IN_WINDOWS_SUPPORT} SKIP USB003.002 not supported + Skip If not ${UPLOAD_ON_USB_SUPPORT} USB003.002 not supported + Skip If not ${HAS_USB_STORAGE} USB003.002 not supported + Skip If not ${TESTS_IN_WINDOWS_SUPPORT} USB003.002 not supported Power On Login To 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} + + +*** Keywords *** +Prepare USB HID Test Suite + [Documentation] Prepare this test suite + Prepare Test Suite + IF "${DEVICE_USB_KEYBOARD}" != "${EMPTY}" or "${DUT_CONNECTION_METHOD}" == "pikvm" + Set Suite Variable $HAS_KEYBOARD ${TRUE} + ELSE + Set Suite Variable $HAS_KEYBOARD ${FALSE} + END + ${conf}= Get Current CONFIG ${CONFIG_LIST} + ${has_storage}= Evaluate "USB_Storage" in """${conf}""" + IF "${DUT_CONNECTION_METHOD}" == "pikvm" + Upload And Mount DTS Flash Iso + ${has_storage}= Set Variable ${TRUE} + END + IF "${ATTACHED_USB}" != "${EMPTY}" or ${has_storage} + Set Suite Variable $HAS_USB_STORAGE ${TRUE} + ELSE + Set Suite Variable $HAS_USB_STORAGE ${FALSE} + END + Skip If not ${HAS_KEYBOARD} and not ${HAS_USB_STORAGE} + ... Platform doesn't have USB keyboard or USB storage attached diff --git a/keywords.robot b/keywords.robot index 1c9617a7e..a5311e29a 100644 --- a/keywords.robot +++ b/keywords.robot @@ -1588,22 +1588,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 @@ -1619,9 +1631,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 diff --git a/platform-configs/include/default.robot b/platform-configs/include/default.robot index 55c5b145c..b24b7f399 100644 --- a/platform-configs/include/default.robot +++ b/platform-configs/include/default.robot @@ -66,6 +66,7 @@ ${DEVICE_AUDIO1_WIN}= ${EMPTY} ${WIFI_CARD_UBUNTU}= ${EMPTY} ${USB_MODEL}= ${EMPTY} ${USB_DEVICE}= ${EMPTY} +@{ATTACHED_USB}= ${EMPTY} ${FLASHROM_FLAGS}= ${EMPTY} diff --git a/platform-configs/protectli-vp2410.robot b/platform-configs/protectli-vp2410.robot index 68b1715fa..500c74359 100644 --- a/platform-configs/protectli-vp2410.robot +++ b/platform-configs/protectli-vp2410.robot @@ -17,8 +17,6 @@ ${CPU_MIN_FREQUENCY}= 300 # eMMC driver support ${E_MMC_NAME}= 8GTF4R -@{ATTACHED_USB}= @{EMPTY} - ${DMIDECODE_SERIAL_NUMBER}= N/A ${DMIDECODE_FIRMWARE_VERSION}= Dasharo (coreboot+UEFI) v ${DMIDECODE_PRODUCT_NAME}= VP2410 diff --git a/platform-configs/protectli-vp2420.robot b/platform-configs/protectli-vp2420.robot index fcf640546..0a91977bf 100644 --- a/platform-configs/protectli-vp2420.robot +++ b/platform-configs/protectli-vp2420.robot @@ -15,8 +15,6 @@ ${FLASHING_METHOD}= internal # eMMC driver support ${E_MMC_NAME}= 8GTF4R -@{ATTACHED_USB}= ${EMPTY} - ${DMIDECODE_SERIAL_NUMBER}= N/A ${DMIDECODE_FIRMWARE_VERSION}= Dasharo (coreboot+UEFI) v1.2.0 ${DMIDECODE_PRODUCT_NAME}= VP2420