Skip to content

Commit 078b5ad

Browse files
[lit] Add support for setting limits to unlimited
This is used by a couple compiler-rt tests. Pull Request: llvm#165123
1 parent b8cce14 commit 078b5ad

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

llvm/utils/lit/lit/TestRunner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import shutil
1313
import tempfile
1414
import threading
15+
import resource
1516
import typing
1617
import traceback
1718
from typing import Optional, Tuple
@@ -605,7 +606,10 @@ def executeBuiltinUlimit(cmd, shenv):
605606
if len(cmd.args) != 3:
606607
raise InternalShellError(cmd, "'ulimit' requires two arguments")
607608
try:
608-
new_limit = int(cmd.args[2])
609+
if cmd.args[2] == "unlimited":
610+
new_limit = resource.RLIM_INFINITY
611+
else:
612+
new_limit = int(cmd.args[2])
609613
except ValueError as err:
610614
raise InternalShellError(cmd, "Error: 'ulimit': %s" % str(err))
611615
if cmd.args[1] == "-v":
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# RUN: ulimit -f 5
2+
# RUN: %{python} %S/print_limits.py
3+
# RUN: ulimit -f unlimited
4+
# RUN: %{python} %S/print_limits.py
5+
# Fail the test so that we can assert on the output.
6+
# RUN: not echo return

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# RUN: not %{lit} -a -v %{inputs}/shtest-ulimit --order=lexical \
1212
# RUN: | FileCheck -DBASE_NOFILE_LIMIT=%{readfile:%t.nofile_limit} %s
1313

14-
# CHECK: -- Testing: 3 tests{{.*}}
14+
# CHECK: -- Testing: 4 tests{{.*}}
1515

1616
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit-bad-arg.txt ({{[^)]*}})
1717
# CHECK: ulimit -n
@@ -27,3 +27,9 @@
2727

2828
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_reset.txt ({{[^)]*}})
2929
# CHECK: RLIMIT_NOFILE=[[BASE_NOFILE_LIMIT]]
30+
31+
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_unlimited.txt ({{[^)]*}})
32+
# CHECK: ulimit -f 5
33+
# CHECK: RLIMIT_FSIZE=5
34+
# CHECK: ulimit -f unlimited
35+
# CHECK: RLIMIT_FSIZE=-1

0 commit comments

Comments
 (0)