Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

These two tests were unresolved when using lit's internal shell.

In the case of tail-duplication-constant-prop, it was because they were
using a echo $? line, and lit's internal echo implementation does not
support $? to get the return code. The test was never actually asserting
anything about the return code though, so I've removed the echo
commands.

In the case of permission.test, it was because umask was not supported
before #155850, and afterwards not without an argument. The test also
was not great at capturing what it was supposed to (leaving open
possibilites like the system umask and what Bolt was using happening to
match), so I've rewritten the test in the style of
llvm/test/tools/llvm-objcopy/ELF/respect-umask.test.

This fixes #102693.

Created using spr 1.3.6
@llvmbot llvmbot added the BOLT label Aug 29, 2025
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Aug 29, 2025
These two tests were unresolved when using lit's internal shell.

In the case of tail-duplication-constant-prop, it was because they were
using a echo $? line, and lit's internal echo implementation does not
support $? to get the return code. The test was never actually asserting
anything about the return code though, so I've removed the echo
commands.

In the case of permission.test, it was because umask was not supported
before llvm#155850, and afterwards not without an argument. The test also
was not great at capturing what it was supposed to (leaving open
possibilites like the system umask and what Bolt was using happening to
match), so I've rewritten the test in the style of
llvm/test/tools/llvm-objcopy/ELF/respect-umask.test.

This fixes llvm#102693.

Pull Request: llvm#156082
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2025

@llvm/pr-subscribers-bolt

Author: Aiden Grossman (boomanaiden154)

Changes

These two tests were unresolved when using lit's internal shell.

In the case of tail-duplication-constant-prop, it was because they were
using a echo $? line, and lit's internal echo implementation does not
support $? to get the return code. The test was never actually asserting
anything about the return code though, so I've removed the echo
commands.

In the case of permission.test, it was because umask was not supported
before #155850, and afterwards not without an argument. The test also
was not great at capturing what it was supposed to (leaving open
possibilites like the system umask and what Bolt was using happening to
match), so I've rewritten the test in the style of
llvm/test/tools/llvm-objcopy/ELF/respect-umask.test.

This fixes #102693.


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

2 Files Affected:

  • (modified) bolt/test/permission.test (+23-8)
  • (modified) bolt/test/runtime/X86/tail-duplication-constant-prop.s (+2-2)
diff --git a/bolt/test/permission.test b/bolt/test/permission.test
index f495e87e8c7da..ecb51fc7466c2 100644
--- a/bolt/test/permission.test
+++ b/bolt/test/permission.test
@@ -1,13 +1,28 @@
 # Ensure that the permissions of the optimized binary file comply with the
 # system's umask.
 
-# This test performs a logical AND operation on the results of the `stat -c %a
-# %t.bolt` and `umask` commands (both results are displayed in octal), and
-# checks whether the result is equal to 0.
-REQUIRES: shell, system-linux
+# This test uses umask, which is Linux specific.
+REQUIRES: system-linux
 
-RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q
-RUN: llvm-bolt %t -o %t.bolt
-RUN: echo $(( 8#$(stat -c %a %t.bolt) & 8#$(umask) )) | FileCheck %s
+# RUN: rm -f %t
+# RUN: touch %t
+# RUN: chmod 0755 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0755
+# RUN: chmod 0600 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0600
+# RUN: chmod 0655 %t
+# RUN: ls -l %t | cut -f 1 -d ' ' > %t.0655
 
-CHECK: 0
+RUN: %clang %cflags %p/Inputs/hello.c -o %t.exe -Wl,-q
+
+RUN: umask 0022
+RUN: llvm-bolt %t.exe -o %t1
+RUN: ls -l %t1 | cut -f 1 -d ' ' | cmp - %t.0755
+
+RUN: umask 0177
+RUN: llvm-bolt %t.exe -o %t2
+RUN: ls -l %t2 | cut -f 1 -d ' ' | cmp - %t.0600
+
+RUN: umask 0122
+RUN: llvm-bolt %t.exe -o %t3
+RUN: ls -l %t3 | cut -f 1 -d ' ' | cmp - %t.0655
diff --git a/bolt/test/runtime/X86/tail-duplication-constant-prop.s b/bolt/test/runtime/X86/tail-duplication-constant-prop.s
index 863c6ff92d222..c28c2f4df61f3 100644
--- a/bolt/test/runtime/X86/tail-duplication-constant-prop.s
+++ b/bolt/test/runtime/X86/tail-duplication-constant-prop.s
@@ -8,8 +8,8 @@
 # RUN:    --print-finalized \
 # RUN:    --tail-duplication=moderate --tail-duplication-minimum-offset=1 \
 # RUN:    --tail-duplication-const-copy-propagation=1 -o %t.out | FileCheck %s
-# RUN: %t.exe; echo $?
-# RUN: %t.out; echo $?
+# RUN: not %t.exe
+# RUN: not %t.out
 
 # FDATA: 1 main 14 1 main #.BB2# 0 10
 # FDATA: 1 main 16 1 main #.BB2# 0 20

Copy link
Contributor

@maksfb maksfb left a comment

Choose a reason for hiding this comment

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

Thanks!

@boomanaiden154 boomanaiden154 merged commit 80c2179 into main Aug 29, 2025
11 checks passed
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/bolt-fix-tests-that-were-unresolved-when-using-lits-internal-shell branch August 29, 2025 19:51
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 29, 2025
…ernal shell

These two tests were unresolved when using lit's internal shell.

In the case of tail-duplication-constant-prop, it was because they were
using a echo $? line, and lit's internal echo implementation does not
support $? to get the return code. The test was never actually asserting
anything about the return code though, so I've removed the echo
commands.

In the case of permission.test, it was because umask was not supported
before #155850, and afterwards not without an argument. The test also
was not great at capturing what it was supposed to (leaving open
possibilites like the system umask and what Bolt was using happening to
match), so I've rewritten the test in the style of
llvm/test/tools/llvm-objcopy/ELF/respect-umask.test.

This fixes #102693.

Reviewers:
maksfb, yota9, ayermolo, yozhu, aaupov, rafaelauler, paschalis-mpeis

Reviewed By: maksfb

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[llvm-lit] TypeError: string argument expected in BOLT when testing with lit internal shell

4 participants