@@ -3,114 +3,199 @@ Documentation Integration tests for air-gradient-pro bootloader, firmware and
3
3
Default Tags agp
4
4
Library Process
5
5
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
+
6
13
*** Variables ***
7
14
# Firmware configs
8
15
${AIR_GRADIENT_MAC_ADDRESS } 02 :00:04:03:07:04
9
16
${AIR_GRADIENT_IP_ADDRESS } 192.0.2.80
10
17
${AIR_GRADIENT_DEVICE_ID } 255
18
+ ${AIR_GRADIENT_DEVICE_PORT } 32101
11
19
${AIR_GRADIENT_LOG } TRACE
12
20
# Test vars
13
21
${CLI } ${CURDIR } /host_tools/air-gradient-cli/target/x86_64-unknown-linux-gnu/release/air-gradient
14
22
${AGP_RESC } ${CURDIR } /renode/agp.resc
23
+ ${FW_IMAGE } ${CURDIR } /firmware/target/agp_images.cpio
15
24
${UART } sysbus.usart6
16
- ${UART_TIMEOUT } 10
25
+ ${UART_TIMEOUT } 30
17
26
${PING_TIMEOUT } 5
27
+ ${VERBOSE_LOGGING_DIR } ${CURDIR } /agp_logs
28
+ ${VERBOSE_LOGGING_ENABLED } True
29
+ ${RENODE_LOG_LEVEL } 2
18
30
19
31
*** 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
+
20
42
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
29
53
END
30
- Should Be Equal As Integers ${result.rc } 0
54
+ Should Be Equal As Integers ${result.rc } 0
31
55
32
56
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
38
62
END
39
- Should Be Equal As Integers ${result.rc } 0
63
+ Should Be Equal As Integers ${result.rc } 0
40
64
41
65
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
46
70
END
47
- Should Be Equal As Integers ${result.rc } 0
71
+ Should Be Equal As Integers ${result.rc } 0
48
72
49
73
Build System
50
74
Build Firmware
51
75
Build Bootloader
52
76
Build CLI
53
77
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
+
54
85
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
57
92
58
93
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
65
99
END
66
100
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
68
105
69
- RETURN ${ result }
106
+ Should Be Equal As Integers ${ result.rc } 0
70
107
71
- *** Test Cases ***
72
- Boot the System
73
- [Documentation] Boots the system, bootloader and firmware
74
- [Tags] firmware bootloader uart
108
+ RETURN ${result }
75
109
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 }
77
114
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 }
80
117
81
- Start Emulation
118
+ *** Test Cases ***
119
+ System Boots
120
+ [Documentation] Boots the system, bootloader and firmware
121
+ [Tags] firmware bootloader uart
82
122
83
- Wait For Line On Uart >>> Initialized <<<
123
+ Start Emulation
84
124
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 <<<
86
135
87
136
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
91
139
92
- Set Test Variable ${ PING_CMD } ping -w ${ PING_TIMEOUT } -W 1 ${ AIR_GRADIENT_IP_ADDRESS }
140
+ Start Emulation
93
141
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 }
95
143
96
- ${result } = Run Process ${PING_CMD } shell=true
97
- Should Be Equal As Integers ${result.rc } 0
144
+ Wait For Device Networking
98
145
99
- Provides running-system
146
+ ${result } = Run Process ${PING_CMD } shell=true
147
+ Should Be Equal As Integers ${result.rc } 0
100
148
101
149
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
105
188
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
107
191
108
- ${ result } Run Command ${ CLI_CMD }
192
+ Wait For Device Networking
109
193
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"
111
196
112
197
# TODO
113
- # - tests for fota related
198
+ # - tests for fota related, failover mechanism, etc
114
199
# - device protocol and CLI ops
115
200
# - sensors and bcast protocol stuff
116
201
# - watchdog and panic stuf
0 commit comments