Skip to content

Commit 797a564

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). Pull Request: llvm#157232
1 parent 043b8a7 commit 797a564

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

llvm/test/MC/COFF/stdin.py

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

llvm/test/MC/COFF/stdin.s

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

0 commit comments

Comments
 (0)