Skip to content

Commit

Permalink
Fix tests with binutils 2.41
Browse files Browse the repository at this point in the history
The tests broke on my machine because of
bminor/binutils-gdb@014a602
which was fixed half a year later by
bminor/binutils-gdb@f82ee0c
so the only binutils version affected is 2.41.

Nevertheless, apparently using objcopy output to pipe is not something
officially supported, so we can avoid such issues in the future by using
another temporary file.
  • Loading branch information
Arusekk committed Oct 26, 2023
1 parent a628256 commit a1b472e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def test_asm_source(self):
self.base_dir = "test/asm/"
self.bin_src = []

with tempfile.NamedTemporaryFile() as asm_tmp:
with tempfile.NamedTemporaryFile() as asm_tmp, tempfile.NamedTemporaryFile() as bin_tmp:
subprocess.check_call(
[
"riscv64-unknown-elf-as",
Expand All @@ -276,9 +276,10 @@ def test_asm_source(self):
self.base_dir + self.source_file,
]
)
code = subprocess.check_output(
["riscv64-unknown-elf-objcopy", "-O", "binary", "-j", ".text", asm_tmp.name, "/dev/stdout"]
subprocess.check_call(
["riscv64-unknown-elf-objcopy", "-O", "binary", "-j", ".text", asm_tmp.name, bin_tmp.name]
)
code = bin_tmp.read()
for word_idx in range(0, len(code), 4):
word = code[word_idx : word_idx + 4]
bin_instr = int.from_bytes(word, "little")
Expand Down

0 comments on commit a1b472e

Please sign in to comment.