Skip to content

Commit 559dfb1

Browse files
committed
*sense tests: sonoff power control and boot time measure
dasharo-compatibility/os-pfsense.robot: preseed test and boot time test cases added dasharo-compatibility/os-opnsense.robot: boot time measure tests lib/bios/menus.py: Power state after AC loss added lib/bsd.robot: new, separate file for installer OS & shell keywords os-config/50*.py: OPNsense & pfSense prompts & credentials, incl. installer scripts/freebsd.preseed_opnsene.sh: license header added Signed-off-by: Mateusz Maciejewski <[email protected]>
1 parent e6b10f9 commit 559dfb1

File tree

8 files changed

+151
-36
lines changed

8 files changed

+151
-36
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
22+
*** Test Cases ***
23+
OPN001.503 Install OPNsense (serial output) on disk
24+
[Documentation] Install OPNsense (serial output) from preseeded
25+
... USB stick on disk. Make sure to use linux fatlabel command
26+
... to rename installer ESP to OPNBOOT. Next, please refer to
27+
... scripts/freebsd/preseed_opnsense.sh for OPNsense installer
28+
... modification.
29+
Power On
30+
Boot OPNsense Installer
31+
${installer_message}= Catenate Click OK, after test execution ends,
32+
... connect to DUT via serial and continue manual installation.
33+
Pause Execution ${installer_message}
34+
35+
OPN002.503 Boot OPNsense CE (serial output) from disk
36+
[Documentation] Boot OPNsense (serial output) from disk.
37+
Power On
38+
Boot OPNsense
39+
40+
OPN003.503 Boot OPNsense (serial output) from disk after cold-boot
41+
[Documentation] Boot OPNsense (serial output) from disk after cold-boot
42+
@{supported_power_ctrls}= Create List RteCtrl sonoff
43+
Skip If '${POWER_CTRL}' not in ${supported_power_ctrls}
44+
Power On
45+
Set UEFI Option PowerStateAfterPowerAcLoss Powered On
46+
Sleep 2
47+
IF '${POWER_CTRL}' == 'RteCtrl'
48+
Rte Psu Off
49+
ELSE IF '${POWER_CTRL}' == 'sonoff'
50+
Sonoff Off
51+
END
52+
Sleep 12
53+
IF '${POWER_CTRL}' == 'RteCtrl'
54+
Rte Psu On
55+
ELSE IF '${POWER_CTRL}' == 'sonoff'
56+
Sonoff On
57+
END
58+
${start_date}= Get Current Date
59+
Boot OPNsense
60+
${end_date}= Get Current Date
61+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
62+
Log To Console Cold boot duration in seconds: ${delta_time}
63+
64+
OPN004.503 Boot OPNsense (serial output) from disk after warm-boot
65+
[Documentation] Boot OPNsense (serial output) from disk after warm-boot
66+
Power On
67+
Boot OPNsense
68+
Enter OPNsense Shell
69+
Write Into Terminal poweroff
70+
Power On
71+
${start_date}= Get Current Date
72+
Boot OPNsense
73+
${end_date}= Get Current Date
74+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
75+
Log To Console Warm boot duration in seconds: ${delta_time}
76+
77+
OPN005.503 Boot OPNsense (serial output) from disk after reboot
78+
[Documentation] Boot OPNsense (serial output) from disk after reboot
79+
Power On
80+
Boot OPNsense
81+
Enter OPNsense Shell
82+
Write Into Terminal reboot
83+
${start_date}= Get Current Date
84+
Boot OPNsense
85+
${end_date}= Get Current Date
86+
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
87+
Log To Console Reboot duration in seconds: ${delta_time}

dasharo-compatibility/os-pfsense.robot

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*** Settings ***
22
Library Collections
3-
Library Dialogs
43
Library DateTime
4+
Library Dialogs
55
Library OperatingSystem
66
Library Process
77
Library String
@@ -25,7 +25,7 @@ PFS001.502 Install pfSense LTS CE (serial output) on disk
2525
... USB stick on disk. Refer to test case PFS006.502 for preseed.
2626
Power On
2727
Boot PfSense Installer
28-
${installer_message}= Catenate Click OK, after test execution ends,
28+
${installer_message}= Catenate Click OK, after test execution ends,
2929
... connect to DUT via serial and continue manual installation.
3030
Pause Execution ${installer_message}
3131

@@ -36,17 +36,27 @@ PFS002.502 Boot pfSense LTS CE (serial output) from disk
3636

3737
PFS003.502 Boot pfSense LTS CE (serial output) from disk after cold-boot
3838
[Documentation] Boot pfSense LTS CE (serial output) from disk after cold-boot
39+
@{supported_power_ctrls}= Create List RteCtrl sonoff
40+
Skip If '${POWER_CTRL}' not in ${supported_power_ctrls}
3941
Power On
4042
Set UEFI Option PowerStateAfterPowerAcLoss Powered On
41-
Sleep 1
42-
Rte Psu Off
43-
Sleep 5
44-
Rte Psu On
43+
Sleep 2
44+
IF '${POWER_CTRL}' == 'RteCtrl'
45+
Rte Psu Off
46+
ELSE IF '${POWER_CTRL}' == 'sonoff'
47+
Sonoff Off
48+
END
49+
Sleep 12
50+
IF '${POWER_CTRL}' == 'RteCtrl'
51+
Rte Psu On
52+
ELSE IF '${POWER_CTRL}' == 'sonoff'
53+
Sonoff On
54+
END
4555
${start_date}= Get Current Date
4656
Boot PfSense
4757
${end_date}= Get Current Date
4858
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
49-
Log To Console Cold boot duration in seconds: ${delta_time}}
59+
Log To Console Cold boot duration in seconds: ${delta_time}
5060

5161
PFS004.502 Boot pfSense LTS CE (serial output) from disk after warm-boot
5262
[Documentation] Boot pfSense LTS CE (serial output) from disk after warm-boot
@@ -59,7 +69,7 @@ PFS004.502 Boot pfSense LTS CE (serial output) from disk after warm-boot
5969
Boot PfSense
6070
${end_date}= Get Current Date
6171
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
62-
Log To Console Warm boot duration in seconds: ${delta_time}}
72+
Log To Console Warm boot duration in seconds: ${delta_time}
6373

6474
PFS005.502 Boot pfSense LTS CE (serial output) from disk after reboot
6575
[Documentation] Boot pfSense LTS CE (serial output) from disk after reboot
@@ -71,19 +81,25 @@ PFS005.502 Boot pfSense LTS CE (serial output) from disk after reboot
7181
Boot PfSense
7282
${end_date}= Get Current Date
7383
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
74-
Log To Console Reboot duration in seconds: ${delta_time}}
75-
84+
Log To Console Reboot duration in seconds: ${delta_time}
7685

7786
PFS006.502 Preseed pfSense Installer
7887
[Documentation] Please use linux fatlabel program to rename ESP partition of
7988
... pfSense installer to PFEFI.
80-
Execute Manual Step Rename ESP partition of pfSense installer to PFEFI.
89+
${pfefi_message}= Catenate SEPARATOR=${SPACE} Rename ESP partition of pfSense
90+
... serial installer to PFEFI.\nOn Linux: (sudo) fatlabel /dev/sdX1 PFEFI
91+
Execute Manual Step ${pfefi_message}
92+
Execute Manual Step Connect pfSense serial installer USB stick to DUT.
8193

8294
Power On
8395
Boot PfSense Installer
8496
Enter PfSense Rescue Shell
97+
${awk_args}= Catenate SEPARATOR=${SPACE} -v sq="'" -v dq='"'
98+
... -v ROOT_LABEL=PFBOOT '/^NEWFS_ESP=/ { print "NEWFS_ESP="
99+
... sq "newfs_msdos -L " ROOT_LABEL " " dq "%s" dq sq; next; };
100+
... { print; }'
85101
Execute Command In Terminal
86-
... awk -v sq="'" -v dq='"' -v ROOT_LABEL=PFBOOT '/^NEWFS_ESP=/ { print "NEWFS_ESP=" sq "newfs_msdos -L " ROOT_LABEL " " dq "%s" dq sq; next; }; { print; }' /usr/libexec/bsdinstall/zfsboot > /tmp/zfsboot
102+
... awk ${awk_args} /usr/libexec/bsdinstall/zfsboot > /tmp/zfsboot
87103
Execute Command In Terminal mount -u /
88104
Execute Command In Terminal mv /tmp/zfsboot /usr/libexec/bsdinstall/zfsboot
89105
Execute Command In Terminal chmod +x /usr/libexec/bsdinstall/zfsboot
@@ -98,5 +114,3 @@ PFS007.502 Boot pfSense LTS CE (serial output) Installer into rescue shell
98114
${output}= Execute Command In Terminal ls
99115
Should Contain ${output} COPYRIGHT
100116
Should Contain ${output} .profile
101-
102-

lib/bios/menus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ def merge_lists(list1, list2):
220220
"PowerStateAfterPowerAcLoss": [
221221
"Dasharo System Features",
222222
"Power Management Options",
223-
"Power state after"
224-
]
223+
"Power state after",
224+
],
225225
}
226226

227227

lib/bsd.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Enter PfSense Rescue Shell
4242
${construction}= Parse Menu Snapshot Into Construction ${menu} 5 3
4343
Enter Submenu From Snapshot
4444
... ${construction}
45-
... Rescue Shell${SPACE * 8}Launch a shell for rescue operations
45+
... Rescue Shell${SPACE*8}Launch a shell for rescue operations
4646
... "APP"
47-
Set Prompt For Terminal ${DEVICE_RESCUE_PROMPT}
47+
Set Prompt For Terminal ${DEVICE_OS_RESCUE_PROMPT}
4848

4949
Enter OPNsense Shell
5050
Read From Terminal Until login:

os-config/502-credentials.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
DEVICE_OS_USERNAME = "pfsense"
5+
DEVICE_OS_USERNAME = "root"
66
DEVICE_OS_PASSWORD = "pfsense"
77
DEVICE_OS_HOSTNAME = "pfSense.home.arpa"
88

9-
DEVICE_OS_ROOT_PROMPT = f"[2.7.2-RELEASE][{DEVICE_OS_USERNAME}@{DEVICE_OS_HOSTNAME}]/root"
9+
DEVICE_OS_ROOT_PROMPT = (
10+
f"[2.7.2-RELEASE][{DEVICE_OS_USERNAME}@{DEVICE_OS_HOSTNAME}]/{DEVICE_OS_USERNAME}"
11+
)
1012
DEVICE_OS_RESCUE_PROMPT = "#"

os-config/503-credentials.py

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

scripts/freebsd/preseed_opnsense.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/sh
22

3+
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
37
LABEL=OPNBOOT
48
INSTALLER_ROOT_PARTITION=/dev/da0p4
59
INSTALLER_MOUNT_DIR=/mnt

test_cases.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9930,84 +9930,84 @@
99309930
{
99319931
"doc": {
99329932
"_id": "PFS001.502",
9933-
"name": "",
9933+
"name": "Install pfSense LTS CE (serial output) on disk",
99349934
"module": "Dasharo Compatibility"
99359935
}
99369936
},
99379937
{
99389938
"doc": {
99399939
"_id": "PFS002.502",
9940-
"name": "",
9940+
"name": "Boot pfSense LTS CE (serial output) from disk",
99419941
"module": "Dasharo Compatibility"
99429942
}
99439943
},
99449944
{
99459945
"doc": {
99469946
"_id": "PFS003.502",
9947-
"name": "",
9947+
"name": "Boot pfSense LTS CE (serial output) from disk after cold-boot",
99489948
"module": "Dasharo Compatibility"
99499949
}
99509950
},
99519951
{
99529952
"doc": {
99539953
"_id": "PFS004.502",
9954-
"name": "",
9954+
"name": "Boot pfSense LTS CE (serial output) from disk after warm-boot",
99559955
"module": "Dasharo Compatibility"
99569956
}
99579957
},
99589958
{
99599959
"doc": {
99609960
"_id": "PFS005.502",
9961-
"name": "",
9961+
"name": "Boot pfSense LTS CE (serial output) from disk after reboot",
99629962
"module": "Dasharo Compatibility"
99639963
}
99649964
},
99659965
{
99669966
"doc": {
99679967
"_id": "PFS006.502",
9968-
"name": "",
9968+
"name": "Preseed pfSense Installer",
99699969
"module": "Dasharo Compatibility"
99709970
}
99719971
},
99729972
{
99739973
"doc": {
99749974
"_id": "PFS007.502",
9975-
"name": "",
9975+
"name": "Boot pfSense LTS CE (serial output) Installer into rescue shell",
99769976
"module": "Dasharo Compatibility"
99779977
}
99789978
},
99799979
{
99809980
"doc": {
99819981
"_id": "OPN001.503",
9982-
"name": "",
9982+
"name": "Install OPNsense (serial output) from preseeded",
99839983
"module": "Dasharo Compatibility"
99849984
}
99859985
},
99869986
{
99879987
"doc": {
9988-
"_id": "PFS001.502",
9989-
"name": "",
9988+
"_id": "OPN002.502",
9989+
"name": "Boot OPNsense (serial output) from disk.",
99909990
"module": "Dasharo Compatibility"
99919991
}
99929992
},
99939993
{
99949994
"doc": {
9995-
"_id": "PFS001.502",
9996-
"name": "",
9995+
"_id": "OPN003.502",
9996+
"name": "Boot OPNsense (serial output) from disk after cold-boot",
99979997
"module": "Dasharo Compatibility"
99989998
}
99999999
},
1000010000
{
1000110001
"doc": {
10002-
"_id": "PFS001.502",
10003-
"name": "",
10002+
"_id": "OPN004.502",
10003+
"name": "Boot OPNsense (serial output) from disk after warm-boot",
1000410004
"module": "Dasharo Compatibility"
1000510005
}
1000610006
},
1000710007
{
1000810008
"doc": {
10009-
"_id": "PFS001.502",
10010-
"name": "",
10009+
"_id": "OPN005.502",
10010+
"name": "Boot OPNsense (serial output) from disk after reboot",
1001110011
"module": "Dasharo Compatibility"
1001210012
}
1001310013
}

0 commit comments

Comments
 (0)