Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

This is used by a couple compiler-rt tests.

@llvmbot
Copy link
Member

llvmbot commented Oct 25, 2025

@llvm/pr-subscribers-testing-tools

Author: Aiden Grossman (boomanaiden154)

Changes

This is used by a couple compiler-rt tests.


Full diff: https://github.com/llvm/llvm-project/pull/165123.diff

3 Files Affected:

  • (modified) llvm/utils/lit/lit/TestRunner.py (+5-1)
  • (added) llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt (+6)
  • (modified) llvm/utils/lit/tests/shtest-ulimit.py (+7-1)
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

boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Oct 26, 2025
This is used by a couple compiler-rt tests.

Pull Request: llvm#165123
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Oct 26, 2025
This is used by a couple compiler-rt tests.

Pull Request: llvm#165123
Created using spr 1.3.7
Copy link
Contributor

@ilovepi ilovepi left a 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.

Comment on lines 605 to 607
# Import resource here after we confirm we are on a POSIX system as the
# module does not exist on Windows.
import resource
Copy link
Contributor

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.

boomanaiden154 and others added 4 commits October 27, 2025 17:44
Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
@boomanaiden154 boomanaiden154 changed the base branch from users/boomanaiden154/main.lit-add-support-for-setting-limits-to-unlimited to main October 30, 2025 15:40
@boomanaiden154 boomanaiden154 merged commit 9b02901 into main Oct 30, 2025
13 of 17 checks passed
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/lit-add-support-for-setting-limits-to-unlimited branch October 30, 2025 16:27
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 30, 2025
This is used by a couple compiler-rt tests.

Reviewers: petrhosek, ilovepi

Reviewed By: ilovepi

Pull Request: llvm/llvm-project#165123
luciechoi pushed a commit to luciechoi/llvm-project that referenced this pull request Nov 1, 2025
This is used by a couple compiler-rt tests.

Reviewers: petrhosek, ilovepi

Reviewed By: ilovepi

Pull Request: llvm#165123
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
This is used by a couple compiler-rt tests.

Reviewers: petrhosek, ilovepi

Reviewed By: ilovepi

Pull Request: llvm#165123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants