Skip to content

[llvm-objdump][MachO] Update check in flaky test that depends on directory path #150674

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akshayrdeodhar
Copy link
Contributor

Earlier, function-starts.test failed when directory path contained '_main', because objdump prints out the entire directory path, and there is an implicit-check-not for '_main'.
There's three ways in which function starts are printed by llvm-objdump

With the "addr" mode, there will be no "_main"
With "names", it'll be printed as "_main\n"
With "both", it'll be printed as " _main\n". 

The existing check for function-starts=addrs checks that the pattern for "names" or "both" does not get printed. This MR makes the check more specific, so that stray _main strings in the directory path will not make the test fail.

@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2025

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-mc

Author: Akshay Deodhar (akshayrdeodhar)

Changes

Earlier, function-starts.test failed when directory path contained '_main', because objdump prints out the entire directory path, and there is an implicit-check-not for '_main'.
There's three ways in which function starts are printed by llvm-objdump

With the "addr" mode, there will be no "_main"
With "names", it'll be printed as "_main\n"
With "both", it'll be printed as "<addr> _main\n". 

The existing check for function-starts=addrs checks that the pattern for "names" or "both" does not get printed. This MR makes the check more specific, so that stray _main strings in the directory path will not make the test fail.


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

1 Files Affected:

  • (modified) llvm/test/tools/llvm-objdump/MachO/function-starts.test (+4-4)
diff --git a/llvm/test/tools/llvm-objdump/MachO/function-starts.test b/llvm/test/tools/llvm-objdump/MachO/function-starts.test
index 8c013174c4eca..509bc8629b014 100644
--- a/llvm/test/tools/llvm-objdump/MachO/function-starts.test
+++ b/llvm/test/tools/llvm-objdump/MachO/function-starts.test
@@ -1,7 +1,7 @@
 ## This test verifies that llvm-objdump correctly prints function starts data.
 
-RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not=_main
-RUN: llvm-objdump --macho --function-starts=addrs %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not=_main
+RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not='{{(^| )_main}}'
+RUN: llvm-objdump --macho --function-starts=addrs %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not='{{(^| )_main}}'
 32-BIT: 00001f40
 
 RUN: llvm-objdump --macho --function-starts=names %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT-NAMES
@@ -10,8 +10,8 @@ RUN: llvm-objdump --macho --function-starts=names %p/Inputs/hello.exe.macho-i386
 RUN: llvm-objdump --macho --function-starts=both %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT-BOTH
 32-BIT-BOTH: 00001f40 _main
 
-RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT --implicit-check-not=_main
-RUN: llvm-objdump --macho --function-starts=addrs %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT --implicit-check-not=_main
+RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT --implicit-check-not='{{(^| )_main}}'
+RUN: llvm-objdump --macho --function-starts=addrs %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT --implicit-check-not='{{(^| )_main}}'
 64-BIT: 0000000100000f30
 
 RUN: llvm-objdump --macho --function-starts=names %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT-NAMES

@MaskRay
Copy link
Member

MaskRay commented Aug 2, 2025

llvm-objdump ... - < %t/xxxx is better.

@@ -1,7 +1,7 @@
## This test verifies that llvm-objdump correctly prints function starts data.

RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not=_main
RUN: llvm-objdump --macho --function-starts=addrs %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not=_main
RUN: llvm-objdump --macho --function-starts %p/Inputs/hello.exe.macho-i386 | FileCheck %s --check-prefix=32-BIT --implicit-check-not='{{(^| )_main}}'
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit edge-casey, but this will still fail for paths like /my/contrived _main/path. Adding $ might help. assuming that the strings we're talking about are always at the end of lines (I'm not familiar with the details of this output).

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.

4 participants