Skip to content

Commit f9e2c3a

Browse files
committed
os-bsd-anysense.sh basic *ense OS support test suite
scripts/freebsd/preseed_opnsense.sh: bsdinstall customization, can be applied for OPNsense, pfSense & FreeBSD. Requires running FreeBSD-based system. lib/bios/menus.robot - added pfSense terminal GUI encoding support. Signed-off-by: Mateusz Maciejewski <[email protected]>
1 parent 1f916b8 commit f9e2c3a

File tree

6 files changed

+217
-28
lines changed

6 files changed

+217
-28
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
*** Settings ***
2+
Library Collections
3+
Library Dialogs
4+
Library OperatingSystem
5+
Library Process
6+
Library String
7+
Library Telnet timeout=20 seconds connection_timeout=120 seconds
8+
Resource ../variables.robot
9+
Resource ../keywords.robot
10+
Resource ../keys.robot
11+
12+
# Log Out And Close Connection - elementary teardown keyword for all tests.
13+
Suite Setup Run Keywords
14+
... Prepare Test Suite
15+
Suite Teardown Run Keywords
16+
... Log Out And Close Connection
17+
Test Setup Run Keyword
18+
... Restore Initial DUT Connection Method
19+
20+
21+
*** Variables ***
22+
${PFSENSE_PROMPT}= [2.7.2-RELEASE][[email protected]]/root
23+
24+
25+
*** Test Cases ***
26+
PFS001.502 Boot pfSense LTS CE (serial output) from disk after cold-boot
27+
[Documentation] Boot pfSense LTS CE (serial output) from disk after cold-boot
28+
Power On
29+
# TBD
30+
31+
OPN001.503 Boot OPNsense (serial output) from disk after cold-boot
32+
[Documentation] Boot OPNsense (serial output) from disk after cold-boot
33+
Power On
34+
Boot OPN
35+
# TBD
36+
37+
PFS002.502 Boot pfSense LTS CE (serial output) from disk after warm-boot
38+
[Documentation] Boot pfSense LTS CE (serial output) from disk after warm-boot
39+
... does not use rtcwake!!!
40+
Power On
41+
Boot PfSense
42+
Enter Pf Sense Shell
43+
Write Into Terminal poweroff
44+
Power On
45+
Boot PfSense
46+
47+
PFS003.502 Boot pfSense LTS CE (serial output) from disk after reboot
48+
[Documentation] Boot pfSense LTS CE (serial output) from disk after reboot
49+
Power On
50+
Boot PfSense
51+
Enter Pf Sense Shell
52+
Write Into Terminal reboot
53+
Boot PfSense
54+
55+
PFS004.502 Boot pfSense LTS CE (serial output) Installer into rescue shell
56+
Power On
57+
Boot PfSense Installer
58+
Enter PfSense Rescue Shell
59+
${output}= Execute Command In Terminal ls
60+
Should Contain ${output} COPYRIGHT
61+
Should Contain ${output} .profile
62+
63+
PFS005.502 Preseed pfSense Installer
64+
Power On
65+
Boot PfSense Installer
66+
Enter PfSense Rescue Shell
67+
Execute Command In Terminal
68+
... 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
69+
Execute Command In Terminal mount -u /
70+
Execute Command In Terminal mv /tmp/zfsboot /usr/libexec/bsdinstall/zfsboot
71+
Execute Command In Terminal chmod +x /usr/libexec/bsdinstall/zfsboot
72+
Execute Command In Terminal sync
73+
${output}= Execute Command In Terminal grep PFBOOT /usr/libexec/bsdinstall/zfsboot
74+
Should Contain ${output} PFBOOT
75+
76+
# There's no OPN005.503, preseed requires another FreeBSD system
77+
78+
PFS006.502 Boot pfSense Installer
79+
Power On
80+
Boot PfSense Installer
81+
Execute Manual Step Click OK to PASS, after test ends, connect to DUT via serial and continue.
82+
83+
OPN006.503 Boot OPNsense Installer
84+
Power On
85+
Boot OPNsense Installer
86+
Execute Manual Step Click OK to PASS, after test ends, connect to DUT via serial and continue.
87+
88+
89+
*** Keywords ***
90+
Boot PfSense Installer
91+
[Documentation] Run /EFI/BOOT/bootx64.efi file from PFEFI-labeled partition;
92+
... Select console type vt100 and accept the license
93+
Enter Boot From File
94+
Enter Volume In File Explorer PFEFI
95+
Execute File In File Explorer EFI
96+
Execute File In File Explorer BOOT
97+
Execute File In File Explorer bootx64.efi
98+
Read From Terminal Until Console type [vt100]:
99+
Write Into Terminal vt100
100+
Read From Terminal Until [Accept]
101+
Press Enter
102+
103+
Boot OPNsense Installer
104+
[Documentation] Run /efi/boot/bootx64.efi file from OPNEFI-labeled partition;
105+
Enter Boot From File
106+
Enter Volume In File Explorer OPNEFI
107+
Execute File In File Explorer efi
108+
Execute File In File Explorer boot
109+
Execute File In File Explorer bootx64.efi
110+
Read From Terminal Until FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
111+
Read From Terminal Until login:
112+
113+
Enter PfSense Shell
114+
Write Into Terminal 8
115+
Read From Terminal Until ${PFSENSE_PROMPT}
116+
Set Prompt For Terminal ${PFSENSE_PROMPT}
117+
118+
Enter PfSense Rescue Shell
119+
${menu}= Read From Terminal Until <Cancel>
120+
# end would be 5 but it's 3 due to two empty lines
121+
${construction}= Parse Menu Snapshot Into Construction ${menu} 5 3
122+
Enter Submenu From Snapshot
123+
... ${construction}
124+
... Rescue Shell${SPACE_*_8}Launch a shell for rescue operations
125+
... "APP"
126+
Set Prompt For Terminal \#
127+
128+
Enter OPN Sense Rescue Shell:
129+
Read From Terminal FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
130+
Read From Terminal Until login:
131+
Write Into Terminal root
132+
Read From Terminal Until Password:
133+
Write Into Terminal opnsense
134+
Read From Terminal Until Enter an option:
135+
Write Into Terminal 8
136+
137+
Boot PfSense
138+
[Documentation] PFBOOT -> /efi/boot/bootx64.efi
139+
Enter Boot From File
140+
Enter Volume In File Explorer PFBOOT
141+
Execute File In File Explorer efi
142+
Execute File In File Explorer boot
143+
Execute File In File Explorer bootx64.efi
144+
Read From Terminal Until Enter an option:
145+
146+
Boot OPN Sense
147+
Enter Boot From File
148+
Enter Volume In File Explorer OPNBOOT
149+
Execute File In File Explorer efi
150+
Execute File In File Explorer boot
151+
Execute File In File Explorer bootx64.efi

keys.robot

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
*** Variables ***
2-
${ARROW_UP}= \x1b\x5b\x41
3-
${ARROW_DOWN}= \x1b\x5b\x42
4-
${ARROW_RIGHT}= \x1b\x5b\x43
5-
${ARROW_LEFT}= \x1b\x5b\x44
6-
${F1}= \x1b\x4f\x50
7-
${F2}= \x1b\x4f\x51
8-
${F3}= \x1b\x4f\x52
9-
${F4}= \x1b\x4f\x53
10-
${F5}= \x1b\x5b\x31\x35\x7e
11-
${F6}= \x1b\x5b\x31\x37\x7e
12-
${F7}= \x1b\x5b\x31\x38\x7e
13-
${F8}= \x1b\x5b\x31\x39\x7e
14-
${F9}= \x1b\x5b\x32\x30\x7e
15-
${F10}= \x1b\x5b\x32\x31\x7e
16-
${F11}= \x1b\x5b\x32\x33\x7e
17-
${F12}= \x1b\x5b\x32\x34\x7e
18-
${CTRL_B}= \x02
19-
${CTRL_C}= \x03
20-
${CTRL_D}= \x04
21-
${ESC}= \x1b
22-
${ENTER}= \x0d
23-
${BACKSPACE}= \x08
24-
${KEY_SPACE}= \x20
25-
${DELETE}= \x1b\x5b\x33\x7e
26-
${KEY_PLUS}= \x2b
2+
${ARROW_UP}= \x1b\x5b\x41
3+
${ARROW_DOWN}= \x1b\x5b\x42
4+
${ARROW_RIGHT}= \x1b\x5b\x43
5+
${ARROW_LEFT}= \x1b\x5b\x44
6+
${ARROW_UP_APP}= \x1b\x4f\x41
7+
${ARROW_DOWN_APP}= \x1b\x4f\x42
8+
${ARROW_RIGHT_APP}= \x1b\x4f\x43
9+
${ARROW_LEFT_APP}= \x1b\x4f\x44
10+
${F1}= \x1b\x4f\x50
11+
${F2}= \x1b\x4f\x51
12+
${F3}= \x1b\x4f\x52
13+
${F4}= \x1b\x4f\x53
14+
${F5}= \x1b\x5b\x31\x35\x7e
15+
${F6}= \x1b\x5b\x31\x37\x7e
16+
${F7}= \x1b\x5b\x31\x38\x7e
17+
${F8}= \x1b\x5b\x31\x39\x7e
18+
${F9}= \x1b\x5b\x32\x30\x7e
19+
${F10}= \x1b\x5b\x32\x31\x7e
20+
${F11}= \x1b\x5b\x32\x33\x7e
21+
${F12}= \x1b\x5b\x32\x34\x7e
22+
${CTRL_B}= \x02
23+
${CTRL_C}= \x03
24+
${CTRL_D}= \x04
25+
${ESC}= \x1b
26+
${ENTER}= \x0d
27+
${BACKSPACE}= \x08
28+
${KEY_SPACE}= \x20
29+
${DELETE}= \x1b\x5b\x33\x7e
30+
${KEY_PLUS}= \x2b

lib/bios/menus.robot

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,12 @@ Parse Menu Snapshot Into Construction
306306
@{construction}= Create List
307307
FOR ${line} IN @{menu_lines}
308308
# Replace multiple spaces with a single one
309-
${line}= Replace String Using Regexp ${line} ${SPACE}+ ${SPACE}
309+
# ${line}= Replace String Using Regexp ${line} ${SPACE}+ ${SPACE}
310310
# Remove leading and trailing spaces
311311
${line}= Strip String ${line}
312+
# Remove FreeBSD installer frames, this affect slicing process due to removing empty lines
313+
# ${line}= Remove String ${line} x x
314+
${line}= Remove String Using Regexp ${line} (x x)
312315
# Drop leading and trailing pipes (e.g. in One Time Boot Menu)
313316
${line}= Strip String ${line} characters=|
314317
# Remove leading and trailing spaces
@@ -420,17 +423,22 @@ Enter Submenu From Snapshot
420423
... === Arguments ===
421424
... - ``${menu}``: ``string`` - the submenu construction or snapshot
422425
... - ``${option}``: ``string`` - the name of the submenu to enter
426+
... - ``${cursor_key_mode}``: ``string`` - VT100 cursor key mode, APP for BSD
423427
...
424428
... === Return Value ===
425429
... None
426430
...
427431
... === Effects ===
428432
... - A setup submenu is entered
429-
[Arguments] ${menu} ${option}
433+
[Arguments] ${menu} ${option} ${cursor_key_mode}="ST"
430434

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

435443
Enter Submenu From Snapshot And Return Construction
436444
[Documentation] Enter given Setup Menu Tianocore option after entering

os-config/502-credentials.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]>
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
DEVICE_OS_USERNAME = "pfsense"
6+
DEVICE_OS_PASSWORD = "pfsense"
7+
DEVICE_OS_HOSTNAME = pfSense.home.arpa
8+
9+
DEVICE_OS_USER_PROMPT = f"{DEVICE_OS_USERNAME}@{DEVICE_OS_HOSTNAME}:~$"
10+
DEVICE_OS_ROOT_PROMPT = f"root@{DEVICE_OS_HOSTNAME}:/home/{DEVICE_OS_USERNAME}#"

os-config/environment-test-ids.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
# 4xx - Other
2121
ENV_ID_ESXI = "401" # ESXi
2222

23+
# 5xx - BSD
24+
ENV_ID_FREEBSD = "501"
25+
ENV_ID_PFSENSE = "502"
26+
ENV_ID_OPNSENSE = "503"
27+
2328
ENV_ID_OS_BOOTMENU_NAMES = {
2429
ENV_ID_UBUNTU: "Ubuntu",
2530
ENV_ID_FEDORA: "Fedora",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
echo FreeBSD+OPNsense bsdinstall modifier
4+
echo
5+
umount /mnt
6+
mount -w /dev/da0p4 /mnt
7+
ls -l /mnt/usr/libexec/bsdinstall/*zfs*
8+
awk -v sq="'" -v dq='"' '/^NEWFS_ESP=/ { print "NEWFS_ESP=" sq "newfs_msdos -L NONSENSE "dq"%si" dq sq; next; }; { print; }' /mnt/usr/libexec/bsdinstall/opnsense-zfs | less
9+
cat /mnt/usr/libexec/bsdinstall/opnsense-zfs | grep ESP
10+
11+
umount /mnt

0 commit comments

Comments
 (0)