Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.

@llvmbot
Copy link
Member

llvmbot commented Jan 3, 2026

@llvm/pr-subscribers-testing-tools

Author: Aiden Grossman (boomanaiden154)

Changes

This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.


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

6 Files Affected:

  • (modified) llvm/utils/lit/lit/TestRunner.py (+11-1)
  • (added) llvm/utils/lit/tests/Inputs/shtest-not-posix/fail-signal.py (+6)
  • (added) llvm/utils/lit/tests/Inputs/shtest-not-posix/lit.cfg (+8)
  • (added) llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal-crash.txt (+3)
  • (added) llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal.txt (+3)
  • (added) llvm/utils/lit/tests/shtest-not-posix.py (+13)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 7a233b238f7e2..fb0f0da568276 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -783,6 +783,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
 
     procs = []
     proc_not_counts = []
+    proc_not_fail_if_crash = []
     default_stdin = subprocess.PIPE
     stderrTempFiles = []
     opened_files = []
@@ -913,6 +914,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
         if not_crash:
             args = not_args + args
             not_count = 0
+        elif not_args == ['not']:
+            pass
         else:
             not_args = []
 
@@ -1008,6 +1011,10 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
             if old_umask != -1:
                 os.umask(old_umask)
             proc_not_counts.append(not_count)
+            if not not_crash and not_args == ['not']:
+                proc_not_fail_if_crash.append(True)
+            else:
+                proc_not_fail_if_crash.append(False)
             # Let the helper know about this process
             timeoutHelper.addProcess(procs[-1])
         except OSError as e:
@@ -1063,7 +1070,10 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
         if res == -signal.SIGINT:
             raise KeyboardInterrupt
         if proc_not_counts[i] % 2:
-            res = 1 if res == 0 else 0
+            if proc_not_fail_if_crash[i]:
+                res = 1 if res <= 0 else 0
+            else:
+                res = 1 if res == 0 else 0
         elif proc_not_counts[i] > 1:
             res = 1 if res != 0 else 0
 
diff --git a/llvm/utils/lit/tests/Inputs/shtest-not-posix/fail-signal.py b/llvm/utils/lit/tests/Inputs/shtest-not-posix/fail-signal.py
new file mode 100644
index 0000000000000..01db32585d071
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-not-posix/fail-signal.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import os
+import signal
+
+os.kill(os.getpid(), signal.SIGABRT)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-not-posix/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-not-posix/lit.cfg
new file mode 100644
index 0000000000000..37f1a141a48ab
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-not-posix/lit.cfg
@@ -0,0 +1,8 @@
+import lit.formats
+
+config.name = "shtest-not-posix"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest()
+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-not-posix/not-signal-crash.txt b/llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal-crash.txt
new file mode 100644
index 0000000000000..8f7638a7970df
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal-crash.txt
@@ -0,0 +1,3 @@
+# Check that the builtin not passes when we fail with a signal with --crash
+
+# RUN: not --crash %{python} fail-signal.py
diff --git a/llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal.txt b/llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal.txt
new file mode 100644
index 0000000000000..be3506b3322c7
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-not-posix/not-signal.txt
@@ -0,0 +1,3 @@
+# Check that the builtin not still fails when we fail with a signal.
+
+# RUN: not %{python} fail-signal.py
diff --git a/llvm/utils/lit/tests/shtest-not-posix.py b/llvm/utils/lit/tests/shtest-not-posix.py
new file mode 100644
index 0000000000000..6468d5ea48450
--- /dev/null
+++ b/llvm/utils/lit/tests/shtest-not-posix.py
@@ -0,0 +1,13 @@
+# Check the not command correctly handles POSIX signals
+
+# UNSUPPORTED: system-windows
+
+# RUN: not %{lit} -a %{inputs}/shtest-not-posix \
+# RUN: | FileCheck -match-full-lines %s
+
+# CHECK: -- Testing: 2 tests{{.*}}
+
+# CHECK PASS: shtest-not-posix :: not-signal-crash.txt (1 of 2)
+
+# CHECK: FAIL: shtest-not-posix :: not-signal.txt (2 of 2)
+# CHECK: # error: command failed with exit status: 1

@github-actions
Copy link

github-actions bot commented Jan 3, 2026

✅ With the latest revision this PR passed the Python code formatter.

Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Jan 3, 2026
This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.

Pull Request: llvm#174298
Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
Created using spr 1.3.7
@boomanaiden154 boomanaiden154 changed the base branch from users/boomanaiden154/main.lit-make-not-still-fail-if-the-called-process-returns-a-signal to main January 5, 2026 17:41
Created using spr 1.3.7
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

🐧 Linux x64 Test Results

  • 188135 tests passed
  • 4989 tests skipped

✅ The build succeeded and all tests passed.

Created using spr 1.3.7
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Jan 5, 2026
This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.

Pull Request: llvm#174298
@boomanaiden154 boomanaiden154 merged commit 65dbee0 into main Jan 5, 2026
10 checks passed
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/lit-make-not-still-fail-if-the-called-process-returns-a-signal branch January 5, 2026 21:34
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 5, 2026
…signal

This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.

Reviewers: petrhosek, ilovepi, jdenny-ornl, arichardson

Pull Request: llvm/llvm-project#174298
@sarnex
Copy link
Member

sarnex commented Jan 5, 2026

I think offload/test/offloading/requires.c is failing after this change. Here's the log from our runner, which is still in staging to be fair, but it seems to be consistent.

******************** TEST 'libomptarget :: x86_64-unknown-linux-gnu :: offloading/requires.c' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 2
/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/clang -fopenmp    -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src  -nogpulib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib  -fopenmp-targets=x86_64-unknown-linux-gnu /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -o /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp -DREQ=1 && /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp 2>&1 | /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/FileCheck /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -check-prefix=GOOD
# executed command: /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/clang -fopenmp -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -fopenmp-targets=x86_64-unknown-linux-gnu /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -o /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp -DREQ=1
# executed command: /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp
# executed command: /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/FileCheck /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -check-prefix=GOOD
# RUN: at line 3
/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/clang -fopenmp    -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src  -nogpulib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib  -fopenmp-targets=x86_64-unknown-linux-gnu /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -o /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp -DREQ=2 && not /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp 2>&1 | /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/FileCheck /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -check-prefix=BAD
# executed command: /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/clang -fopenmp -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test -I /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -L /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -Wl,-rpath,/home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./lib -fopenmp-targets=x86_64-unknown-linux-gnu /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -o /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp -DREQ=2
# executed command: not /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/runtimes/runtimes-bins/offload/test/x86_64-unknown-linux-gnu/offloading/Output/requires.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/build/./bin/FileCheck /home/test-user/llvm-buildbot-worker/intel-sycl-gpu/llvm-project/offload/test/offloading/requires.c -check-prefix=BAD
--
********************

It could be the test is wrong and this just exposed it.

@boomanaiden154
Copy link
Contributor Author

It could be the test is wrong and this just exposed it.

That would be my guess. If you run the command locally and you get a signal, then the test needs to be updated to pass --crash to not.

@sarnex
Copy link
Member

sarnex commented Jan 5, 2026

Yeah seems that was it, made #174499, thx

sarnex added a commit that referenced this pull request Jan 5, 2026
`not` behavior change in
#174298 requires `--crash`
passed now.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 5, 2026
…(#174499)

`not` behavior change in
llvm/llvm-project#174298 requires `--crash`
passed now.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jan 6, 2026
This is the behavior of the main not binary that was not preserved in
the internal shell. Make it so that the builtin not command does
actually fail if we end up with a signal rather than just a non-zero
exit code.

Reviewers: petrhosek, ilovepi, jdenny-ornl, arichardson

Pull Request: llvm#174298
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jan 6, 2026
`not` behavior change in
llvm#174298 requires `--crash`
passed now.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
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.

7 participants