Skip to content

Commit 042ea4e

Browse files
authored
Rollup merge of #131694 - c6c7:fixup-failing-fuchsia-tests, r=Urgau
Make fuchsia-test-runner.py compatible with new JSON output from llvm-readelf [A recent commit in LLVM](llvm/llvm-project@ab930ee) modified the JSON output of LLVM. The LLVM change renamed "Notes" to "NoteSections" and inserted a new "Notes" key nested under each "NoteSection". This change shores up exceptions around reading the JSON output of llvm-readelf and reads from "NoteSections" instead of the non-existent "Notes". r? `@erickt`
2 parents f7b91ca + 5d178e1 commit 042ea4e

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

src/ci/docker/scripts/fuchsia-test-runner.py

+31-11
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,38 @@ def build_id(self, binary):
193193
stderr=subprocess.STDOUT,
194194
)
195195
if process.returncode:
196-
self.env_logger.error(
197-
f"llvm-readelf failed for binary {binary} with output {process.stdout}"
196+
e = f"llvm-readelf failed for binary {binary} with output {process.stdout}"
197+
self.env_logger.error(e)
198+
raise Exception(e)
199+
200+
try:
201+
elf_output = json.loads(process.stdout)
202+
except Exception as e:
203+
e.add_note(f"Failed to read JSON from llvm-readelf for binary {binary}")
204+
e.add_note(f"stdout: {process.stdout}")
205+
raise
206+
207+
try:
208+
note_sections = elf_output[0]["NoteSections"]
209+
except Exception as e:
210+
e.add_note(
211+
f'Failed to read "NoteSections" from llvm-readelf for binary {binary}'
198212
)
199-
raise Exception(f"Unreadable build-id for binary {binary}")
200-
data = json.loads(process.stdout)
201-
if len(data) != 1:
202-
raise Exception(f"Unreadable output from llvm-readelf for binary {binary}")
203-
notes = data[0]["Notes"]
204-
for note in notes:
205-
note_section = note["NoteSection"]
206-
if note_section["Name"] == ".note.gnu.build-id":
207-
return note_section["Note"]["Build ID"]
213+
e.add_note(f"elf_output: {elf_output}")
214+
raise
215+
216+
for entry in note_sections:
217+
try:
218+
note_section = entry["NoteSection"]
219+
if note_section["Name"] == ".note.gnu.build-id":
220+
return note_section["Notes"][0]["Build ID"]
221+
except Exception as e:
222+
e.add_note(
223+
f'Failed to read ".note.gnu.build-id" from NoteSections \
224+
entry in llvm-readelf for binary {binary}'
225+
)
226+
e.add_note(f"NoteSections: {note_sections}")
227+
raise
208228
raise Exception(f"Build ID not found for binary {binary}")
209229

210230
def generate_buildid_dir(

0 commit comments

Comments
 (0)