Skip to content

Commit 53cb035

Browse files
committed
dasharo-compatibility/os-openwrt.robot: OpenWRT automation
ENV_ID: 207, test naming: OWR*.207 lib/openwrt.robot: OpenWrt keyword library Automated installation, (re)boots with time measure, WiFi scan, Ethernet controler detection. Pre-build rtcwake static binary provided via file server (warmboot test dependency). Signed-off-by: Mateusz Maciejewski <[email protected]>
1 parent 84f4918 commit 53cb035

File tree

8 files changed

+286
-0
lines changed

8 files changed

+286
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
*** Settings ***
2+
Library Collections
3+
Library DateTime
4+
Library Dialogs
5+
Library OperatingSystem
6+
Library Process
7+
Library String
8+
Library Telnet timeout=20 seconds connection_timeout=120 seconds
9+
Resource ../variables.robot
10+
Resource ../keywords.robot
11+
Resource ../keys.robot
12+
13+
# Log Out And Close Connection - elementary teardown keyword for all tests.
14+
Suite Setup Run Keywords
15+
... Prepare Test Suite
16+
Suite Teardown Run Keywords
17+
... Log Out And Close Connection
18+
Test Setup Run Keyword
19+
... Restore Initial DUT Connection Method
20+
21+
Default Tags semiauto
22+
23+
24+
*** Test Cases ***
25+
OWR001.207 Install operating system on disk (OpenWrt)
26+
[Documentation] This test installs OpenWrt on NVMe drive using dd program.
27+
... DTS is boot via iPXE and OpenWrt image is downloaded using wget.
28+
... OPENWRT_IMAGE_FILE - core of file name
29+
... OPENWRT_TARGET_DEVICE - target drive to be wiped out using dd (!)
30+
[Tags] semiauto
31+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR001.207 not supported
32+
Variable Should Exist ${OPENWRT_TARGET_DEVICE}
33+
Variable Should Exist ${OPENWRT_IMAGE_FILE}
34+
${selection}= Get Selection From User
35+
... Caution! You are about to install OpenWrt on ${OPENWRT_TARGET_DEVICE} device. Are you sure?
36+
... Yes, I'd like to wipe all the data existing on ${OPENWRT_TARGET_DEVICE} device.
37+
... No, let's skip OpenWrt installation.
38+
${contains_yes}= Run Keyword And Return Status Should Contain ${selection} Yes, I'd like to
39+
Skip If not(${contains_yes}) OpenWrt installation on ${OPENWRT_TARGET_DEVICE} device skipped.
40+
Power On
41+
Make Sure That Network Boot Is Enabled
42+
Boot Dasharo Tools Suite iPXE
43+
# Starting SSH server
44+
Write Bare Into Terminal K
45+
Read From Terminal Until Press Enter to continue.
46+
Press Enter
47+
Enter Shell In DTS
48+
VAR ${openwrt_image_gz}= ${OPENWRT_IMAGE_FILE} .gz separator=${EMPTY}
49+
Remove File ${openwrt_image_gz}
50+
Remove File ${OPENWRT_IMAGE_FILE}
51+
VAR ${DEVICE_OS_USERNAME}= root scope=TEST
52+
VAR ${DEVICE_OS_PASSWORD}= ${EMPTY} scope=TEST
53+
Send File To DUT osfv-test-data/openwrt/${openwrt_image_gz} /${openwrt_image_gz}
54+
Execute Linux Command gzip -cdk ${openwrt_image_gz} | dd of=/dev/${OPENWRT_TARGET_DEVICE} bs=1M
55+
Execute Linux Command sync
56+
Execute Reboot Command
57+
Boot OpenWrt
58+
# Disabling DHCP server of OpenWrt
59+
Execute Command In Terminal /etc/init.d/odhcpd disable
60+
Execute Command In Terminal /etc/init.d/odhcpd stop
61+
# Enabling DHCP client for all LAN interfaces
62+
Execute Command In Terminal uci set network.lan.proto="dhcp"
63+
Execute Command In Terminal uci commit network
64+
Execute Command In Terminal service network restart
65+
66+
OWR002.207 Boot operating system from disk (OpenWrt)
67+
[Documentation] Boot installed OpenWrt from NVMe drive, check identity.
68+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR002.207 not supported
69+
Power On
70+
Boot OpenWrt
71+
${out}= Execute Command In Terminal uname -a
72+
Should Contain ${out} OpenWrt
73+
74+
OWR003.207 Boot operating system from disk after cold-boot (OpenWrt)
75+
[Documentation] Boot OpenWrt from hard disk after cold-boot.
76+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR003.207 not supported
77+
Power On
78+
Boot OpenWrt
79+
Execute Cold Boot
80+
${start_date}= Get Current Date
81+
Boot OpenWrt
82+
${end_date}= Get Current Date
83+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
84+
Log To Console Cold boot duration in seconds: ${delta_time}
85+
86+
OWR004.207 Boot operating system from disk after warm-boot (OpenWrt)
87+
[Documentation] Boot OpenWrt from hard disk after warm-boot.
88+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR004.207 not supported
89+
Power On
90+
Boot OpenWrt
91+
Download File OpenWrt https://cloud.3mdeb.com/public.php/dav/files/Aqe5Xj24pkoYLwX /bin/rtcwake
92+
Execute Command In Terminal chmod +x /bin/rtcwake
93+
Perform Warmboot Using Rtcwake
94+
${start_date}= Get Current Date
95+
Boot OpenWrt
96+
${end_date}= Get Current Date
97+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
98+
Log To Console Warm boot duration in seconds: ${delta_time}
99+
100+
OWR005.207 Boot operating system from disk after reboot (OpenWrt)
101+
[Documentation] Boot OpenWrt from hard disk after reboot.
102+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR005.207 not supported
103+
Power On
104+
Boot OpenWrt
105+
Execute Command In Terminal reboot
106+
${start_date}= Get Current Date
107+
Boot OpenWrt
108+
${end_date}= Get Current Date
109+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
110+
Log To Console Reboot duration in seconds: ${delta_time}
111+
112+
OWR006.207 Scan WiFi networks (OpenWrt)
113+
[Documentation] Enable WiFi and scan for 3mdeb lab network.
114+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR006.207 not supported
115+
Power On
116+
Boot OpenWrt
117+
Enable WiFi OpenWrt
118+
Scan WiFi For Network OpenWrt ${3_MDEB_WIFI_NETWORK}
119+
120+
OWR007.207 Ethernet controller detection (OpenWrt)
121+
[Documentation] Check presence of ethernet controller using lspci.
122+
... Install pciutils if missing. Controller name defined in OPENWRT_ETHERNET_CONTROLLER.
123+
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR007.207 not supported
124+
Variable Should Exist ${OPENWRT_ETHERNET_CONTROLLER}
125+
Power On
126+
Boot OpenWrt
127+
Detect Or Install Package OpenWrt pciutils
128+
${lspci_out}= Execute Command In Terminal lspci
129+
Should Contain ${lspci_out} ${OPENWRT_ETHERNET_CONTROLLER}

keywords.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Resource lib/framework.robot
1616
Resource lib/me.robot
1717
Resource lib/network.robot
1818
Resource lib/bsd.robot
19+
Resource lib/openwrt.robot
1920

2021

2122
*** Keywords ***

lib/openwrt.robot

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
*** Settings ***
2+
Library Collections
3+
Resource ../keywords.robot
4+
Resource ../lib/platform/power.robot
5+
6+
7+
*** Keywords ***
8+
Boot OpenWrt
9+
[Documentation] Boot OpenWrt using Boot From File, kernel -> /efi/boot/bootx64.efi
10+
Enter Boot From File
11+
Enter Volume In File Explorer kernel
12+
Execute File In File Explorer efi
13+
Execute File In File Explorer boot
14+
Execute File In File Explorer bootx64.efi
15+
Read From Terminal Until Link is Up
16+
Sleep 2
17+
Press Enter
18+
VAR ${BOOTED_OS_ID}= ${ENV_ID_OPENWRT} scope=GLOBAL
19+
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py
20+
Telnet.Set Prompt ${DEVICE_OS_ROOT_PROMPT} prompt_is_regexp=False
21+
22+
Detect Or Install Package OpenWrt
23+
[Documentation] Check if package is installed using apk, attempt to install
24+
... otherwise. Requires working internet connection.
25+
[Arguments] ${package}
26+
${apk_info_grep}= Execute Command In Terminal apk info | grep ${package}
27+
# This double filtering is dirty fix for random 'apk' errors on output.
28+
${apk_info_grep_second}= Get Lines Containing String ${apk_info_grep} ${package}
29+
IF $apk_info_grep_second != $package
30+
${apk_add_package}= Execute Command In Terminal apk add ${package}
31+
Should Contain ${apk_add_package} OK
32+
END
33+
34+
Enable WiFi OpenWrt
35+
[Documentation] Enabling WiFi in OpenWrt with uci. Setting it up and
36+
... waiting for wifi status output to be "up".
37+
... Number of attempts defined in OPENWRT_WIFI_UP_ATTEMPTS.
38+
Variable Should Exist ${OPENWRT_WIFI_UP_ATTEMPTS}
39+
${out_show}= Execute Command In Terminal uci show wireless
40+
Should Contain ${out_show} wireless.radio0=wifi-device
41+
Execute Command In Terminal uci set wireless.radio0.country='PL'
42+
Execute Command In Terminal uci set wireless.radio0.disabled='0'
43+
Execute Command In Terminal uci commit wireless
44+
Execute Command In Terminal wifi reload
45+
Execute Command In Terminal wifi up
46+
Press Enter
47+
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_UP_ATTEMPTS}
48+
TRY
49+
${up_out}= Execute Command In Terminal wifi status | grep '"up":'
50+
EXCEPT
51+
Log To Console No prompt, sending Enter.
52+
Press Enter
53+
END
54+
${contains}= Run Keyword And Return Status Should Contain ${up_out} "up": true,
55+
IF ${contains} == ${TRUE} BREAK
56+
END
57+
58+
Scan WiFi For Network OpenWrt
59+
[Documentation] Sanning for WiFi network named by ESSID. Interface name extracted
60+
... from wifi status command output. Number of attempts defined in OPENWRT_WIFI_SCAN_ATTEMPTS.
61+
[Arguments] ${essid}
62+
Variable Should Exist ${OPENWRT_WIFI_SCAN_ATTEMPTS}
63+
VAR @{empty_list}= @{EMPTY}
64+
${ifname_grep}= Execute Command In Terminal wifi status | grep "ifname"
65+
${re_search}= Get Regexp Matches ${ifname_grep} (\\s*)(\"ifname\":\\s*)\"([^"]*)\", 3
66+
Should Not Be Equal ${re_search} ${empty_list}
67+
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_SCAN_ATTEMPTS}
68+
${iwinfo_scan_out}= Execute Command In Terminal iwinfo ${re_search}[0] scanning | grep ${essid}
69+
${contains}= Run Keyword And Return Status Should Contain ${iwinfo_scan_out} ${essid}
70+
Pass Execution If ${contains} == ${TRUE} ${essid} network found in ${index} attempt(s).
71+
END
72+
Fail Searching for ${essid} network failed in ${OPENWRT_WIFI_SCAN_ATTEMPTS} attempts.
73+
74+
Download File OpenWrt
75+
[Documentation] Download file from the given URL.
76+
[Arguments] ${remote_url} ${local_path} ${timeout}=30
77+
Wait Until Keyword Succeeds 5x 1s
78+
... Check Internet Connection On Linux
79+
${out}= Execute Linux Command
80+
... wget --no-check-certificate -O ${local_path} ${remote_url}
81+
... ${timeout}
82+
Should Contain ${out} ${local_path}
83+
Should Not Contain ${out} failed

os-config/207-credentials.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
DEVICE_OS_ROOT_PROMPT = f"root@OpenWrt:~#"

os-config/environment-test-ids.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ENV_ID_TRENCHBOOT = "204"
1616
ENV_ID_XCP_NG = "205"
1717
ENV_ID_ZARHUS = "206"
18+
ENV_ID_OPENWRT = "207"
1819

1920
# 3xx - Windows
2021
ENV_ID_WINDOWS = "301"
@@ -36,6 +37,7 @@
3637
ENV_ID_XCP_NG: "XCP-ng",
3738
# Or 'ZarhusOS A' and 'ZarhusOS B' if using A/B update feature
3839
ENV_ID_ZARHUS: "ZarhusOS",
40+
ENV_ID_OPENWRT: "OpenWrt",
3941
}
4042

4143
ENV_ID_FRIENDLY_NAMES = {
@@ -50,4 +52,5 @@
5052
ENV_ID_ESXI: "ESXi",
5153
ENV_ID_QUBES: "QubesOS",
5254
ENV_ID_ZARHUS: "ZarhusOS",
55+
ENV_ID_OPENWRT: "OpenWrt",
5356
}

platform-configs/include/default.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ ${TESTS_IN_WINDOWS_SUPPORT}= ${FALSE}
8888
${TESTS_IN_METATB_SUPPORT}= ${FALSE}
8989
${TESTS_IN_HEADS_SUPPORT}= ${FALSE}
9090
${TESTS_IN_FEDORA_SUPPORT}= ${FALSE}
91+
${TESTS_IN_OPENWRT_SUPPORT}= ${FALSE}
9192

9293
# Regression test flags
9394
${DASHARO_SECURITY_MENU_SUPPORT}= ${FALSE}
@@ -265,6 +266,13 @@ ${CAPSULE_UPDATE_SUPPORT}= ${FALSE}
265266
# Test module: trenchboot
266267
${TRENCHBOOT_SUPPORT}= ${FALSE}
267268

269+
# OpenWRT-specific variables
270+
${OPENWRT_IMAGE_FILE}= ${TBD}
271+
${OPENWRT_TARGET_DEVICE}= ${TBD}
272+
${OPENWRT_ETHERNET_CONTROLLER}= ${TBD}
273+
${OPENWRT_WIFI_UP_ATTEMPTS}= ${TBD}
274+
${OPENWRT_WIFI_SCAN_ATTEMPTS}= ${TBD}
275+
268276
# Test cases iterations number
269277
# Booting OS from USB stick test cases
270278
${BOOT_FROM_USB_ITERATIONS_NUMBER}= 0

platform-configs/include/protectli-common.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ${TESTS_IN_FIRMWARE_SUPPORT}= ${TRUE}
4242
${TESTS_IN_UBUNTU_SUPPORT}= ${TRUE}
4343
${TESTS_IN_WINDOWS_SUPPORT}= ${TRUE}
4444
${TESTS_IN_ESXI_SUPPORT}= ${TRUE}
45+
${TESTS_IN_OPENWRT_SUPPORT}= ${TRUE}
4546

4647
# Regression test flags
4748
${DASHARO_USB_MENU_SUPPORT}= ${TRUE}
@@ -142,6 +143,13 @@ ${STABILITY_DETECTION_WARMBOOT_ITERATIONS}= 2
142143
${STABILITY_DETECTION_REBOOT_ITERATIONS}= 5
143144
${STABILITY_DETECTION_SUSPEND_ITERATIONS}= 5
144145

146+
# OpenWRT-specific variables
147+
${OPENWRT_IMAGE_FILE}= openwrt_combined_efi.img
148+
${OPENWRT_TARGET_DEVICE}= nvme0n1
149+
${OPENWRT_ETHERNET_CONTROLLER}= Intel Corporation Ethernet Controller
150+
${OPENWRT_WIFI_UP_ATTEMPTS}= 512
151+
${OPENWRT_WIFI_SCAN_ATTEMPTS}= 8
152+
145153

146154
*** Keywords ***
147155
Power On

test_cases.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5236,6 +5236,55 @@
52365236
"module": "Dasharo Compatibility"
52375237
}
52385238
},
5239+
{
5240+
"doc": {
5241+
"_id": "OWR001.207",
5242+
"name": "Install operating system on disk (OpenWrt)",
5243+
"module": "Dasharo Compatibility"
5244+
}
5245+
},
5246+
{
5247+
"doc": {
5248+
"_id": "OWR002.207",
5249+
"name": "Boot operating system from disk (OpenWrt)",
5250+
"module": "Dasharo Compatibility"
5251+
}
5252+
},
5253+
{
5254+
"doc": {
5255+
"_id": "OWR003.207",
5256+
"name": "Boot operating system from disk after cold-boot (OpenWrt)",
5257+
"module": "Dasharo Compatibility"
5258+
}
5259+
},
5260+
{
5261+
"doc": {
5262+
"_id": "OWR004.207",
5263+
"name": "Boot operating system from disk after warm-boot (OpenWrt)",
5264+
"module": "Dasharo Compatibility"
5265+
}
5266+
},
5267+
{
5268+
"doc": {
5269+
"_id": "OWR005.207",
5270+
"name": "Boot operating system from disk after reboot (OpenWrt)",
5271+
"module": "Dasharo Compatibility"
5272+
}
5273+
},
5274+
{
5275+
"doc": {
5276+
"_id": "OWR006.207",
5277+
"name": "Scan WiFi networks (OpenWrt)",
5278+
"module": "Dasharo Compatibility"
5279+
}
5280+
},
5281+
{
5282+
"doc": {
5283+
"_id": "OWR007.207",
5284+
"name": "Ethernet controller detection (OpenWrt)",
5285+
"module": "Dasharo Compatibility"
5286+
}
5287+
},
52395288
{
52405289
"doc": {
52415290
"_id": "PFS001.001",

0 commit comments

Comments
 (0)