diff --git a/llvm/test/tools/llvm-tli-checker/coff-reject.test b/llvm/test/tools/llvm-tli-checker/coff-reject.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-tli-checker/coff-reject.test @@ -0,0 +1,43 @@ +## Currently COFF files aren't supported. +# RUN: yaml2obj %s -o %t.obj +# RUN: llvm-tli-checker %t.obj 2>&1 | FileCheck %s +# +# CHECK: only ELF-format files are supported +# CHECK: no symbols found +# CHECK: NO symbols found! + +## Minimal COFF input. +--- !COFF +OptionalHeader: + AddressOfEntryPoint: 4144 + ImageBase: 1073741824 + SectionAlignment: 4096 + FileAlignment: 512 + MajorOperatingSystemVersion: 6 + MinorOperatingSystemVersion: 0 + MajorImageVersion: 0 + MinorImageVersion: 0 + MajorSubsystemVersion: 6 + MinorSubsystemVersion: 0 + Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI + DLLCharacteristics: [ ] + SizeOfStackReserve: 1048576 + SizeOfStackCommit: 4096 + SizeOfHeapReserve: 1048576 + SizeOfHeapCommit: 4096 +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE ] + VirtualAddress: 4096 + VirtualSize: 4 + SectionData: C3C3C3C3 +symbols: + - Name: main + Value: 2 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL diff --git a/llvm/test/tools/llvm-tli-checker/error-cases.test b/llvm/test/tools/llvm-tli-checker/error-cases.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-tli-checker/error-cases.test @@ -0,0 +1,32 @@ +## No input files. +# RUN: not llvm-tli-checker 2>&1 | FileCheck %s --check-prefix=NOFILES +# +## File not found. +# RUN: rm -f %t0.txt +# RUN: llvm-tli-checker %t0.txt 2>&1 | FileCheck %s -DFILE=%t0.txt --check-prefixes=FILE-NOT-FOUND,NOSYMBOLS-AT-ALL +# +## Reject a non-binary file. +# RUN: echo nonsense > %t1.o +# RUN: llvm-tli-checker %t1.o 2>&1 | FileCheck %s --check-prefixes=INVALID-FILE,NOSYMBOLS-AT-ALL +# +## Reject an empty file. +# RUN: yaml2obj %s -o %t2.o +# RUN: llvm-tli-checker %t2.o 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefixes=NOSYMBOLS-IN-FILE,NOSYMBOLS-AT-ALL +# +# NOFILES: error: no input files +# FILE-NOT-FOUND-DAG: warning: [[FILE]]: not found +# INVALID-FILE-DAG: warning: The file was not recognized as a valid object file +# NOSYMBOLS-AT-ALL-DAG: error: NO symbols found! +# NOSYMBOLS-IN-FILE-DAG: warning: [[FILE]]: no symbols found + +## Minimal ELF with no symbols. +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_FREEBSD + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS diff --git a/llvm/test/tools/llvm-tli-checker/multi-file.yaml b/llvm/test/tools/llvm-tli-checker/multi-file.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-tli-checker/multi-file.yaml @@ -0,0 +1,117 @@ +## Test that we can pass multiple files. There are several ways to do this: +## list them all individually, use --libdir to shorten the list, or use a +## response file (with or without --libdir). +## +# REQUIRES: x86-registered-target +# +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 %s -o %t.dir/file1 +# RUN: yaml2obj --docnum=2 %s -o %t.dir/file2 +# RUN: yaml2obj --docnum=3 %s -o %t.dir/file3 + +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --report=full \ +# RUN: %t.dir/file1 %t.dir/file2 %t.dir/file3 | \ +# RUN: FileCheck %s +# +## Same result using --libdir. +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --report=full \ +# RUN: --libdir=%t.dir file1 file2 file3 | \ +# RUN: FileCheck %s +# +## And with a response file. +# RUN: echo -e "file1\nfile2\nfile3\n" > %t.dir/resp1.txt +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --report=full \ +# RUN: --libdir=%t.dir @%t.dir/resp1.txt | \ +# RUN: FileCheck %s +# +# RUN: echo %t.dir/file1 > %t.dir/resp2.txt +# RUN: echo %t.dir/file2 >> %t.dir/resp2.txt +# RUN: echo %t.dir/file3 >> %t.dir/resp2.txt +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --report=full \ +# RUN: @%t.dir/resp2.txt | \ +# RUN: FileCheck %s +# +## Also check that an archive works. Put file1 and file2 into an archive, +## and pass the archive name plus file3 on the command line. +# RUN: rm -f %t.dir/archive.a +# RUN: llvm-ar rc %t.dir/archive.a %t.dir/file1 %t.dir/file2 +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --report=full \ +# RUN: --libdir=%t.dir archive.a file3 | \ +# RUN: FileCheck %s +# +# CHECK: TLI knows {{[0-9]+}} symbols, [[#AVAILABLE:]] available +# CHECK: >> TLI no SDK yes: '_ZdaPvj' +# CHECK: == TLI yes SDK yes: 'abs' +# CHECK: == TLI yes SDK yes: 'calloc' +## The yes/no and yes/yes should add up to the total available. +## The no/yes aren't included in the total available. +# CHECK: << Total TLI yes SDK no: [[#AVAILABLE-2]] +# CHECK: >> Total TLI no SDK yes: 1{{$}} +# CHECK: == Total TLI yes SDK yes: 2{{$}} + +## --separate should give one summary per input file (as listed on the +# command line; it doesn't break things down by archive member). +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 --separate \ +# RUN: --libdir=%t.dir archive.a file3 | \ +# RUN: FileCheck %s --check-prefix=SEPARATE +# +# SEPARATE: TLI knows {{[0-9]+}} symbols, [[#AVAILABLE:]] available +# SEPARATE: Found 2 global function symbols in '{{.*}}archive.a' +# SEPARATE: << Total TLI yes SDK no: [[#AVAILABLE-1]] +# SEPARATE: >> Total TLI no SDK yes: 1{{$}} +# SEPARATE: == Total TLI yes SDK yes: 1{{$}} +# SEPARATE: Found 1 global function symbols in '{{.*}}file3' +# SEPARATE: << Total TLI yes SDK no: [[#AVAILABLE-1]] +# SEPARATE: >> Total TLI no SDK yes: 0{{$}} +# SEPARATE: == Total TLI yes SDK yes: 1{{$}} + +# file1 +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_FREEBSD + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS +DynamicSymbols: + - Name: abs + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + +# file2 +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_FREEBSD + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS +DynamicSymbols: + - Name: _ZdaPvj + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + +# file3 +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_FREEBSD + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS +DynamicSymbols: + - Name: calloc + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL diff --git a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml --- a/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml +++ b/llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml @@ -6,17 +6,23 @@ # ## This produces an object that has _ZdaPvj instead of _ZdaPv. # RUN: yaml2obj %s -DZDAPV=_ZdaPvj -o=%t2 -# RUN: echo %t2 > %t2.txt -# RUN: llvm-tli-checker --triple x86_64-scei-ps4 @%t2.txt | \ +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 %t2 | \ # RUN: FileCheck %s --check-prefixes=WRONG_SUMMARY,WRONG_DETAIL \ # RUN: --implicit-check-not="==" --implicit-check-not="<<" --implicit-check-not=">>" # -# RUN: llvm-tli-checker --triple x86_64-scei-ps4 @%t2.txt --report=summary | \ +## --report=discrepancy is the default, check we get the same output. +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 %t2 --report=discrepancy | \ +# RUN: FileCheck %s --check-prefixes=WRONG_SUMMARY,WRONG_DETAIL \ +# RUN: --implicit-check-not="==" --implicit-check-not="<<" --implicit-check-not=">>" +# +## --report=summary should not print the details (checked by the +## implicit-check-not strings). +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 %t.dir/bad --report=summary | \ # RUN: FileCheck %s --check-prefix=WRONG_SUMMARY \ # RUN: --implicit-check-not="==" --implicit-check-not="<<" --implicit-check-not=">>" +# ## --separate implies --report=summary. -## Also use a response file to show we support that. -# RUN: llvm-tli-checker --triple x86_64-scei-ps4 @%t2.txt --separate | \ +# RUN: llvm-tli-checker --triple x86_64-scei-ps4 %t2 --separate | \ # RUN: FileCheck %s --check-prefix=WRONG_SUMMARY \ # RUN: --implicit-check-not="==" --implicit-check-not="<<" --implicit-check-not=">>" # @@ -37,10 +43,14 @@ # ## The -COUNT suffix doesn't care if there are too many matches, so check ## the exact count first; the two directives should add up to that. +## Yes, this means additions to TLI will fail this test, but the argument +## to -COUNT can't be an expression. # AVAIL: TLI knows 468 symbols, 235 available # AVAIL-COUNT-235: {{^}} available -# UNAVAIL-COUNT-231: not available +# UNAVAIL-COUNT-233: not available +## This is a large file so it's worth telling lit to stop here. +# END. --- !ELF FileHeader: