[llvm-dwarfdump][test] Add missing dedicated tests for some options

This change adds tests specifically for --parent-recurse-depth, --quiet
and -o. The test for -o found a typo in an error message which is also
fixed in this change.

Differential Revision: https://reviews.llvm.org/D103250
This commit is contained in:
gbreynoo 2021-06-01 14:57:00 +01:00
parent 97d234935f
commit e60f147324
4 changed files with 97 additions and 1 deletions

View File

@ -0,0 +1,21 @@
# RUN: rm -f %t1.txt %t2.txt %t3.txt
# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o %t.o
# RUN: llvm-dwarfdump -o=- %t.o | FileCheck %s
# RUN: llvm-dwarfdump -o=%t1.txt %t.o
# RUN: FileCheck %s --input-file %t1.txt
# RUN: touch %t2.txt
# RUN: llvm-dwarfdump -o=%t2.txt %t.o
# RUN: FileCheck %s --input-file %t2.txt
# RUN: touch %t3.txt
# RUN: chmod 444 %t3.txt
# RUN: not llvm-dwarfdump -o=%t3.txt %t.o 2>&1 | FileCheck %s --check-prefix=ERROR1 -DFILE=%t3.txt
# RUN: not llvm-dwarfdump -o= %t.o 2>&1 | FileCheck %s --check-prefix=ERROR2
# CHECK: DW_TAG_compile_unit
# ERROR1: unable to open output file [[FILE]]: {{[pP]}}ermission denied
# ERROR2: unable to open output file : {{[nN]}}o such file or directory

View File

@ -0,0 +1,65 @@
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 0 %t.o | FileCheck %s --check-prefix=ALL
# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 1 %t.o | FileCheck %s --check-prefix=ONE
# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 2 %t.o | FileCheck %s --check-prefix=TWO
# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 3 %t.o | FileCheck %s --check-prefix=ALL
# ALL: by_hand
# ALL: main
# ALL: test
# ALL: int
# ONE-NOT: by_hand
# ONE-NOT: main
# ONE: test
# ONE: int
# TWO-NOT: by_hand
# TWO: main
# TWO: test
# TWO: int
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
DWARF:
debug_abbrev:
- Table:
- Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes
Attributes:
- Attribute: DW_AT_producer
Form: DW_FORM_string
- Tag: DW_TAG_subprogram
Children: DW_CHILDREN_yes
Attributes:
- Attribute: DW_AT_name
Form: DW_FORM_string
- Tag: DW_TAG_namespace
Children: DW_CHILDREN_yes
Attributes:
- Attribute: DW_AT_name
Form: DW_FORM_string
- Tag: DW_TAG_base_type
Children: DW_CHILDREN_no
Attributes:
- Attribute: DW_AT_name
Form: DW_FORM_string
debug_info:
- Version: 4
Entries:
- AbbrCode: 1
Values:
- CStr: by_hand
- AbbrCode: 2
Values:
- CStr: main
- AbbrCode: 3
Values:
- CStr: test
- AbbrCode: 4
Values:
- CStr: int

View File

@ -0,0 +1,10 @@
# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o %t.o
# RUN: llvm-dwarfdump --verify %t.o | FileCheck %s
# RUN: llvm-dwarfdump --verify --quiet %t.o | FileCheck %s --check-prefix=QUIET --allow-empty
# RUN: llvm-mc %S/empty-CU.s -filetype obj -triple x86_64-apple-darwin -o %t-error.o
# RUN: not llvm-dwarfdump --verify %t-error.o | FileCheck %s
# RUN: not llvm-dwarfdump --verify --quiet %t-error.o | FileCheck %s --check-prefix=QUIET --allow-empty
# CHECK: {{.}}
# QUIET-NOT: {{.}}

View File

@ -635,7 +635,7 @@ int main(int argc, char **argv) {
std::error_code EC;
ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_TextWithCRLF);
error("Unable to open output file" + OutputFilename, EC);
error("unable to open output file " + OutputFilename, EC);
// Don't remove output file if we exit with an error.
OutputFile.keep();