aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorgbreynoo <Owen.Reynolds@sony.com>2021-06-01 14:57:00 +0100
committergbreynoo <Owen.Reynolds@sony.com>2021-06-01 14:57:00 +0100
commite60f147324b64f7740de58e6b936cdc0e26daadd (patch)
tree55ccb9acff3724cfefcdacc4c2766029e04f82b8 /llvm
parent97d234935f1514af128277943f30efc469525371 (diff)
downloadllvm-e60f147324b64f7740de58e6b936cdc0e26daadd.zip
llvm-e60f147324b64f7740de58e6b936cdc0e26daadd.tar.gz
llvm-e60f147324b64f7740de58e6b936cdc0e26daadd.tar.bz2
[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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/output.s21
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s65
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/quiet.s10
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp2
4 files changed, 97 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/output.s b/llvm/test/tools/llvm-dwarfdump/X86/output.s
new file mode 100644
index 0000000..d4a7457
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/output.s
@@ -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
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s b/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
new file mode 100644
index 0000000..2d57334
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
@@ -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
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/quiet.s b/llvm/test/tools/llvm-dwarfdump/X86/quiet.s
new file mode 100644
index 0000000..72ac60a
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/X86/quiet.s
@@ -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: {{.}}
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 78665c0..abb2961 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -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();