[llvm] e60f147 - [llvm-dwarfdump][test] Add missing dedicated tests for some options
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 1 06:58:58 PDT 2021
Author: gbreynoo
Date: 2021-06-01T14:57:00+01:00
New Revision: e60f147324b64f7740de58e6b936cdc0e26daadd
URL: https://github.com/llvm/llvm-project/commit/e60f147324b64f7740de58e6b936cdc0e26daadd
DIFF: https://github.com/llvm/llvm-project/commit/e60f147324b64f7740de58e6b936cdc0e26daadd.diff
LOG: [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
Added:
llvm/test/tools/llvm-dwarfdump/X86/output.s
llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
llvm/test/tools/llvm-dwarfdump/X86/quiet.s
Modified:
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Removed:
################################################################################
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 0000000000000..d4a7457b086a5
--- /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 0000000000000..2d573344191cb
--- /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 0000000000000..72ac60a6d7941
--- /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 78665c0a3b8dd..abb2961826810 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();
More information about the llvm-commits
mailing list