Skip to content

Commit 90e9c5e

Browse files
[MC] Rewrite stdin.s to use python
This test needs to change the file descriptor offset for the llvm-mc output file to test that we do not get an assertion in that situation. This doesn't seem easy to do without bash subshells. Rewrite these test in Python so we can remove the shell requirement from this test and enable using it with lit's internal shell. This also has the bonus of making the behavior that we are trying to create for the test much more explicit (a .seek call on the FD). Reviewers: ilovepi, MaskRay, petrhosek Reviewed By: petrhosek, ilovepi Pull Request: #157232
1 parent bd0580c commit 90e9c5e

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

llvm/test/MC/COFF/stdin.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# RUN: echo "// comment" > %t.input
2+
# We use STDIN to for the binary name as lit will substitute in the full path
3+
# of the binary before executing, ensuring we pick up the correct llvm-mc.
4+
# RUN: echo llvm-mc | %python %s %t.input %t
5+
6+
import argparse
7+
import subprocess
8+
import sys
9+
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("input_file")
12+
parser.add_argument("temp_file")
13+
arguments = parser.parse_args()
14+
15+
llvm_mc_binary = sys.stdin.readlines()[0].strip()
16+
17+
with open(arguments.temp_file, "w") as mc_stdout:
18+
## We need to test that starting on an input stream with a non-zero offset
19+
## does not trigger an assertion in WinCOFFObjectWriter.cpp, so we seek
20+
## past zero for STDOUT.
21+
mc_stdout.seek(4)
22+
subprocess.run(
23+
[
24+
llvm_mc_binary,
25+
"-filetype=obj",
26+
"-triple",
27+
"i686-pc-win32",
28+
arguments.input_file,
29+
],
30+
stdout=mc_stdout,
31+
check=True,
32+
)

llvm/test/MC/COFF/stdin.s

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)