Skip to content

Commit

Permalink
[test][tools] Add missing and improve testing
Browse files Browse the repository at this point in the history
Mostly this adds testing for certain aliases in more explicit ways.
There are also a few tidy-ups, and additions of missing testing, where
the feature was either not tested at all, or not tested explicitly and
sufficiently.

Reviewed by: MaskRay, rupprecht, grimar

Differential Revision: https://reviews.llvm.org/D71116
  • Loading branch information
jh7370 committed Dec 9, 2019
1 parent 0d1490b commit dba420b
Show file tree
Hide file tree
Showing 16 changed files with 534 additions and 22 deletions.
2 changes: 2 additions & 0 deletions llvm/test/DebugInfo/symbolize-inlined.test
@@ -1,4 +1,6 @@
RUN: llvm-symbolizer --inlining --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s
RUN: llvm-symbolizer -i --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s
RUN: llvm-symbolizer --inlines --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s

CHECK: inlined_h
CHECK-NEXT: dwarfdump-inl-test.h:2
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/Object/nm-shared-object.test
@@ -1,5 +1,7 @@
# RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-i386 \
# RUN: | FileCheck %s -check-prefix ELF-32
# RUN: llvm-nm --dynamic %p/Inputs/shared-object-test.elf-i386 \
# RUN: | FileCheck %s -check-prefix ELF-32

# ELF-32-NOT: U
# ELF-32: 000012c8 A __bss_start
Expand All @@ -12,6 +14,8 @@

# RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-x86-64 \
# RUN: | FileCheck %s -check-prefix ELF-64
# RUN: llvm-nm --dynamic %p/Inputs/shared-object-test.elf-x86-64 \
# RUN: | FileCheck %s -check-prefix ELF-64

# ELF-64-NOT: U
# ELF-64: 0000000000200454 A __bss_start
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/tools/llvm-cxxfilt/simple.test
@@ -1,7 +1,7 @@
RUN: llvm-cxxfilt -n _Z1fi abc | FileCheck %s
RUN: echo "Mangled _Z1fi and _Z3foov in string." | llvm-cxxfilt -n \
RUN: llvm-cxxfilt _Z1fi abc | FileCheck %s
RUN: echo "Mangled _Z1fi and _Z3foov in string." | llvm-cxxfilt \
RUN: | FileCheck %s --check-prefix=CHECK-STRING
RUN: llvm-cxxfilt -n "CLI remains mangled _Z1fi" \
RUN: llvm-cxxfilt "CLI remains mangled _Z1fi" \
RUN: | FileCheck %s --check-prefix=CHECK-MANGLED

CHECK: f(int)
Expand Down
4 changes: 3 additions & 1 deletion llvm/test/tools/llvm-cxxfilt/underscore.test
@@ -1,5 +1,8 @@
RUN: llvm-cxxfilt -_ __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-STRIPPED
RUN: llvm-cxxfilt --strip-underscore __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-STRIPPED
RUN: llvm-cxxfilt __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED
RUN: llvm-cxxfilt -n __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED
RUN: llvm-cxxfilt --no-strip-underscore __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED

CHECK-STRIPPED: ns::f
CHECK-STRIPPED: _ZSt1f
Expand All @@ -8,4 +11,3 @@ CHECK-STRIPPED: _f
CHECK-UNSTRIPPED: __ZN2ns1fE
CHECK-UNSTRIPPED: std::f
CHECK-UNSTRIPPED: _f

58 changes: 58 additions & 0 deletions llvm/test/tools/llvm-nm/elf-archive.test
@@ -0,0 +1,58 @@
## Show that llvm-nm prints the symbols of all ELF members of an archive.

# RUN: yaml2obj %s --docnum=1 -o %t1.o
# RUN: yaml2obj %s --docnum=2 -o %t2.o

# RUN: rm -f %t.symtab
# RUN: llvm-ar rc %t.symtab %t1.o %t2.o
# RUN: llvm-nm %t.symtab | FileCheck %s --match-full-lines

# RUN: rm -f %t.nosymtab
# RUN: llvm-ar rcS %t.nosymtab %t1.o %t2.o
# RUN: llvm-nm %t.nosymtab | FileCheck %s --match-full-lines

# CHECK: {{.*}}1.o:
# CHECK-NEXT: 00000002 D global_data_symbol
# CHECK-NEXT: 00000000 T global_function_symbol
# CHECK-EMPTY:
# CHECK-NEXT: {{.*}}2.o:
# CHECK-NEXT: 00000001 D another_data_symbol

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_EXECINSTR]
- Name: .data
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_WRITE]
Symbols:
- Name: global_function_symbol
Value: 0x0
Binding: STB_GLOBAL
Section: .text
- Name: global_data_symbol
Binding: STB_GLOBAL
Section: .data
Value: 0x2

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_WRITE]
Symbols:
- Name: another_data_symbol
Binding: STB_GLOBAL
Section: .data
Value: 0x1
49 changes: 49 additions & 0 deletions llvm/test/tools/llvm-nm/elf-extern-only.test
@@ -0,0 +1,49 @@
## Test that the --extern-only switch only shows external ELF symbols.

# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm %t.o --extern-only --no-sort | FileCheck %s
# RUN: llvm-nm %t.o -g --no-sort | FileCheck %s

## Using --no-sort ensures that the symbols appear in the symbol table order
## allowing our CHECK-NOTs to work as expected.
# CHECK-NOT: local
# CHECK: D global_data_symbol
# CHECK-NEXT: T global_function_symbol
# CHECK-NEXT: U undefined
# CHECK-NEXT: W weak_symbol
# CHECK-NOT: local

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_EXECINSTR]
- Name: .data
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_WRITE]
Symbols:
- Name: local_function_symbol
Binding: STB_LOCAL
Section: .text
- Name: local_data_symbol
Binding: STB_LOCAL
Section: .data
- Name: global_data_symbol
Binding: STB_GLOBAL
Section: .data
- Name: global_function_symbol
Binding: STB_GLOBAL
Section: .text
- Name: undefined
Binding: STB_GLOBAL
- Name: weak_symbol
Binding: STB_WEAK
Section: .data
- Name: local_at_end
Binding: STB_LOCAL
Section: .text
5 changes: 2 additions & 3 deletions llvm/test/tools/llvm-nm/print-filename.test
@@ -1,7 +1,6 @@
# RUN: yaml2obj %s > %t.o
# RUN: llvm-nm --print-file-name %t.o | FileCheck %s -DFILE=%t.o
# RUN: yaml2obj %s > %t.o
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm --print-file-name %t.o | FileCheck %s -DFILE=%t.o
# RUN: llvm-nm -A %t.o | FileCheck %s -DFILE=%t.o

!ELF
FileHeader:
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/tools/llvm-nm/print-size.test
@@ -1,5 +1,6 @@
# RUN: yaml2obj %s > %t.o
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm --print-size %t.o | FileCheck %s --strict-whitespace
# RUN: llvm-nm -S %t.o | FileCheck %s --strict-whitespace

!ELF
FileHeader:
Expand Down
1 change: 1 addition & 0 deletions llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
Expand Up @@ -4,6 +4,7 @@

# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump --dynamic-reloc %t | FileCheck --implicit-check-not=R_X86 %s
# RUN: llvm-objdump -R %t | FileCheck --implicit-check-not=R_X86 %s

# CHECK: file format ELF64-x86-64
# CHECK: DYNAMIC RELOCATION RECORDS
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/tools/llvm-objdump/all-headers.test
@@ -1,5 +1,6 @@
# RUN: yaml2obj %s > %t
# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump --all-headers %t | FileCheck %s
# RUN: llvm-objdump -x %t | FileCheck %s

## Note: --all-headers (-x) is an alias for --archive-headers --file-headers
## --section-headers --private-headers --reloc --syms (-afhprt). Test for them
Expand Down
8 changes: 6 additions & 2 deletions llvm/test/tools/llvm-readobj/elf-dynamic-tags.test
@@ -1,7 +1,11 @@
# Show that all non-machine specific tags can be read and printed correctly.
# RUN: yaml2obj %s > %t
## Show that all non-machine specific tags can be read and printed correctly.
## Also show that -d is an alias for --dynamic-table.

# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readobj -d %t | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readelf --dynamic-table %t | FileCheck %s --check-prefix=GNU
# RUN: llvm-readelf -d %t | FileCheck %s --check-prefix=GNU

# LLVM: DynamicSection [ (61 entries)
# LLVM-NEXT: Tag Type Name/Value
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/tools/llvm-readobj/elf-file-headers.test
@@ -1,5 +1,7 @@
# RUN: yaml2obj %s --docnum=1 -o %t.i386
# RUN: llvm-readobj -h %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
# RUN: llvm-readobj --file-header %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
# RUN: llvm-readobj --file-headers %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386

# I386:File: [[FILE]]
# I386-NEXT:Format: ELF32-i386
Expand Down Expand Up @@ -44,6 +46,10 @@ FileHeader:
# RUN: yaml2obj %s --docnum=2 -o %t.x86-64
# RUN: llvm-readobj -h %t.x86-64 \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
# RUN: llvm-readobj --file-header %t.x86-64 \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
# RUN: llvm-readobj --file-headers %t.x86-64 \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64

# X86-64:File: [[FILE]]
# X86-64-NEXT:Format: ELF64-x86-64
Expand Down Expand Up @@ -88,6 +94,10 @@ FileHeader:
# RUN: yaml2obj %s --docnum=3 -o %t.lanai
# RUN: llvm-readobj -h %t.lanai \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI
# RUN: llvm-readobj --file-header %t.lanai \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI
# RUN: llvm-readobj --file-headers %t.lanai \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI

--- !ELF
FileHeader:
Expand Down

0 comments on commit dba420b

Please sign in to comment.