[llvm-symbolizer][test] Simplify test input reading

This change migrates most llvm-symbolizer tests away from reading input
via stdin and instead using --obj + positional arguments for the file
and addresses respectively, which makes the tests easier to read.

One exception is the test test/tools/llvm-symbolizer/pdb/pdb.test, which
was doing some manipulation on the input addresses. This patch
simplifies this somewhat, but it still reads from stdin.

More changes to follow to simplify/break-up other tests.

Reviewed by: dblaikie

Differential Revision: https://reviews.llvm.org/D57441

llvm-svn: 352752
This commit is contained in:
James Henderson 2019-01-31 14:04:47 +00:00
parent 63f3383ece
commit ca8f3cb27c
11 changed files with 37 additions and 67 deletions

View File

@ -1,10 +1,5 @@
RUN: rm -rf %t && mkdir -p %t
RUN: cd %t
RUN: cp %p/Inputs/split-dwarf-no-skel-address.dwo %t
RUN: echo "%p/Inputs/split-dwarf-no-skel-address.o 0x4" > %t.input
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
RUN: --default-arch=i386 < %t.input | FileCheck %s RUN: --default-arch=i386 --obj=%p/Inputs/split-dwarf-no-skel-address.o 0x4 | FileCheck %s
Built from the following source: Built from the following source:
void f1(); void f1();

View File

@ -1,5 +1,4 @@
RUN: echo "%p/Inputs/llvm-symbolizer-tu.elf-x86-64 0x0" \ RUN: llvm-symbolizer --obj=%p/Inputs/llvm-symbolizer-tu.elf-x86-64 0x0 | FileCheck %s
RUN: | llvm-symbolizer | FileCheck %s
Built from the following source: Built from the following source:

View File

@ -1,10 +1,7 @@
REQUIRES: zlib REQUIRES: zlib
RUN: echo "%p/Inputs/dwarfdump-test-zlib.elf-x86-64 0x4005e9" > %t1.input RUN: llvm-symbolizer --obj=%p/Inputs/dwarfdump-test-zlib.elf-x86-64 0x4005e9 | FileCheck %s
RUN: llvm-symbolizer < %t1.input | FileCheck %s RUN: llvm-symbolizer --obj=%p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 0x4005e9 | FileCheck %s
RUN: echo "%p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 0x4005e9" > %t2.input
RUN: llvm-symbolizer < %t2.input | FileCheck %s
CHECK: main CHECK: main
CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test-zlib.cc:16 CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test-zlib.cc:16

View File

@ -1,19 +1,13 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x5009 0x5038 --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x5009 0x5038 --inlines --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | llvm-symbolizer --inlines --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x5009 0x5038 -i --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | llvm-symbolizer -i --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
This test relies on UnDecorateSymbolName, which is Windows-only. This test relies on UnDecorateSymbolName, which is Windows-only.
REQUIRES: target-windows, system-windows REQUIRES: target-windows, system-windows
ADDR: 0x5009
ADDR: 0x5038
CHECK: foo(void) CHECK: foo(void)
CHECK: coff-dwarf.cpp:7 CHECK: coff-dwarf.cpp:7
CHECK: bar(void) CHECK: bar(void)

View File

@ -1,11 +1,8 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x500A 0x5038 0x504B --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x500A 0x5038 0x504B --inlines --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | llvm-symbolizer --inlines --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x500A 0x5038 0x504B -i --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | llvm-symbolizer -i --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s RUN: | FileCheck %s
This test relies on UnDecorateSymbolName, which is Win32-only. This test relies on UnDecorateSymbolName, which is Win32-only.
@ -13,10 +10,6 @@ REQUIRES: system-windows
REQUIRES: target-windows REQUIRES: target-windows
FIXME: This test depends on host, not target. FIXME: This test depends on host, not target.
ADDR: 0x500A
ADDR: 0x5038
ADDR: 0x504B
We get the expected stack trace, except 'foo' appears for the 'bar' frame We get the expected stack trace, except 'foo' appears for the 'bar' frame
because 'bar' isn't in the export table. because 'bar' isn't in the export table.

View File

@ -1,8 +1,8 @@
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s
X86_64: x86_64_function X86_64: x86_64_function
X86_64H: x86_64h_function X86_64H: x86_64h_function

View File

@ -2,9 +2,9 @@
; Checks if symbolizer can correctly symbolize address in the padding between ; Checks if symbolizer can correctly symbolize address in the padding between
; functions. ; functions.
; RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %s ; RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %s
; RUN: echo 0x5 | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=FOO ; RUN: llvm-symbolizer 0x5 -obj=%t.o | FileCheck %s --check-prefix=FOO
; RUN: echo 0xd | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=PADDING ; RUN: llvm-symbolizer 0xd -obj=%t.o | FileCheck %s --check-prefix=PADDING
; RUN: echo 0x10 | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=MAIN ; RUN: llvm-symbolizer 0x10 -obj=%t.o | FileCheck %s --check-prefix=MAIN
;FOO: foo ;FOO: foo
;PADDING: ?? ;PADDING: ??

View File

@ -1,11 +1,7 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer 0x401000 0x401001 -obj="%p/Inputs/missing_pdb.exe" 2>%t.err \
RUN: | llvm-symbolizer -obj="%p/Inputs/missing_pdb.exe" 2>%t.err \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: FileCheck --check-prefix=ERROR %s < %t.err RUN: FileCheck --check-prefix=ERROR %s < %t.err
ADDR: 0x401000
ADDR: 0x401001
llvm-symbolizer should print one error and two unknown line info records. llvm-symbolizer should print one error and two unknown line info records.
ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{N|n}}o such file or directory ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{N|n}}o such file or directory

View File

@ -1,27 +1,23 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: echo 0x401380 > %t.input
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" \ RUN: echo 0x401390 >> %t.input
RUN: echo 0x4013A0 >> %t.input
RUN: echo 0x4013C0 >> %t.input
RUN: echo 0x4013D0 >> %t.input
RUN: echo 0x4013E0 >> %t.input
RUN: echo 0x4013F0 >> %t.input
RUN: echo 0x401420 >> %t.input
RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < %t.input \
RUN: | FileCheck %s RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false < %t.input \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
Subtract ImageBase from all the offsets and run the test again with Subtract ImageBase from all the offsets and run the test again with
--relative-address. --relative-address.
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ RUN: %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin]))' < %t.input \
RUN: | %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin]))' \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \ RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
ADDR: 0x401380
ADDR: 0x401390
ADDR: 0x4013A0
ADDR: 0x4013C0
ADDR: 0x4013D0
ADDR: 0x4013E0
ADDR: 0x4013F0
ADDR: 0x401420
CHECK: foo(void) CHECK: foo(void)
CHECK-NEXT: test.cpp:10 CHECK-NEXT: test.cpp:10
CHECK: {{^private_symbol$}} CHECK: {{^private_symbol$}}

View File

@ -4,7 +4,7 @@ int foo() { return 0; }
int bar() { return foo(); } int bar() { return foo(); }
int _start() { return bar(); } int _start() { return bar(); }
RUN: %python -c "print('0x1000014c\n0x1000018c\n0x100001cc')" | llvm-symbolizer -obj=%p/Inputs/ppc64 | FileCheck %s RUN: llvm-symbolizer 0x1000014c 0x1000018c 0x100001cc -obj=%p/Inputs/ppc64 | FileCheck %s
CHECK: foo CHECK: foo
CHECK: bar CHECK: bar

View File

@ -13,7 +13,7 @@ int main() {
// RUN: cp %s %t/ // RUN: cp %s %t/
// RUN: cp %p/Inputs/print_context.o %t // RUN: cp %p/Inputs/print_context.o %t
// RUN: cd %t // RUN: cd %t
// RUN: echo "%t/print_context.o 0x0" | llvm-symbolizer -print-source-context-lines=5 | FileCheck %s // RUN: llvm-symbolizer -obj=%t/print_context.o 0x0 -print-source-context-lines=5 | FileCheck %s
// Inputs/print_context.o built with plain -g -c from this source file // Inputs/print_context.o built with plain -g -c from this source file
// Specifying -Xclang -fdebug-compilation-dir -Xclang . to make the debug info // Specifying -Xclang -fdebug-compilation-dir -Xclang . to make the debug info