Skip to content

Commit c380ea9

Browse files
boomanaiden154Lukacma
authored andcommitted
[lit] Support more ulimit options
These are the other options used in compiler-rt that we also need to support. Reviewers: arichardson, petrhosek, ilovepi Reviewed By: ilovepi, arichardson Pull Request: llvm#165122
1 parent a299a0b commit c380ea9

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

llvm/utils/lit/lit/TestRunner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ def executeBuiltinUlimit(cmd, shenv):
612612
shenv.ulimit["RLIMIT_AS"] = new_limit * 1024
613613
elif cmd.args[1] == "-n":
614614
shenv.ulimit["RLIMIT_NOFILE"] = new_limit
615+
elif cmd.args[1] == "-s":
616+
shenv.ulimit["RLIMIT_STACK"] = new_limit * 1024
617+
elif cmd.args[1] == "-f":
618+
shenv.ulimit["RLIMIT_FSIZE"] = new_limit
615619
else:
616620
raise InternalShellError(
617621
cmd, "'ulimit' does not support option: %s" % cmd.args[1]

llvm/utils/lit/lit/builtin_commands/_launch_with_limit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def main(argv):
1717
resource.setrlimit(resource.RLIMIT_AS, limit)
1818
elif limit_str == "RLIMIT_NOFILE":
1919
resource.setrlimit(resource.RLIMIT_NOFILE, limit)
20+
elif limit_str == "RLIMIT_STACK":
21+
resource.setrlimit(resource.RLIMIT_STACK, limit)
22+
elif limit_str == "RLIMIT_FSIZE":
23+
resource.setrlimit(resource.RLIMIT_FSIZE, limit)
2024
process_output = subprocess.run(command_args)
2125
sys.exit(process_output.returncode)
2226

llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
print("RLIMIT_AS=" + str(resource.getrlimit(resource.RLIMIT_AS)[0]))
44
print("RLIMIT_NOFILE=" + str(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
5+
print("RLIMIT_STACK=" + str(resource.getrlimit(resource.RLIMIT_STACK)[0]))
6+
print("RLIMIT_FSIZE=" + str(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# RUN: ulimit -n 50
2+
# RUN: ulimit -s 256
3+
# RUN: ulimit -f 5
24
# RUN: %{python} %S/print_limits.py
35
# Fail the test so that we can assert on the output.
46
# RUN: not echo return

llvm/utils/lit/tests/shtest-ulimit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_okay.txt ({{[^)]*}})
2121
# CHECK: ulimit -n 50
22+
# CHECK: ulimit -s 256
23+
# CHECK: ulimit -f 5
2224
# CHECK: RLIMIT_NOFILE=50
25+
# CHECK: RLIMIT_STACK=262144
26+
# CHECK: RLIMIT_FSIZE=5
2327

2428
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_reset.txt ({{[^)]*}})
2529
# CHECK: RLIMIT_NOFILE=[[BASE_NOFILE_LIMIT]]

0 commit comments

Comments
 (0)