[llvm] 4cd1425 - [llvm-readobj][test] - Test "Format" values.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 01:33:01 PDT 2020


Author: Georgii Rymar
Date: 2020-08-28T11:31:25+03:00
New Revision: 4cd14256b23a19f4e7cf96628dda6cd6cec01be7

URL: https://github.com/llvm/llvm-project/commit/4cd14256b23a19f4e7cf96628dda6cd6cec01be7
DIFF: https://github.com/llvm/llvm-project/commit/4cd14256b23a19f4e7cf96628dda6cd6cec01be7.diff

LOG: [llvm-readobj][test] - Test "Format" values.

This adds testing for the "Format" field printed with `--file-headers`.

llvm-readelf doesn't use them, so only llvm-readobj needs to be tested.

All possible values are defined and tested in `ELFObjectFile<ELFT>::getFileFormatName()`.
Here we test just a few arbitrary ones.

Differential revision: https://reviews.llvm.org/D86350

Added: 
    llvm/test/tools/llvm-readobj/ELF/file-header-format.test

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-readobj/ELF/file-header-format.test b/llvm/test/tools/llvm-readobj/ELF/file-header-format.test
new file mode 100644
index 000000000000..0a208777fd88
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/file-header-format.test
@@ -0,0 +1,27 @@
+## This tests "Format" values printed by llvm-readobj.
+
+## The "Format" value printed depends on values stored in e_ident[EI_CLASS],
+## e_ident[EI_DATA] and e_machine fields of an ELF file header.
+## We test all possible values in unittests\Object\ELFObjectFileTest.cpp,
+## here we test just a few of them to demonstrate that llvm-readobj prints the same.
+
+# RUN: yaml2obj %s -o %t.none64.o
+# RUN: llvm-readobj --file-headers %t.none64.o | FileCheck %s -DFMT="elf64-unknown"
+
+# RUN: yaml2obj %s -o %t.none32.o -DCLASS=32
+# RUN: llvm-readobj --file-headers %t.none32.o | FileCheck %s -DFMT="elf32-unknown"
+
+# RUN: yaml2obj %s -o %t.i386-32.o -DMACHINE=EM_386 -DCLASS=32
+# RUN: llvm-readobj --file-headers %t.i386-32.o | FileCheck %s -DFMT="elf32-i386"
+
+# RUN: yaml2obj %s -o %t.x86_64.o -DMACHINE=EM_X86_64
+# RUN: llvm-readobj --file-headers %t.x86_64.o | FileCheck %s -DFMT="elf64-x86-64"
+
+# CHECK: Format: [[FMT]]
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS[[CLASS=64]]
+  Data:    ELFDATA2[[DATA=LSB]]
+  Type:    ET_REL
+  Machine: [[MACHINE=EM_NONE]]


        


More information about the llvm-commits mailing list