Skip to content

Commit

Permalink
test_framework: Support python3 in expand_testcase
Browse files Browse the repository at this point in the history
Use open() instead of file() and add encode() calls to handle byte
conversion.
  • Loading branch information
lsgunth authored and pchaigno committed Feb 25, 2021
1 parent 7c1437c commit 0014f29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test_framework/expand-testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():
os.makedirs(args.path)

def writefile(name, contents):
file("%s/%s" % (args.path, name), "w").write(contents)
open("%s/%s" % (args.path, name), "wb").write(contents)

if 'mem' in data:
writefile('mem', data['mem'])
Expand All @@ -49,7 +49,7 @@ def writefile(name, contents):
+ data['mem'])

if 'raw' in data:
code = ''.join(struct.pack("=Q", x) for x in data['raw'])
code = b''.join(struct.pack("=Q", x) for x in data['raw'])
elif 'asm' in data:
code = ubpf.assembler.assemble(data['asm'])
else:
Expand All @@ -59,7 +59,7 @@ def writefile(name, contents):
writefile('code', code)

if 'asm' in data:
writefile('asm', data['asm'])
writefile('asm', data['asm'].encode())
elif code:
writefile('asm', ubpf.disassembler.disassemble(code))

Expand Down

0 comments on commit 0014f29

Please sign in to comment.