Skip to content

Commit ac1fae8

Browse files
committed
Add firmware update robot test, update renode configs
1 parent 3cb9846 commit ac1fae8

File tree

7 files changed

+157
-56
lines changed

7 files changed

+157
-56
lines changed

.github/workflows/integration_tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
sleep 2
5353
5454
- name: Run tests
55+
timeout-minutes: 10
5556
run: renode-test agp.robot
5657

5758
- name: Archive test results
@@ -63,3 +64,7 @@ jobs:
6364
report.html
6465
log.html
6566
robot_output.xml
67+
cmd.stdout
68+
cmd.stderr
69+
agp_uart.txt
70+
agp_renode.log

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# robot framework
2+
agp_logs/
3+
log.html
4+
report.html
5+
results-agp.robot.xml
6+
robot_output.xml
7+
snapshots

agp.robot

Lines changed: 141 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,114 +3,199 @@ Documentation Integration tests for air-gradient-pro bootloader, firmware and
33
Default Tags agp
44
Library Process
55

6+
# These are the defaults provided by renode, automatically set if not supplied
7+
Suite Setup AGP Suite Setup
8+
Suite Teardown Teardown
9+
Test Setup AGP Test Setup
10+
Test Teardown Test Teardown
11+
Resource ${RENODEKEYWORDS}
12+
613
*** Variables ***
714
# Firmware configs
815
${AIR_GRADIENT_MAC_ADDRESS} 02:00:04:03:07:04
916
${AIR_GRADIENT_IP_ADDRESS} 192.0.2.80
1017
${AIR_GRADIENT_DEVICE_ID} 255
18+
${AIR_GRADIENT_DEVICE_PORT} 32101
1119
${AIR_GRADIENT_LOG} TRACE
1220
# Test vars
1321
${CLI} ${CURDIR}/host_tools/air-gradient-cli/target/x86_64-unknown-linux-gnu/release/air-gradient
1422
${AGP_RESC} ${CURDIR}/renode/agp.resc
23+
${FW_IMAGE} ${CURDIR}/firmware/target/agp_images.cpio
1524
${UART} sysbus.usart6
16-
${UART_TIMEOUT} 10
25+
${UART_TIMEOUT} 30
1726
${PING_TIMEOUT} 5
27+
${VERBOSE_LOGGING_DIR} ${CURDIR}/agp_logs
28+
${VERBOSE_LOGGING_ENABLED} True
29+
${RENODE_LOG_LEVEL} 2
1830

1931
*** Keywords ***
32+
AGP Suite Setup
33+
Setup
34+
Build System
35+
36+
AGP Test Setup
37+
${test_name} = Replace String ${TEST NAME} ${SPACE} _
38+
Set Test Variable \${TEST_NAME} ${test_name}
39+
Test Setup
40+
Prepare Machine
41+
2042
Build Firmware
21-
Set environment variable AIR_GRADIENT_MAC_ADDRESS ${AIR_GRADIENT_MAC_ADDRESS}
22-
Set environment variable AIR_GRADIENT_IP_ADDRESS ${AIR_GRADIENT_IP_ADDRESS}
23-
Set environment variable AIR_GRADIENT_DEVICE_ID ${AIR_GRADIENT_DEVICE_ID}
24-
Set environment variable AIR_GRADIENT_LOG ${AIR_GRADIENT_LOG}
25-
${result}= Run Process cargo build --release cwd=firmware shell=true
26-
IF ${result.rc} != 0
27-
Log To Console ${result.stdout} console=yes
28-
Log To Console ${result.stderr} console=yes
43+
Set environment variable AIR_GRADIENT_MAC_ADDRESS ${AIR_GRADIENT_MAC_ADDRESS}
44+
Set environment variable AIR_GRADIENT_IP_ADDRESS ${AIR_GRADIENT_IP_ADDRESS}
45+
Set environment variable AIR_GRADIENT_DEVICE_ID ${AIR_GRADIENT_DEVICE_ID}
46+
Set environment variable AIR_GRADIENT_LOG ${AIR_GRADIENT_LOG}
47+
Set environment variable AIR_GRADIENT_DEVICE_PORT ${AIR_GRADIENT_DEVICE_PORT}
48+
49+
${result} = Run Process cargo build --release cwd=firmware shell=true
50+
IF ${result.rc} != 0
51+
Log To Console ${result.stdout} console=yes
52+
Log To Console ${result.stderr} console=yes
2953
END
30-
Should Be Equal As Integers ${result.rc} 0
54+
Should Be Equal As Integers ${result.rc} 0
3155

3256
Build Bootloader
33-
Set environment variable AIR_GRADIENT_LOG ${AIR_GRADIENT_LOG}
34-
${result}= Run Process cargo build --release cwd=bootloader shell=true
35-
IF ${result.rc} != 0
36-
Log To Console ${result.stdout} console=yes
37-
Log To Console ${result.stderr} console=yes
57+
Set environment variable AIR_GRADIENT_LOG ${AIR_GRADIENT_LOG}
58+
${result} = Run Process cargo build --release cwd=bootloader shell=true
59+
IF ${result.rc} != 0
60+
Log To Console ${result.stdout} console=yes
61+
Log To Console ${result.stderr} console=yes
3862
END
39-
Should Be Equal As Integers ${result.rc} 0
63+
Should Be Equal As Integers ${result.rc} 0
4064

4165
Build CLI
42-
${result}= Run Process cargo build --release cwd=host_tools/air-gradient-cli shell=true
43-
IF ${result.rc} != 0
44-
Log To Console ${result.stdout} console=yes
45-
Log To Console ${result.stderr} console=yes
66+
${result} = Run Process cargo build --release cwd=host_tools/air-gradient-cli shell=true
67+
IF ${result.rc} != 0
68+
Log To Console ${result.stdout} console=yes
69+
Log To Console ${result.stderr} console=yes
4670
END
47-
Should Be Equal As Integers ${result.rc} 0
71+
Should Be Equal As Integers ${result.rc} 0
4872

4973
Build System
5074
Build Firmware
5175
Build Bootloader
5276
Build CLI
5377

78+
Enable Verbose Logging
79+
Create Directory ${VERBOSE_LOGGING_DIR}
80+
81+
Execute Command usart6 CreateFileBackend @${VERBOSE_LOGGING_DIR}/${TEST_NAME}_uart.txt true
82+
Execute Command logFile @${VERBOSE_LOGGING_DIR}/${TEST_NAME}_renode.log true
83+
Execute Command logLevel ${RENODE_LOG_LEVEL} file
84+
5485
Prepare Machine
55-
Execute Command path add @${CURDIR}
56-
Execute Script ${AGP_RESC}
86+
Execute Command path add @${CURDIR}
87+
Execute Script ${AGP_RESC}
88+
Create Terminal Tester ${UART} timeout=${UART_TIMEOUT}
89+
IF ${VERBOSE_LOGGING_ENABLED} == True
90+
Enable Verbose Logging
91+
END
5792

5893
Run Command
59-
[Arguments] ${cmd_and_args}
60-
Log To Console ${cmd_and_args}
61-
${result}= Run Process ${cmd_and_args} shell=true
62-
IF ${result.rc} != 0
63-
Log To Console ${result.stdout} console=yes
64-
Log To Console ${result.stderr} console=yes
94+
[Arguments] ${cmd_and_args}
95+
IF ${VERBOSE_LOGGING_ENABLED} == True
96+
${result} = Run Process ${cmd_and_args} shell=true stdout=${VERBOSE_LOGGING_DIR}/${TEST_NAME}_cmd.stdout stderr=${VERBOSE_LOGGING_DIR}/${TEST_NAME}_cmd.stderr
97+
ELSE
98+
${result} = Run Process ${cmd_and_args} shell=true
6599
END
66100

67-
Should Be Equal As Integers ${result.rc} 0
101+
IF ${result.rc} != 0
102+
Log To Console ${result.stdout} console=yes
103+
Log To Console ${result.stderr} console=yes
104+
END
68105

69-
RETURN ${result}
106+
Should Be Equal As Integers ${result.rc} 0
70107

71-
*** Test Cases ***
72-
Boot the System
73-
[Documentation] Boots the system, bootloader and firmware
74-
[Tags] firmware bootloader uart
108+
RETURN ${result}
75109

76-
Build System
110+
Run CLI Command
111+
[Arguments] ${args} ${log_level}=error
112+
${result} = Run Command RUST_LOG=${log_level} ${CLI} ${args}
113+
RETURN ${result}
77114

78-
Prepare Machine
79-
Create Terminal Tester ${UART} timeout=${UART_TIMEOUT}
115+
Wait For Device Networking
116+
Wait For Line On Uart [D] UM: listening on port ${AIR_GRADIENT_DEVICE_PORT}
80117

81-
Start Emulation
118+
*** Test Cases ***
119+
System Boots
120+
[Documentation] Boots the system, bootloader and firmware
121+
[Tags] firmware bootloader uart
82122
83-
Wait For Line On Uart >>> Initialized <<<
123+
Start Emulation
84124

85-
Provides booted-system
125+
Wait For Line On Uart [W] Invalid boot config, using default
126+
Wait For Line On Uart agp-bootloader
127+
Wait For Line On Uart Reset reason: Power-on reset
128+
Wait For Line On Uart Boot config slot: SLOT0
129+
Wait For Line On Uart Update pending: false
130+
Wait For Line On Uart Update valid: false
131+
Wait For Line On Uart air-gradient-pro-rs
132+
Wait For Line On Uart Reset reason: Power-on reset
133+
Wait For Line On Uart Update pending: false
134+
Wait For Line On Uart >>> Initialized <<<
86135

87136
Responds to Ping
88-
[Documentation] TCP/IP stack should respond to pings
89-
[Tags] firmware bootloader uart network
90-
Requires booted-system
137+
[Documentation] TCP/IP stack should respond to pings
138+
[Tags] firmware bootloader uart network
91139
92-
Set Test Variable ${PING_CMD} ping -w ${PING_TIMEOUT} -W 1 ${AIR_GRADIENT_IP_ADDRESS}
140+
Start Emulation
93141

94-
Wait For Line On Uart [D] UM: listening on port 32101
142+
Set Test Variable ${PING_CMD} ping -w ${PING_TIMEOUT} -W 1 ${AIR_GRADIENT_IP_ADDRESS}
95143

96-
${result}= Run Process ${PING_CMD} shell=true
97-
Should Be Equal As Integers ${result.rc} 0
144+
Wait For Device Networking
98145

99-
Provides running-system
146+
${result} = Run Process ${PING_CMD} shell=true
147+
Should Be Equal As Integers ${result.rc} 0
100148

101149
Responds with Device Info
102-
[Documentation] Device responds to info request
103-
[Tags] firmware bootloader network device-protocol cli
104-
Requires running-system
150+
[Documentation] Device responds to info request
151+
[Tags] firmware bootloader network device-protocol cli
152+
153+
Start Emulation
154+
155+
Wait For Device Networking
156+
157+
${result} = Run CLI Command device info -a ${AIR_GRADIENT_IP_ADDRESS} -F device_id
158+
Should Be Equal As Integers ${result.stdout} ${AIR_GRADIENT_DEVICE_ID}
159+
160+
Wait For Line On Uart [D] UM: processing command Info
161+
162+
# NOTE: this test flaps sometimes on my local machine but not in CI...
163+
Device Applies Valid Firmware Update
164+
[Documentation] Devices handles firmware updates from the CLI, initially boots from SLOT0,
165+
... updates and boots to SLOT1
166+
[Tags] firmware bootloader network device-protocol cli fota
167+
168+
Start Emulation
169+
170+
Wait For Device Networking
171+
172+
${r0} = Run CLI Command device info -a ${AIR_GRADIENT_IP_ADDRESS} -F active_boot_slot
173+
Should Be Equal ${r0.stdout} "SLOT0"
174+
175+
# Socket gets reset every time the connection ends
176+
Wait For Device Networking
177+
178+
Run CLI Command device update -a ${AIR_GRADIENT_IP_ADDRESS} ${FW_IMAGE} log_level=trace
179+
180+
# firmware msg when upload complete
181+
Wait For Line On Uart [W] Update complete, rebooting now
182+
183+
# bootloader msg after reboot
184+
Wait For Line On Uart Update pending: true
185+
186+
# firmware ACKs the pending update and resets
187+
Wait For Line On Uart New application update checks out, marking for BC flash and reseting
105188

106-
Set Test Variable ${CLI_CMD} ${CLI} device info -a ${AIR_GRADIENT_IP_ADDRESS} -F device_id
189+
# bootloader msg after next reboot from ACK
190+
Wait For Line On Uart Update valid: true
107191

108-
${result} Run Command ${CLI_CMD}
192+
Wait For Device Networking
109193

110-
Should Be Equal As Integers ${result.stdout} ${AIR_GRADIENT_DEVICE_ID}
194+
${r1} = Run CLI Command device info -a ${AIR_GRADIENT_IP_ADDRESS} -F active_boot_slot
195+
Should Be Equal ${r1.stdout} "SLOT1"
111196

112197
# TODO
113-
# - tests for fota related
198+
# - tests for fota related, failover mechanism, etc
114199
# - device protocol and CLI ops
115200
# - sensors and bcast protocol stuff
116201
# - watchdog and panic stuf

bootloader/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pre-start-commands = [
7878
]
7979
reset = '''
8080
sysbus LoadELF $bin
81+
sysbus.cpu VectorTableOffset 0x8000000
8182
8283
sysbus WriteDoubleWord 0x1FFF7A10 $id1
8384
sysbus WriteDoubleWord 0x1FFF7A14 $id2

firmware/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firmware/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ pre-start-commands = [
253253
]
254254
reset = '''
255255
sysbus LoadELF $bin
256+
sysbus.cpu VectorTableOffset 0x8000000
256257
257258
# Device ID
258259
sysbus WriteDoubleWord 0x1FFF7A10 $id1

renode/agp.resc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ macro reset
9999
"""
100100
sysbus LoadELF $firmware_bin
101101
sysbus LoadELF $bootloader_bin
102+
sysbus.cpu VectorTableOffset 0x8000000
102103

103104
sysbus WriteDoubleWord 0x1FFF7A10 $id1
104105
sysbus WriteDoubleWord 0x1FFF7A14 $id2

0 commit comments

Comments
 (0)