Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

boomanaiden154
Copy link
Contributor

Some of the ulimit limits do not work on some POSIX platforms. THe motivating example here is ulimit -v on MacOS as the relevant system calls are not implemented in XNU. Splitting the tests lets us keep test coverage on POSIX (non-Linux) platforms.

Some of the ulimit limits do not work on some POSIX platforms. THe
motivating example here is ulimit -v on MacOS as the relevant system
calls are not implemented in XNU. Splitting the tests lets us keep test
coverage on POSIX (non-Linux) platforms.
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2025

@llvm/pr-subscribers-testing-tools

Author: Aiden Grossman (boomanaiden154)

Changes

Some of the ulimit limits do not work on some POSIX platforms. THe motivating example here is ulimit -v on MacOS as the relevant system calls are not implemented in XNU. Splitting the tests lets us keep test coverage on POSIX (non-Linux) platforms.


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

4 Files Affected:

  • (added) llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/lit.cfg (+8)
  • (added) llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/ulimit_okay.txt (+4)
  • (modified) llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_okay.txt (-1)
  • (modified) llvm/utils/lit/tests/shtest-ulimit.py (+7-8)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/lit.cfg
new file mode 100644
index 0000000000000..c7bdc7e7b6bc0
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/lit.cfg
@@ -0,0 +1,8 @@
+import lit.formats
+
+config.name = "shtest-ulimit"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest(execute_external=False)
+config.test_source_root = None
+config.test_exec_root = None
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/ulimit_okay.txt b/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/ulimit_okay.txt
new file mode 100644
index 0000000000000..dbdd0037e70a7
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit-linux/ulimit_okay.txt
@@ -0,0 +1,4 @@
+# RUN: ulimit -v 1048576
+# RUN: %{python} %S/../shtest-ulimit/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/Inputs/shtest-ulimit/ulimit_okay.txt b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_okay.txt
index ad353b5d7c459..4edf1c303a092 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_okay.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_okay.txt
@@ -1,4 +1,3 @@
-# RUN: ulimit -v 1048576
 # RUN: ulimit -n 50
 # RUN: %{python} %S/print_limits.py
 # Fail the test so that we can assert on the output.
diff --git a/llvm/utils/lit/tests/shtest-ulimit.py b/llvm/utils/lit/tests/shtest-ulimit.py
index b86578a21f661..444937f21eb02 100644
--- a/llvm/utils/lit/tests/shtest-ulimit.py
+++ b/llvm/utils/lit/tests/shtest-ulimit.py
@@ -3,13 +3,8 @@
 # ulimit does not work on non-POSIX platforms.
 # UNSUPPORTED: system-windows
 
-# TODO(boomanaiden154): The test fails on some non-Linux POSIX
-# platforms (like MacOS) due to the underlying system not supporting
-# ulimit -v. This test needs to be carved up so we keep full test
-# coverage on Linux and as much as possible on other platforms.
-# REQUIRES: system-linux
-
 # RUN: not %{lit} -a -v %{inputs}/shtest-ulimit | FileCheck %s
+# RUN: %if system-linux %{ not %{lit} -a -v %{inputs}/shtest-ulimit-linux | FileCheck %s --check-prefix CHECK-LINUX %}
 
 # CHECK: -- Testing: 2 tests{{.*}}
 
@@ -18,7 +13,11 @@
 # CHECK: 'ulimit' requires two arguments
 
 # CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_okay.txt ({{[^)]*}})
-# CHECK: ulimit -v 1048576
 # CHECK: ulimit -n 50
-# CHECK: RLIMIT_AS=1073741824
 # CHECK: RLIMIT_NOFILE=50
+
+# CHECK-LINUX: -- Testing: 1 tests{{.*}}
+
+# CHECK-LINUX-LABEL: FAIL: shtest-ulimit :: ulimit_okay.txt ({{[^)]*}})
+# CHECK-LINUX: ulimit -v 1048576
+# CHECK-LINUX: RLIMIT_AS=1073741824

# RUN: not %{lit} -a -v %{inputs}/shtest-ulimit | FileCheck %s
# RUN: %if system-linux %{ not %{lit} -a -v %{inputs}/shtest-ulimit-linux | FileCheck %s --check-prefix CHECK-LINUX %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also work on other operating systems such as FreeBSD. Could we split this test into two and just make the one that has ulimit -v UNSUPPORTED: system-mac?

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.

3 participants