Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ def executeBuiltinUlimit(cmd, shenv):
shenv.ulimit["RLIMIT_AS"] = new_limit * 1024
elif cmd.args[1] == "-n":
shenv.ulimit["RLIMIT_NOFILE"] = new_limit
elif cmd.args[1] == "-s":
shenv.ulimit["RLIMIT_STACK"] = new_limit * 1024
elif cmd.args[1] == "-f":
shenv.ulimit["RLIMIT_FSIZE"] = new_limit
else:
raise InternalShellError(
cmd, "'ulimit' does not support option: %s" % cmd.args[1]
Expand Down
4 changes: 4 additions & 0 deletions llvm/utils/lit/lit/builtin_commands/_launch_with_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def main(argv):
resource.setrlimit(resource.RLIMIT_AS, limit)
elif limit_str == "RLIMIT_NOFILE":
resource.setrlimit(resource.RLIMIT_NOFILE, limit)
elif limit_str == "RLIMIT_STACK":
resource.setrlimit(resource.RLIMIT_STACK, limit)
elif limit_str == "RLIMIT_FSIZE":
resource.setrlimit(resource.RLIMIT_FSIZE, limit)
process_output = subprocess.run(command_args)
sys.exit(process_output.returncode)

Expand Down
2 changes: 2 additions & 0 deletions llvm/utils/lit/tests/Inputs/shtest-ulimit/print_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

print("RLIMIT_AS=" + str(resource.getrlimit(resource.RLIMIT_AS)[0]))
print("RLIMIT_NOFILE=" + str(resource.getrlimit(resource.RLIMIT_NOFILE)[0]))
print("RLIMIT_STACK=" + str(resource.getrlimit(resource.RLIMIT_STACK)[0]))
print("RLIMIT_FSIZE=" + str(resource.getrlimit(resource.RLIMIT_FSIZE)[0]))
2 changes: 2 additions & 0 deletions llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_okay.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# RUN: ulimit -n 50
# RUN: ulimit -s 256
# RUN: ulimit -f 5
# RUN: %{python} %S/print_limits.py
# Fail the test so that we can assert on the output.
# RUN: not echo return
4 changes: 4 additions & 0 deletions llvm/utils/lit/tests/shtest-ulimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_okay.txt ({{[^)]*}})
# CHECK: ulimit -n 50
# CHECK: ulimit -s 256
# CHECK: ulimit -f 5
# CHECK: RLIMIT_NOFILE=50
# CHECK: RLIMIT_STACK=262144
# CHECK: RLIMIT_FSIZE=5

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