-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lit] Add support for setting limits to unlimited #165123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lit] Add support for setting limits to unlimited #165123
Conversation
Created using spr 1.3.7
Created using spr 1.3.7 [skip ci]
|
@llvm/pr-subscribers-testing-tools Author: Aiden Grossman (boomanaiden154) ChangesThis is used by a couple compiler-rt tests. Full diff: https://github.com/llvm/llvm-project/pull/165123.diff 3 Files Affected:
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index a48df097403c7..ee7670d4a9961 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -12,6 +12,7 @@
import shutil
import tempfile
import threading
+import resource
import typing
import traceback
from typing import Optional, Tuple
@@ -605,7 +606,10 @@ def executeBuiltinUlimit(cmd, shenv):
if len(cmd.args) != 3:
raise InternalShellError(cmd, "'ulimit' requires two arguments")
try:
- new_limit = int(cmd.args[2])
+ if cmd.args[2] == "unlimited":
+ new_limit = resource.RLIM_INFINITY
+ else:
+ new_limit = int(cmd.args[2])
except ValueError as err:
raise InternalShellError(cmd, "Error: 'ulimit': %s" % str(err))
if cmd.args[1] == "-v":
diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt
new file mode 100644
index 0000000000000..b8aa3d5071712
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt
@@ -0,0 +1,6 @@
+# RUN: ulimit -f 5
+# RUN: %{python} %S/print_limits.py
+# RUN: ulimit -f unlimited
+# RUN: %{python} %S/print_limits.py
+# Fail the test so that we can assert on the output.
+# RUN: not echo return
diff --git a/llvm/utils/lit/tests/shtest-ulimit.py b/llvm/utils/lit/tests/shtest-ulimit.py
index ba3de8b1bfced..d63a92f1c18e3 100644
--- a/llvm/utils/lit/tests/shtest-ulimit.py
+++ b/llvm/utils/lit/tests/shtest-ulimit.py
@@ -11,7 +11,7 @@
# RUN: not %{lit} -a -v %{inputs}/shtest-ulimit --order=lexical \
# RUN: | FileCheck -DBASE_NOFILE_LIMIT=%{readfile:%t.nofile_limit} %s
-# CHECK: -- Testing: 3 tests{{.*}}
+# CHECK: -- Testing: 4 tests{{.*}}
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit-bad-arg.txt ({{[^)]*}})
# CHECK: ulimit -n
@@ -27,3 +27,9 @@
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_reset.txt ({{[^)]*}})
# CHECK: RLIMIT_NOFILE=[[BASE_NOFILE_LIMIT]]
+
+# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_unlimited.txt ({{[^)]*}})
+# CHECK: ulimit -f 5
+# CHECK: RLIMIT_FSIZE=5
+# CHECK: ulimit -f unlimited
+# CHECK: RLIMIT_FSIZE=-1
|
This is used by a couple compiler-rt tests. Pull Request: llvm#165123
This is used by a couple compiler-rt tests. Pull Request: llvm#165123
ilovepi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I don't have a strong opinion on the one import I commented on.
llvm/utils/lit/lit/TestRunner.py
Outdated
| # Import resource here after we confirm we are on a POSIX system as the | ||
| # module does not exist on Windows. | ||
| import resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way on this import here. on one hand I like that its conditional, since ulimit is rare. on the other hand, I'd generally prefer the imports be together at the top of the file.
Created using spr 1.3.7 [skip ci]
Created using spr 1.3.7 [skip ci]
This is used by a couple compiler-rt tests. Reviewers: petrhosek, ilovepi Reviewed By: ilovepi Pull Request: llvm/llvm-project#165123
This is used by a couple compiler-rt tests. Reviewers: petrhosek, ilovepi Reviewed By: ilovepi Pull Request: llvm#165123
This is used by a couple compiler-rt tests. Reviewers: petrhosek, ilovepi Reviewed By: ilovepi Pull Request: llvm#165123
This is used by a couple compiler-rt tests.