Skip to content
Merged
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
74 changes: 74 additions & 0 deletions dasharo-compatibility/os-opnsense.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
*** 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


*** Test Cases ***
OPN001.503 Install OPNsense (serial output) on disk
[Documentation] Install OPNsense (serial output) from preseeded
... USB stick on disk. Make sure to use linux fatlabel command
... to rename installer ESP to OPNBOOT. Next, please refer to
... scripts/freebsd/preseed_opnsense.sh for OPNsense installer
... modification.
Power On
Boot OPNsense Installer
${installer_message}= Catenate Click OK, after test execution ends,
... connect to DUT via serial and continue manual installation.
Pause Execution ${installer_message}

OPN002.503 Boot OPNsense (serial output) from disk
[Documentation] Boot OPNsense (serial output) from disk.
Power On
Boot OPNsense

OPN003.503 Boot OPNsense (serial output) from disk after cold-boot
[Documentation] Boot OPNsense (serial output) from disk after cold-boot
@{supported_power_ctrls}= Create List RteCtrl sonoff
Skip If '${POWER_CTRL}' not in ${supported_power_ctrls}
Execute Cold Boot
${start_date}= Get Current Date
Boot OPNsense
${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}

OPN004.503 Boot OPNsense (serial output) from disk after warm-boot
[Documentation] Boot OPNsense (serial output) from disk after warm-boot
Power On
Boot OPNsense
Enter OPNsense Shell
Write Into Terminal poweroff
Power On
${start_date}= Get Current Date
Boot OPNsense
${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}

OPN005.503 Boot OPNsense (serial output) from disk after reboot
[Documentation] Boot OPNsense (serial output) from disk after reboot
Power On
Boot OPNsense
Enter OPNsense Shell
Write Into Terminal reboot
${start_date}= Get Current Date
Boot OPNsense
${end_date}= Get Current Date
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
Log To Console Reboot duration in seconds: ${delta_time}
103 changes: 103 additions & 0 deletions dasharo-compatibility/os-pfsense.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
*** 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


*** Test Cases ***
PFS001.502 Install pfSense LTS CE (serial output) on disk
[Documentation] Install pfSense LTS CE (serial output) from preseeded
... USB stick on disk. Refer to test case PFS006.502 for preseed.
Power On
Boot PfSense Installer
${installer_message}= Catenate Click OK, after test execution ends,
... connect to DUT via serial and continue manual installation.
Pause Execution ${installer_message}

PFS002.502 Boot pfSense LTS CE (serial output) from disk
[Documentation] Boot pfSense LTS CE (serial output) from disk.
Power On
Boot PfSense

PFS003.502 Boot pfSense LTS CE (serial output) from disk after cold-boot
[Documentation] Boot pfSense LTS CE (serial output) from disk after cold-boot
@{supported_power_ctrls}= Create List RteCtrl sonoff
Skip If '${POWER_CTRL}' not in ${supported_power_ctrls}
Execute Cold Boot
${start_date}= Get Current Date
Boot PfSense
${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}

PFS004.502 Boot pfSense LTS CE (serial output) from disk after warm-boot
[Documentation] Boot pfSense LTS CE (serial output) from disk after warm-boot
Power On
Boot PfSense
Enter PfSense Shell
Write Into Terminal poweroff
Power On
${start_date}= Get Current Date
Boot PfSense
${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}

PFS005.502 Boot pfSense LTS CE (serial output) from disk after reboot
[Documentation] Boot pfSense LTS CE (serial output) from disk after reboot
Power On
Boot PfSense
Enter PfSense Shell
Write Into Terminal reboot
${start_date}= Get Current Date
Boot PfSense
${end_date}= Get Current Date
${delta_time}= Subtract Date From Date ${end_date} ${start_date}
Log To Console Reboot duration in seconds: ${delta_time}

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

Power On
Boot PfSense Installer
Enter PfSense Rescue Shell
${awk_args}= Catenate SEPARATOR=${SPACE} -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; }'
Execute Command In Terminal
... awk ${awk_args} /usr/libexec/bsdinstall/zfsboot > /tmp/zfsboot
Execute Command In Terminal mount -u /
Execute Command In Terminal mv /tmp/zfsboot /usr/libexec/bsdinstall/zfsboot
Execute Command In Terminal chmod +x /usr/libexec/bsdinstall/zfsboot
Execute Command In Terminal sync
${output}= Execute Command In Terminal grep PFBOOT /usr/libexec/bsdinstall/zfsboot
Should Contain ${output} PFBOOT

PFS007.502 Boot pfSense Installer (serial output) into rescue shell
Power On
Boot PfSense Installer
Enter PfSense Rescue Shell
${output}= Execute Command In Terminal ls
Should Contain ${output} COPYRIGHT
Should Contain ${output} .profile
54 changes: 29 additions & 25 deletions keys.robot
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
*** Variables ***
${ARROW_UP}= \x1b\x5b\x41
${ARROW_DOWN}= \x1b\x5b\x42
${ARROW_RIGHT}= \x1b\x5b\x43
${ARROW_LEFT}= \x1b\x5b\x44
${F1}= \x1b\x4f\x50
${F2}= \x1b\x4f\x51
${F3}= \x1b\x4f\x52
${F4}= \x1b\x4f\x53
${F5}= \x1b\x5b\x31\x35\x7e
${F6}= \x1b\x5b\x31\x37\x7e
${F7}= \x1b\x5b\x31\x38\x7e
${F8}= \x1b\x5b\x31\x39\x7e
${F9}= \x1b\x5b\x32\x30\x7e
${F10}= \x1b\x5b\x32\x31\x7e
${F11}= \x1b\x5b\x32\x33\x7e
${F12}= \x1b\x5b\x32\x34\x7e
${CTRL_B}= \x02
${CTRL_C}= \x03
${CTRL_D}= \x04
${ESC}= \x1b
${ENTER}= \x0d
${BACKSPACE}= \x08
${KEY_SPACE}= \x20
${DELETE}= \x1b\x5b\x33\x7e
${KEY_PLUS}= \x2b
${ARROW_UP}= \x1b\x5b\x41
${ARROW_DOWN}= \x1b\x5b\x42
${ARROW_RIGHT}= \x1b\x5b\x43
${ARROW_LEFT}= \x1b\x5b\x44
${ARROW_UP_APP}= \x1b\x4f\x41
${ARROW_DOWN_APP}= \x1b\x4f\x42
${ARROW_RIGHT_APP}= \x1b\x4f\x43
${ARROW_LEFT_APP}= \x1b\x4f\x44
${F1}= \x1b\x4f\x50
${F2}= \x1b\x4f\x51
${F3}= \x1b\x4f\x52
${F4}= \x1b\x4f\x53
${F5}= \x1b\x5b\x31\x35\x7e
${F6}= \x1b\x5b\x31\x37\x7e
${F7}= \x1b\x5b\x31\x38\x7e
${F8}= \x1b\x5b\x31\x39\x7e
${F9}= \x1b\x5b\x32\x30\x7e
${F10}= \x1b\x5b\x32\x31\x7e
${F11}= \x1b\x5b\x32\x33\x7e
${F12}= \x1b\x5b\x32\x34\x7e
${CTRL_B}= \x02
${CTRL_C}= \x03
${CTRL_D}= \x04
${ESC}= \x1b
${ENTER}= \x0d
${BACKSPACE}= \x08
${KEY_SPACE}= \x20
${DELETE}= \x1b\x5b\x33\x7e
${KEY_PLUS}= \x2b
1 change: 1 addition & 0 deletions keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Resource lib/sleep-lib.robot
Resource lib/framework.robot
Resource lib/me.robot
Resource lib/network.robot
Resource lib/bsd.robot


*** Keywords ***
Expand Down
5 changes: 5 additions & 0 deletions lib/bios/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ def merge_lists(list1, list2):
"Power Management Options",
"CPU Throttling",
],
"PowerStateAfterPowerAcLoss": [
"Dasharo System Features",
"Power Management Options",
"Power state after",
],
}


Expand Down
9 changes: 7 additions & 2 deletions lib/bios/menus.robot
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,22 @@ Enter Submenu From Snapshot
... === Arguments ===
... - ``${menu}``: ``string`` - the submenu construction or snapshot
... - ``${option}``: ``string`` - the name of the submenu to enter
... - ``${cursor_key_mode}``: ``string`` - VT100 cursor key mode, APP for BSD
...
... === Return Value ===
... None
...
... === Effects ===
... - A setup submenu is entered
[Arguments] ${menu} ${option}
[Arguments] ${menu} ${option} ${cursor_key_mode}="ST"

${index}= Get Index Of Matching Option In Menu ${menu} ${option}
Should Not Be Equal As Integers ${index} -1 msg=Option ${option} not found in menu
Press Key N Times And Enter ${index} ${ARROW_DOWN}
IF ${cursor_key_mode} == "APP"
Press Key N Times And Enter ${index} ${ARROW_DOWN_APP}
ELSE
Press Key N Times And Enter ${index} ${ARROW_DOWN}
END

Enter Submenu From Snapshot And Return Construction
[Documentation] Enter given Setup Menu Tianocore option after entering
Expand Down
80 changes: 80 additions & 0 deletions lib/bsd.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
*** Settings ***
Library Collections
Resource ../keywords.robot
Resource ../lib/platform/power.robot


*** Keywords ***
Boot PfSense Installer
[Documentation] Run /EFI/BOOT/bootx64.efi file from PFEFI-labeled partition;
... Select console type vt100 and accept the license
Enter Boot From File
Enter Volume In File Explorer PFEFI
Execute File In File Explorer EFI
Execute File In File Explorer BOOT
Execute File In File Explorer bootx64.efi
Read From Terminal Until Console type [vt100]:
Write Into Terminal vt100
Read From Terminal Until [Accept]
Press Enter
Set Suite Variable ${BOOTED_OS_ID} ${ENV_ID_PFSENSE}
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py

Boot OPNsense Installer
[Documentation] Run /efi/boot/bootx64.efi file from OPNEFI-labeled partition;
Enter Boot From File
Enter Volume In File Explorer OPNEFI
Execute File In File Explorer efi
Execute File In File Explorer boot
Execute File In File Explorer bootx64.efi
Read From Terminal Until FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
Read From Terminal Until login:
Set Suite Variable ${BOOTED_OS_ID} ${ENV_ID_OPNSENSE}
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py

Enter PfSense Shell
Write Into Terminal 8
Read From Terminal Until ${DEVICE_OS_ROOT_PROMPT}
Set Prompt For Terminal ${DEVICE_OS_ROOT_PROMPT}

Enter PfSense Rescue Shell
${menu}= Read From Terminal Until <Cancel>
# end would be 5 but it's 3 due to two empty lines
${construction}= Parse Menu Snapshot Into Construction ${menu} 5 3
Enter Submenu From Snapshot
... ${construction}
... Rescue Shell Launch a shell for rescue operations
... "APP"
Set Prompt For Terminal ${DEVICE_OS_RESCUE_PROMPT}

Enter OPNsense Shell
Read From Terminal Until login:
Write Into Terminal ${DEVICE_OS_USERNAME}
Read From Terminal Until Password:
Write Into Terminal ${DEVICE_OS_PASSWORD}
Read From Terminal Until Enter an option:
Write Into Terminal 8
Read From Terminal Until ${DEVICE_OS_ROOT_PROMPT}
Set Prompt For Terminal ${DEVICE_OS_ROOT_PROMPT}

Boot PfSense
[Documentation] PFBOOT -> /efi/boot/bootx64.efi
Enter Boot From File
Enter Volume In File Explorer PFBOOT
Execute File In File Explorer efi
Execute File In File Explorer boot
Execute File In File Explorer bootx64.efi
Read From Terminal Until Enter an option:
Set Suite Variable ${BOOTED_OS_ID} ${ENV_ID_PFSENSE}
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py

Boot OPNsense
[Documentation] OPNBOOT -> /efi/boot/bootx64.efi
Enter Boot From File
Enter Volume In File Explorer OPNBOOT
Execute File In File Explorer efi
Execute File In File Explorer boot
Execute File In File Explorer bootx64.efi
Read From Terminal Until FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
Set Suite Variable ${BOOTED_OS_ID} ${ENV_ID_OPNSENSE}
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py
17 changes: 17 additions & 0 deletions lib/platform/power.robot
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,20 @@ Power Cycle Into Windows
Power Cycle Into Firmware Setup
Power On
Enter Setup Menu Tianocore

Execute Cold Boot
[Documentation] Performs cold boot, either with RTE relay or Sonoff
Power On
Set UEFI Option PowerStateAfterPowerAcLoss Powered On
Sleep 2
IF '${POWER_CTRL}' == 'RteCtrl'
Rte Psu Off
ELSE IF '${POWER_CTRL}' == 'sonoff'
Sonoff Off
END
Sleep 12
IF '${POWER_CTRL}' == 'RteCtrl'
Rte Psu On
ELSE IF '${POWER_CTRL}' == 'sonoff'
Sonoff On
END
12 changes: 12 additions & 0 deletions os-config/502-credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

DEVICE_OS_USERNAME = "root"
DEVICE_OS_PASSWORD = "pfsense"
DEVICE_OS_HOSTNAME = "pfSense.home.arpa"

DEVICE_OS_ROOT_PROMPT = (
f"[2.7.2-RELEASE][{DEVICE_OS_USERNAME}@{DEVICE_OS_HOSTNAME}]/{DEVICE_OS_USERNAME}"
)
DEVICE_OS_RESCUE_PROMPT = "#"
Loading
Loading