From 13294b42bd5d03c2a8e502c82b2a0b607583bc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Wed, 3 Jul 2024 18:42:18 +0200 Subject: [PATCH 1/5] dasharo-compatibility: usb-hid-and-msc: Skip keyboard and HID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests if no keyboard or pikvm connected Signed-off-by: Michał Iwanicki --- .../usb-hid-and-msc-support.robot | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/dasharo-compatibility/usb-hid-and-msc-support.robot b/dasharo-compatibility/usb-hid-and-msc-support.robot index 1bb300291..39ca2367b 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 @@ -44,7 +44,7 @@ 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 + IF ${HAS_KEYBOARD} Should Contain ${out} Human Interface Device Should Contain ${out} Mass Storage Exit From Root User @@ -55,8 +55,9 @@ 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 + ${out}= Execute Command In Terminal + ... Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' } + IF ${HAS_KEYBOARD} Should Contain ${out} HIDClass Should Contain ${out} DiskDrive USB002.001 USB keyboard detected in FW @@ -64,6 +65,7 @@ USB002.001 USB keyboard detected in FW ... 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 @@ -129,3 +128,14 @@ USB003.002 Upload 1GB file on USB storage (Windows) 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 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 From 2ca1ee1809502d1d9fa78db12ac1010046dbfd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Wed, 3 Jul 2024 18:43:28 +0200 Subject: [PATCH 2/5] dasharo-compatibility: usb-hid-and-msc: Don't mount ISO if no pikvm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Iwanicki --- dasharo-compatibility/usb-hid-and-msc-support.robot | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dasharo-compatibility/usb-hid-and-msc-support.robot b/dasharo-compatibility/usb-hid-and-msc-support.robot index 39ca2367b..c9382cc0a 100644 --- a/dasharo-compatibility/usb-hid-and-msc-support.robot +++ b/dasharo-compatibility/usb-hid-and-msc-support.robot @@ -28,7 +28,9 @@ 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 + IF "${DUT_CONNECTION_METHOD}" == "pikvm" + Upload And Mount DTS Flash Iso + END Power On ${boot_menu}= Enter Boot Menu Tianocore And Return Construction Check That USB Devices Are Detected ${boot_menu} From f735b93322edf7f64b7fd9e9c5f9aaf06677f611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Thu, 4 Jul 2024 11:44:49 +0200 Subject: [PATCH 3/5] platform-configs: default & protectli: move ATTACHED_USB to default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Iwanicki --- platform-configs/include/default.robot | 1 + platform-configs/protectli-vp2410.robot | 2 -- platform-configs/protectli-vp2420.robot | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) 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 From 319a3e5fca5cf12d972311853f4dddd01c6ac1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Thu, 4 Jul 2024 16:39:17 +0200 Subject: [PATCH 4/5] dasharo-compatibility: usb: Skip tests with no keyboard or storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Iwanicki --- .../usb-hid-and-msc-support.robot | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/dasharo-compatibility/usb-hid-and-msc-support.robot b/dasharo-compatibility/usb-hid-and-msc-support.robot index c9382cc0a..c39549b88 100644 --- a/dasharo-compatibility/usb-hid-and-msc-support.robot +++ b/dasharo-compatibility/usb-hid-and-msc-support.robot @@ -28,9 +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 - IF "${DUT_CONNECTION_METHOD}" == "pikvm" - Upload And Mount DTS Flash Iso - END + 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} @@ -47,7 +45,7 @@ USB001.002 USB devices detected by OS (Ubuntu) Detect Or Install Package usbutils ${out}= Execute Command In Terminal lsusb -v | grep bInterfaceClass IF ${HAS_KEYBOARD} Should Contain ${out} Human Interface Device - Should Contain ${out} Mass Storage + IF ${HAS_USB_STORAGE} Should Contain ${out} Mass Storage Exit From Root User USB001.003 USB devices detected by OS (Windows) @@ -60,7 +58,7 @@ USB001.003 USB devices detected by OS (Windows) ${out}= Execute Command In Terminal ... Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' } IF ${HAS_KEYBOARD} Should Contain ${out} HIDClass - Should Contain ${out} DiskDrive + IF ${HAS_USB_STORAGE} Should Contain ${out} DiskDrive USB002.001 USB keyboard detected in FW [Documentation] Check whether the external USB keyboard is detected @@ -101,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 @@ -117,8 +116,9 @@ 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 @@ -141,3 +141,16 @@ Prepare USB HID Test Suite 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 From 2e687af6f6ce2370e2e5ec1b66e22cede133b21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Thu, 4 Jul 2024 16:49:59 +0200 Subject: [PATCH 5/5] dasharo-compatibility: usb-hid-msc: fix tests on Windows & Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Iwanicki --- .../usb-hid-and-msc-support.robot | 6 ++-- keywords.robot | 29 ++++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dasharo-compatibility/usb-hid-and-msc-support.robot b/dasharo-compatibility/usb-hid-and-msc-support.robot index c39549b88..2ccb22f98 100644 --- a/dasharo-compatibility/usb-hid-and-msc-support.robot +++ b/dasharo-compatibility/usb-hid-and-msc-support.robot @@ -124,11 +124,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} 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