Skip to content

Commit b042ac7

Browse files
committed
flash.robot: Move flash related kwds from coreboot-redundant-boot
1 parent 32b1f94 commit b042ac7

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

dasharo-stability/coreboot-redundant-boot.robot

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -104,44 +104,6 @@ CRB004.201 Slot A Protection (Ubuntu)
104104

105105

106106
*** Keywords ***
107-
Verify Region Range Protected
108-
[Arguments] ${region_name} ${expected_start} ${expected_end}
109-
${readonly_regions}= Get Flashrom Readonly Offsets
110-
IF len(${readonly_regions}) == 0
111-
Fail No readonly regions found in flashrom output
112-
END
113-
114-
${expected_readonly_bootblock}= Calculate Expected Flashrom Readonly Region
115-
... region_name=${region_name}
116-
... start_offset=${expected_start}
117-
... end_offset=${expected_end}
118-
119-
VAR ${expected_readonly_found}= ${FALSE}
120-
FOR ${region} IN @{readonly_regions}
121-
Log To Console Found readonly region: ${region}
122-
Log To Console Expected readonly region: ${expected_readonly_bootblock}
123-
${start_matches}= Evaluate int(${region['start']}) == int(${expected_readonly_bootblock['start']})
124-
${end_matches}= Evaluate int(${region['end']}) == int(${expected_readonly_bootblock['end']})
125-
IF ${start_matches} and ${end_matches}
126-
VAR ${expected_readonly_found}= ${TRUE}
127-
BREAK
128-
END
129-
END
130-
IF not ${expected_readonly_found}
131-
Fail Expected readonly region ${expected_readonly_bootblock} not found in flashrom output
132-
END
133-
134-
Calculate Expected Flashrom Readonly Region
135-
[Arguments] ${region_name} ${start_offset} ${end_offset}
136-
${flashrom_regions}= Get Flashrom Regions
137-
${bios_start}= Get From Dictionary ${flashrom_regions['${region_name}']} start
138-
${bios_end}= Get From Dictionary ${flashrom_regions['${region_name}']} end
139-
${expected_readonly_start}= Evaluate hex(${bios_start} + ${COREBOOT_REDUNDANT_BOOT_BOOTBLOCK_OFFSET.start})
140-
${expected_readonly_end}= Evaluate hex(${bios_start} + ${COREBOOT_REDUNDANT_BOOT_BOOTBLOCK_OFFSET.end})
141-
${expected_readonly}= Create Dictionary start=${expected_readonly_start} end=${expected_readonly_end}
142-
RETURN ${expected_readonly}
143-
144-
145107
Set Attempt Slot B Flag
146108
[Arguments] ${state}=${TRUE}
147109
IF ${state}
@@ -161,29 +123,3 @@ Should Have Booted From Slot
161123
${out}= Convert To Lower Case ${out}
162124
${out}= Strip String ${out}
163125
Should Contain ${out} ${slot}
164-
165-
Get Flashrom Regions
166-
${output}= Execute Command In Terminal flashrom -p internal
167-
${lines}= Split To Lines ${output}
168-
${dict}= Create Dictionary
169-
FOR ${l} IN @{lines}
170-
${m}= Get Regexp Matches ${l} FREG[0-9]+: (.+) region \\((0x[0-9a-f]+)-(0x[0-9a-f]+)\\) is (.+) 1 2 3 4
171-
IF ${m} != []
172-
${region}= Create Dictionary start=${m[0][1]} end=${m[0][2]} state=${m[0][3]}
173-
Set To Dictionary ${dict} ${m[0][0]}=${region}
174-
END
175-
END
176-
RETURN ${dict}
177-
178-
Get Flashrom Readonly Offsets
179-
${output}= Execute Command In Terminal flashrom -p internal
180-
${lines}= Split To Lines ${output}
181-
${list}= Create List
182-
FOR ${l} IN @{lines}
183-
${m}= Get Regexp Matches ${l} Warning: (0x[0-9a-f]+)-(0x[0-9a-f]+) is read-only 1 2
184-
IF ${m} != []
185-
${region}= Create Dictionary start=${m[0][0]} end=${m[0][1]}
186-
Append To List ${list} ${region}
187-
END
188-
END
189-
RETURN ${list}

lib/flash.robot

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,67 @@ Read Firmware
191191
ELSE
192192
Fail Read firmware not implemented for platform config ${CONFIG}
193193
END
194+
195+
Get Flashrom Regions
196+
${output}= Execute Command In Terminal flashrom -p internal
197+
${lines}= Split To Lines ${output}
198+
${dict}= Create Dictionary
199+
FOR ${l} IN @{lines}
200+
${m}= Get Regexp Matches ${l} FREG[0-9]+: (.+) region \\((0x[0-9a-f]+)-(0x[0-9a-f]+)\\) is (.+) 1 2 3 4
201+
IF ${m} != []
202+
${region}= Create Dictionary start=${m[0][1]} end=${m[0][2]} state=${m[0][3]}
203+
Set To Dictionary ${dict} ${m[0][0]}=${region}
204+
END
205+
END
206+
RETURN ${dict}
207+
208+
Get Flashrom Readonly Offsets
209+
${output}= Execute Command In Terminal flashrom -p internal
210+
${lines}= Split To Lines ${output}
211+
${list}= Create List
212+
FOR ${l} IN @{lines}
213+
${m}= Get Regexp Matches ${l} Warning: (0x[0-9a-f]+)-(0x[0-9a-f]+) is read-only 1 2
214+
IF ${m} != []
215+
${region}= Create Dictionary start=${m[0][0]} end=${m[0][1]}
216+
Append To List ${list} ${region}
217+
END
218+
END
219+
RETURN ${list}
220+
221+
Calculate Expected Flashrom Readonly Region
222+
[Tags] robot:private
223+
[Arguments] ${region_name} ${start_offset} ${end_offset}
224+
${flashrom_regions}= Get Flashrom Regions
225+
${bios_start}= Get From Dictionary ${flashrom_regions['${region_name}']} start
226+
${bios_end}= Get From Dictionary ${flashrom_regions['${region_name}']} end
227+
${expected_readonly_start}= Evaluate hex(${bios_start} + ${COREBOOT_REDUNDANT_BOOT_BOOTBLOCK_OFFSET.start})
228+
${expected_readonly_end}= Evaluate hex(${bios_start} + ${COREBOOT_REDUNDANT_BOOT_BOOTBLOCK_OFFSET.end})
229+
${expected_readonly}= Create Dictionary start=${expected_readonly_start} end=${expected_readonly_end}
230+
RETURN ${expected_readonly}
231+
232+
Verify Region Range Protected
233+
[Arguments] ${region_name} ${expected_start} ${expected_end}
234+
${readonly_regions}= Get Flashrom Readonly Offsets
235+
IF len(${readonly_regions}) == 0
236+
Fail No readonly regions found in flashrom output
237+
END
238+
239+
${expected_readonly_bootblock}= Calculate Expected Flashrom Readonly Region
240+
... region_name=${region_name}
241+
... start_offset=${expected_start}
242+
... end_offset=${expected_end}
243+
244+
VAR ${expected_readonly_found}= ${FALSE}
245+
FOR ${region} IN @{readonly_regions}
246+
Log To Console Found readonly region: ${region}
247+
Log To Console Expected readonly region: ${expected_readonly_bootblock}
248+
${start_matches}= Evaluate int(${region['start']}) == int(${expected_readonly_bootblock['start']})
249+
${end_matches}= Evaluate int(${region['end']}) == int(${expected_readonly_bootblock['end']})
250+
IF ${start_matches} and ${end_matches}
251+
VAR ${expected_readonly_found}= ${TRUE}
252+
BREAK
253+
END
254+
END
255+
IF not ${expected_readonly_found}
256+
Fail Expected readonly region ${expected_readonly_bootblock} not found in flashrom output
257+
END

0 commit comments

Comments
 (0)