[llvm] 725412f - [yaml2obj] - Refactor header-sh-fields.yaml test.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 06:13:45 PDT 2020
Author: Georgii Rymar
Date: 2020-07-13T16:12:22+03:00
New Revision: 725412f1f54aca6d465b61191b420c0aee0cef38
URL: https://github.com/llvm/llvm-project/commit/725412f1f54aca6d465b61191b420c0aee0cef38
DIFF: https://github.com/llvm/llvm-project/commit/725412f1f54aca6d465b61191b420c0aee0cef38.diff
LOG: [yaml2obj] - Refactor header-sh-fields.yaml test.
This refines the test to use macros. It is needed for
a follow-up change that adds a functionality to
override more fields.
Also, it is just cleaner to test each key separately.
Differential revision: https://reviews.llvm.org/D83481
Added:
Modified:
llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
Removed:
################################################################################
diff --git a/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml b/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
index 821b77418857..166c68405bb7 100644
--- a/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
@@ -3,8 +3,8 @@
## First we check the default values.
-# RUN: yaml2obj --docnum=1 %s -o %t1
-# RUN: llvm-readelf --file-headers %t1 | FileCheck %s --check-prefix=DEFAULT
+# RUN: yaml2obj %s -o %t-default
+# RUN: llvm-readelf --file-headers %t-default | FileCheck %s --check-prefix=DEFAULT
# DEFAULT: Start of section headers: 88 (bytes into file)
# DEFAULT: Size of section headers: 64 (bytes)
@@ -18,15 +18,10 @@ FileHeader:
Type: ET_REL
Machine: EM_X86_64
-## Override 3 fields: e_shoff, e_shnum and e_shstrndx. Check the output.
-
-# RUN: yaml2obj --docnum=2 %s -o %t2
-# RUN: llvm-readelf --file-headers %t2 | FileCheck %s --check-prefix=CUSTOM
-
-# CUSTOM: Start of section headers: 2 (bytes into file)
-# CUSTOM: Size of section headers: 64 (bytes)
-# CUSTOM: Number of section headers: 3
-# CUSTOM: Section header string table index: 4
+## Check we can override all default values using the same values
+## and that this does not change the output.
+# RUN: yaml2obj --docnum=2 %s -o %t-default-override
+# RUN: cmp %t-default %t-default-override
--- !ELF
FileHeader:
@@ -34,28 +29,37 @@ FileHeader:
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
- SHEntSize: 64
- SHOff: 2
- SHNum: 3
- SHStrNdx: 4
+ SHEntSize: [[SHENTSIZE=64]]
+ SHOff: [[SHOFF=88]]
+ SHNum: [[SHNUM=3]]
+ SHStrNdx: [[SHSTRNDX=2]]
+
+## Override
diff erent fields to check the output produced.
+
+## Override the e_shoff field.
+# RUN: yaml2obj --docnum=2 %s -DSHOFF=3 -o %t2
+# RUN: llvm-readelf --file-headers %t2 | FileCheck %s --check-prefix=SHOFF
+
+# SHOFF: Start of section headers: 3 (bytes into file)
+
+## Override the e_shnum field.
+# RUN: yaml2obj --docnum=2 %s -DSHNUM=2 -o %t3
+# RUN: llvm-readelf --file-headers %t3 | FileCheck %s --check-prefix=SHNUM
+
+# SHNUM: Number of section headers: 2{{$}}
+
+## Override the e_shstrndx field.
+# RUN: yaml2obj --docnum=2 %s -DSHSTRNDX=4 -o %t4
+# RUN: llvm-readelf --file-headers %t4 | FileCheck %s --check-prefix=SHSTRNDX
-## Finally, we use the same YAML as above, but set e_shentsize to 1.
+# SHSTRNDX: Section header string table index: 4{{$}}
+
+## Override the e_shentsize field.
## Check the result using raw output from 'od' because llvm-readelf
## is unable to dump such headers.
-# RUN: yaml2obj --docnum=3 %s -o %t3
-# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t3 | FileCheck %s --check-prefix=NEWSIZE
-# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t2 | FileCheck %s --check-prefix=OLDSIZE
+# RUN: yaml2obj --docnum=2 %s -DSHENTSIZE=1 -o %t5
+# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t5 | FileCheck %s --check-prefix=NEWSIZE
+# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t-default | FileCheck %s --check-prefix=OLDSIZE
# NEWSIZE: 01
# OLDSIZE: 40
-
---- !ELF
-FileHeader:
- Class: ELFCLASS64
- Data: ELFDATA2LSB
- Type: ET_REL
- Machine: EM_X86_64
- SHEntSize: 1
- SHOff: 2
- SHNum: 3
- SHStrNdx: 4
More information about the llvm-commits
mailing list