Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions dasharo-compatibility/os-openwrt.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
*** Settings ***
Library Collections
Library DateTime
Library Dialogs
Library OperatingSystem
Library Process
Library String
Library Telnet timeout=20 seconds connection_timeout=120 seconds
Resource ../variables.robot
Resource ../keywords.robot
Resource ../keys.robot

# Log Out And Close Connection - elementary teardown keyword for all tests.
Suite Setup Run Keywords
... Prepare Test Suite
Suite Teardown Run Keywords
... Log Out And Close Connection
Test Setup Run Keyword
... Restore Initial DUT Connection Method

Default Tags semiauto


*** Test Cases ***
OWR001.206 Install operating system on disk (OpenWrt)
[Documentation] This test installs OpenWrt on NVMe drive using dd program.
... DTS is boot via iPXE and OpenWrt image is downloaded using wget.
... OPENWRT_IMAGE_FILE - core of file name
... OPENWRT_TARGET_DEVICE - target drive to be wiped out using dd (!)
[Tags] semiauto
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR001.206 not supported
Variable Should Exist ${OPENWRT_TARGET_DEVICE}
Variable Should Exist ${OPENWRT_IMAGE_FILE}
${selection}= Get Selection From User
... Caution! You are about to install OpenWrt on ${OPENWRT_TARGET_DEVICE} device. Are you sure?
... Yes, I'd like to wipe all the data existing on ${OPENWRT_TARGET_DEVICE} device.
... No, let's skip OpenWrt installation.
${contains_yes}= Run Keyword And Return Status Should Contain ${selection} Yes, I'd like to
Skip If not(${contains_yes}) OpenWrt installation on ${OPENWRT_TARGET_DEVICE} device skipped.
Power On
Make Sure That Network Boot Is Enabled
Boot Dasharo Tools Suite iPXE
# Starting SSH server
Write Bare Into Terminal K
Read From Terminal Until Press Enter to continue.
Press Enter
Enter Shell In DTS
VAR ${openwrt_image_gz}= ${OPENWRT_IMAGE_FILE} .gz separator=${EMPTY}
Remove File ${openwrt_image_gz}
Remove File ${OPENWRT_IMAGE_FILE}
VAR ${DEVICE_OS_USERNAME}= root scope=TEST
VAR ${DEVICE_OS_PASSWORD}= ${EMPTY} scope=TEST
Send File To DUT osfv-test-data/openwrt/${openwrt_image_gz} /${openwrt_image_gz}
Execute Linux Command gzip -cdk ${openwrt_image_gz} | dd of=/dev/${OPENWRT_TARGET_DEVICE} bs=1M
Execute Linux Command sync
Execute Reboot Command
Boot OpenWrt
# Disabling DHCP server of OpenWrt
Execute Command In Terminal /etc/init.d/odhcpd disable
Execute Command In Terminal /etc/init.d/odhcpd stop
# Enabling DHCP client for all LAN interfaces
Execute Command In Terminal uci set network.lan.proto="dhcp"
Execute Command In Terminal uci commit network
Execute Command In Terminal service network restart

OWR002.206 Boot operating system from disk (OpenWrt)
[Documentation] Boot installed OpenWrt from NVMe drive, check identity.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR002.206 not supported
Power On
Boot OpenWrt
${out}= Execute Command In Terminal uname -a
Should Contain ${out} OpenWrt

OWR003.206 Boot operating system from disk after cold-boot (OpenWrt)
[Documentation] Boot OpenWrt from hard disk after cold-boot.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR003.206 not supported
Power On
Boot OpenWrt
Execute Cold Boot
${start_date}= Get Current Date
Boot OpenWrt
${end_date}= Get Current Date
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
Log To Console Cold boot duration in seconds: ${delta_time}

OWR004.206 Boot operating system from disk after warm-boot (OpenWrt)
[Documentation] Boot OpenWrt from hard disk after warm-boot.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR004.206 not supported
Power On
Boot OpenWrt
Download File OpenWrt https://cloud.3mdeb.com/public.php/dav/files/Aqe5Xj24pkoYLwX /bin/rtcwake
Execute Command In Terminal chmod +x /bin/rtcwake
Perform Warmboot Using Rtcwake
${start_date}= Get Current Date
Boot OpenWrt
${end_date}= Get Current Date
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
Log To Console Warm boot duration in seconds: ${delta_time}

OWR005.206 Boot operating system from disk after reboot (OpenWrt)
[Documentation] Boot OpenWrt from hard disk after reboot.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR005.206 not supported
Power On
Boot OpenWrt
Execute Command In Terminal reboot
${start_date}= Get Current Date
Boot OpenWrt
${end_date}= Get Current Date
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
Log To Console Reboot duration in seconds: ${delta_time}

OWR006.206 Scan WiFi networks (OpenWrt)
[Documentation] Enable WiFi and scan for 3mdeb lab network.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR006.206 not supported
Power On
Boot OpenWrt
Enable WiFi OpenWrt
Scan WiFi For Network OpenWrt ${3_MDEB_WIFI_NETWORK}

OWR007.206 Ethernet controller detection (OpenWrt)
[Documentation] Check presence of ethernet controller using lspci.
... Install pciutils if missing. Controller name defined in OPENWRT_ETHERNET_CONTROLLER.
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR007.206 not supported
Variable Should Exist ${OPENWRT_ETHERNET_CONTROLLER}
Power On
Boot OpenWrt
Detect Or Install Package OpenWrt pciutils
${lspci_out}= Execute Command In Terminal lspci
Should Contain ${lspci_out} ${OPENWRT_ETHERNET_CONTROLLER}
1 change: 1 addition & 0 deletions keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Resource lib/framework.robot
Resource lib/me.robot
Resource lib/network.robot
Resource lib/bsd.robot
Resource lib/openwrt.robot


*** Keywords ***
Expand Down
83 changes: 83 additions & 0 deletions lib/openwrt.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
*** Settings ***
Library Collections
Resource ../keywords.robot
Resource ../lib/platform/power.robot


*** Keywords ***
Boot OpenWrt
[Documentation] Boot OpenWrt using Boot From File, kernel -> /efi/boot/bootx64.efi
Enter Boot From File
Enter Volume In File Explorer kernel
Execute File In File Explorer efi
Execute File In File Explorer boot
Execute File In File Explorer bootx64.efi
Read From Terminal Until Link is Up
Sleep 2
Press Enter
VAR ${BOOTED_OS_ID}= ${ENV_ID_OPENWRT} scope=GLOBAL
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py
Telnet.Set Prompt ${DEVICE_OS_ROOT_PROMPT} prompt_is_regexp=False

Detect Or Install Package OpenWrt
[Documentation] Check if package is installed using apk, attempt to install
... otherwise. Requires working internet connection.
[Arguments] ${package}
${apk_info_grep}= Execute Command In Terminal apk info | grep ${package}
# This double filtering is dirty fix for random 'apk' errors on output.
${apk_info_grep_second}= Get Lines Containing String ${apk_info_grep} ${package}
IF $apk_info_grep_second != $package
${apk_add_package}= Execute Command In Terminal apk add ${package}
Should Contain ${apk_add_package} OK
END

Enable WiFi OpenWrt
[Documentation] Enabling WiFi in OpenWrt with uci. Setting it up and
... waiting for wifi status output to be "up".
... Number of attempts defined in OPENWRT_WIFI_UP_ATTEMPTS.
Variable Should Exist ${OPENWRT_WIFI_UP_ATTEMPTS}
${out_show}= Execute Command In Terminal uci show wireless
Should Contain ${out_show} wireless.radio0=wifi-device
Execute Command In Terminal uci set wireless.radio0.country='PL'
Execute Command In Terminal uci set wireless.radio0.disabled='0'
Execute Command In Terminal uci commit wireless
Execute Command In Terminal wifi reload
Execute Command In Terminal wifi up
Press Enter
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_UP_ATTEMPTS}
TRY
${up_out}= Execute Command In Terminal wifi status | grep '"up":'
EXCEPT
Log To Console No prompt, sending Enter.
Press Enter
END
${contains}= Run Keyword And Return Status Should Contain ${up_out} "up": true,
IF ${contains} == ${TRUE} BREAK
END

Scan WiFi For Network OpenWrt
[Documentation] Sanning for WiFi network named by ESSID. Interface name extracted
... from wifi status command output. Number of attempts defined in OPENWRT_WIFI_SCAN_ATTEMPTS.
[Arguments] ${essid}
Variable Should Exist ${OPENWRT_WIFI_SCAN_ATTEMPTS}
VAR @{empty_list}= @{EMPTY}
${ifname_grep}= Execute Command In Terminal wifi status | grep "ifname"
${re_search}= Get Regexp Matches ${ifname_grep} (\\s*)(\"ifname\":\\s*)\"([^"]*)\", 3
Should Not Be Equal ${re_search} ${empty_list}
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_SCAN_ATTEMPTS}
${iwinfo_scan_out}= Execute Command In Terminal iwinfo ${re_search}[0] scanning | grep ${essid}
${contains}= Run Keyword And Return Status Should Contain ${iwinfo_scan_out} ${essid}
Pass Execution If ${contains} == ${TRUE} ${essid} network found in ${index} attempt(s).
END
Fail Searching for ${essid} network failed in ${OPENWRT_WIFI_SCAN_ATTEMPTS} attempts.

Download File OpenWrt
[Documentation] Download file from the given URL.
[Arguments] ${remote_url} ${local_path} ${timeout}=30
Wait Until Keyword Succeeds 5x 1s
... Check Internet Connection On Linux
${out}= Execute Linux Command
... wget --no-check-certificate -O ${local_path} ${remote_url}
... ${timeout}
Should Contain ${out} ${local_path}
Should Not Contain ${out} failed
5 changes: 5 additions & 0 deletions os-config/206-credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

DEVICE_OS_ROOT_PROMPT = f"root@OpenWrt:~#"
3 changes: 3 additions & 0 deletions os-config/environment-test-ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ENV_ID_QUBES = "203"
ENV_ID_TRENCHBOOT = "204"
ENV_ID_XCP_NG = "205"
ENV_ID_OPENWRT = "206"

# 3xx - Windows
ENV_ID_WINDOWS = "301"
Expand All @@ -33,6 +34,7 @@
ENV_ID_TRENCHBOOT: "trenchboot",
ENV_ID_ESXI: "ESXi",
ENV_ID_XCP_NG: "XCP-ng",
ENV_ID_OPENWRT: "OpenWrt",
}

ENV_ID_FRIENDLY_NAMES = {
Expand All @@ -46,4 +48,5 @@
ENV_ID_TRENCHBOOT: "TrenchBoot",
ENV_ID_ESXI: "ESXi",
ENV_ID_QUBES: "QubesOS",
ENV_ID_OPENWRT: "OpenWrt",
}
Loading
Loading