llvm-project/llvm/test/tools/llvm-objdump/MachO/function-starts.test
Akshay Deodhar 73bcac28d0
[llvm-objdump][MachO] Update check in flaky test that depends on directory path (#150674)
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](https://llvm.org/docs/CommandGuide/llvm-objdump.html#cmdoption-llvm-objdump-function-starts): 

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 changes the RUN lines to
take stdin input, so that no directory path is printed, and stray _main
strings in the directory path will not make the test fail.
2025-09-25 21:26:23 +00:00

35 lines
1.9 KiB
Plaintext

## This test verifies that llvm-objdump correctly prints function starts data.
## Note: we read input from stdin instead of from a file, because llvm-objdump prints
## the filename in its output. If the filename contains the string "_main", then the
## check will incorrectly get triggered.
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
32-BIT-NAMES: {{^}}_main
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
64-BIT: 0000000100000f30
RUN: llvm-objdump --macho --function-starts=names - < %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT-NAMES
64-BIT-NAMES: {{^}}_main
RUN: llvm-objdump --macho --function-starts=both - < %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s --check-prefix=64-BIT-BOTH
64-BIT-BOTH: 0000000100000f30 _main
RUN: llvm-strip %p/Inputs/hello.exe.macho-x86_64 -o %t.stripped
RUN: llvm-objdump --macho --function-starts=both - < %t.stripped | FileCheck %s --check-prefix=BOTH-STRIPPED
BOTH-STRIPPED: 0000000100000f30 ?
RUN: llvm-strip %p/Inputs/hello.exe.macho-x86_64 -o %t.stripped
RUN: llvm-objdump --macho --function-starts=names - < %t.stripped | FileCheck %s --check-prefix=NAMES-STRIPPED
NAMES-STRIPPED: -:
NAMES-STRIPPED-EMPTY: