llvm.org GIT mirror llvm / f8592d2
[llvm-objcopy][IHEX] Improve test case formatting. NFC Differential revision: https://reviews.llvm.org/D63258 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363359 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Leviant 3 months ago
1 changed file(s) with 135 addition(s) and 122 deletion(s). Raw diff Collapse all Expand all
None # Check section headers when converting from hex to ELF
0 ## Check section headers when converting from hex to ELF.
11 # RUN: yaml2obj %p/Inputs/ihex-elf-sections.yaml -o %t
22 # RUN: llvm-objcopy -O ihex %t %t.hex
33 # RUN: llvm-objcopy -I ihex -O elf32-i386 %t.hex %t2
4 # RUN: llvm-readobj -section-headers %t2 | FileCheck %s
5
6 # Check section contents
4 # RUN: llvm-readobj --section-headers %t2 | FileCheck %s
5
6 # CHECK: Index: 1
7 # CHECK-NEXT: Name: .sec1
8 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
9 # CHECK-NEXT: Flags [ (0x3)
10 # CHECK-NEXT: SHF_ALLOC (0x2)
11 # CHECK-NEXT: SHF_WRITE (0x1)
12 # CHECK-NEXT: ]
13 # CHECK-NEXT: Address: 0x0
14 # CHECK-NEXT: Offset: 0x34
15 # CHECK-NEXT: Size: 21
16 # CHECK-NEXT: Link: 0
17 # CHECK-NEXT: Info: 0
18 # CHECK-NEXT: AddressAlignment: 1
19 # CHECK-NEXT: EntrySize: 0
20
21 # CHECK: Index: 2
22 # CHECK-NEXT: Name: .sec2
23 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
24 # CHECK-NEXT: Flags [ (0x3)
25 # CHECK-NEXT: SHF_ALLOC (0x2)
26 # CHECK-NEXT: SHF_WRITE (0x1)
27 # CHECK-NEXT: ]
28 # CHECK-NEXT: Address: 0xFFF8
29 # CHECK-NEXT: Offset: 0x49
30 # CHECK-NEXT: Size: 11
31 # CHECK-NEXT: Link: 0
32 # CHECK-NEXT: Info: 0
33 # CHECK-NEXT: AddressAlignment: 1
34 # CHECK-NEXT: EntrySize: 0
35
36 # CHECK: Index: 3
37 # CHECK-NEXT: Name: .sec3
38 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
39 # CHECK-NEXT: Flags [ (0x3)
40 # CHECK-NEXT: SHF_ALLOC (0x2)
41 # CHECK-NEXT: SHF_WRITE (0x1)
42 # CHECK-NEXT: ]
43 # CHECK-NEXT: Address: 0x10100
44 # CHECK-NEXT: Offset: 0x54
45 # CHECK-NEXT: Size: 4
46 # CHECK-NEXT: Link: 0
47 # CHECK-NEXT: Info: 0
48 # CHECK-NEXT: AddressAlignment: 1
49 # CHECK-NEXT: EntrySize: 0
50
51 # CHECK: Index: 4
52 # CHECK-NEXT: Name: .sec4
53 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
54 # CHECK-NEXT: Flags [ (0x3)
55 # CHECK-NEXT: SHF_ALLOC (0x2)
56 # CHECK-NEXT: SHF_WRITE (0x1)
57 # CHECK-NEXT: ]
58 # CHECK-NEXT: Address: 0x10FFF8
59 # CHECK-NEXT: Offset: 0x58
60 # CHECK-NEXT: Size: 11
61 # CHECK-NEXT: Link: 0
62 # CHECK-NEXT: Info: 0
63 # CHECK-NEXT: AddressAlignment: 1
64 # CHECK-NEXT: EntrySize: 0
65
66 ## Check section contents.
767 # RUN: llvm-objcopy -O binary --only-section=.text %t %t.text
868 # RUN: llvm-objcopy -O binary --only-section=.sec1 %t2 %t2.sec1
969 # RUN: cmp %t.text %t2.sec1
1777 # RUN: llvm-objcopy -O binary --only-section=.sec4 %t2 %t2.sec4
1878 # RUN: cmp %t.data3 %t2.sec4
1979
20 # Check loading from raw hex file
80 ## Check loading from raw hex file.
2181 # RUN: llvm-objcopy -I ihex -O elf32-i386 %p/Inputs/sections.hex %t-raw
22 # RUN: llvm-readobj -section-headers %t-raw | FileCheck %s --check-prefix=RAW
23
24 # Check section contents
25 # RUN: llvm-objcopy -O ihex --only-section=.sec1 %t-raw - | FileCheck %s --check-prefix=RAW-SEC1
26 # RUN: llvm-objcopy -O ihex --only-section=.sec2 %t-raw - | FileCheck %s --check-prefix=RAW-SEC2
27 # RUN: llvm-objcopy -O ihex --only-section=.sec3 %t-raw - | FileCheck %s --check-prefix=RAW-SEC3
28
29 # Check that line is trimmed from whitespace
30 # RUN: echo " :0100000001FE " | llvm-objcopy -I ihex -O elf64-x86-64 - - \
31 # RUN: | llvm-objcopy -O ihex - - | FileCheck %s --check-prefix=SPACES
32
33 # Check for various parsing errors
34 # 1. String too short
35 # RUN: echo "01000000FF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_LENGTH
36
37 # 2. missing ':'
38 # RUN: echo "0100000000FF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=MISSING_COLON
39
40 # 3. invalid charatcer
41 # RUN: echo ":01000000xF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_CHAR
42
43 # 4. incorrect string length
44 # RUN: echo ":010000000000000F" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_LENGTH2
45
46 # 5. invalid type (06)
47 # RUN: echo ":00000006FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_TYPE
48
49 # 6. invalid checksum
50 # RUN: echo ":00000001FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_CKSUM
51
52 # 7. zero data length
53 # RUN: echo ":00010000FF" | not llvm-objcopy -I ihex - - 2>&1 | FileCheck %s --check-prefix=ZERO_DATA_LEN
54
55 # 8. Bad data length for '02' (SegmentAddr) record
56 # RUN: echo ":03000002000000FB" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_SEGADDR_LEN
57
58 # 9. Bad data length for '03' (StartAddr80x86) record
59 # RUN: echo ":03000003000000FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR_LEN
60
61 # 10. Bad data length for '05' (StartAddr) record
62 # RUN: echo ":03000005000000F8" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR_LEN
63
64 # 11. Address value for 'StartAddr80x86' is greater then 0xFFFFFU
65 # RUN: echo ":04000003FFFFFFFFFD" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR
66
67 # 12. Invalid extended address data size
68 # RUN: echo ":04000004FFFFFFFFFC" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_EXTADDR_LEN
69
70 # 13. no sections in the hex file
71 # a) try empty file:
72 # RUN: echo "" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=NO_SECTIONS
73 # b) EOF record should cancel processing further records. Not having any section data
74 # before EOF should trigger an error
75 # RUN: echo ":00000001FF" > %t-bad14.hex
76 # RUN: echo ":0100000001FE" >> %t-bad14.hex
77 # RUN: not llvm-objcopy -I ihex %t-bad14.hex %t-none 2>&1 | FileCheck %s --check-prefix=NO_SECTIONS
78
79 # CHECK: Index: 1
80 # CHECK-NEXT: Name: .sec1
81 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
82 # CHECK-NEXT: Flags [ (0x3)
83 # CHECK-NEXT: SHF_ALLOC (0x2)
84 # CHECK-NEXT: SHF_WRITE (0x1)
85 # CHECK-NEXT: ]
86 # CHECK-NEXT: Address: 0x0
87 # CHECK-NEXT: Offset: 0x34
88 # CHECK-NEXT: Size: 21
89 # CHECK-NEXT: Link: 0
90 # CHECK-NEXT: Info: 0
91 # CHECK-NEXT: AddressAlignment: 1
92 # CHECK-NEXT: EntrySize: 0
93
94 # CHECK: Index: 2
95 # CHECK-NEXT: Name: .sec2
96 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
97 # CHECK-NEXT: Flags [ (0x3)
98 # CHECK-NEXT: SHF_ALLOC (0x2)
99 # CHECK-NEXT: SHF_WRITE (0x1)
100 # CHECK-NEXT: ]
101 # CHECK-NEXT: Address: 0xFFF8
102 # CHECK-NEXT: Offset: 0x49
103 # CHECK-NEXT: Size: 11
104 # CHECK-NEXT: Link: 0
105 # CHECK-NEXT: Info: 0
106 # CHECK-NEXT: AddressAlignment: 1
107 # CHECK-NEXT: EntrySize: 0
108
109 # CHECK: Index: 3
110 # CHECK-NEXT: Name: .sec3
111 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
112 # CHECK-NEXT: Flags [ (0x3)
113 # CHECK-NEXT: SHF_ALLOC (0x2)
114 # CHECK-NEXT: SHF_WRITE (0x1)
115 # CHECK-NEXT: ]
116 # CHECK-NEXT: Address: 0x10100
117 # CHECK-NEXT: Offset: 0x54
118 # CHECK-NEXT: Size: 4
119 # CHECK-NEXT: Link: 0
120 # CHECK-NEXT: Info: 0
121 # CHECK-NEXT: AddressAlignment: 1
122 # CHECK-NEXT: EntrySize: 0
123
124 # CHECK: Index: 4
125 # CHECK-NEXT: Name: .sec4
126 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
127 # CHECK-NEXT: Flags [ (0x3)
128 # CHECK-NEXT: SHF_ALLOC (0x2)
129 # CHECK-NEXT: SHF_WRITE (0x1)
130 # CHECK-NEXT: ]
131 # CHECK-NEXT: Address: 0x10FFF8
132 # CHECK-NEXT: Offset: 0x58
133 # CHECK-NEXT: Size: 11
134 # CHECK-NEXT: Link: 0
135 # CHECK-NEXT: Info: 0
136 # CHECK-NEXT: AddressAlignment: 1
137 # CHECK-NEXT: EntrySize: 0
138
82 # RUN: llvm-readobj --section-headers %t-raw | FileCheck %s --check-prefix=RAW
83
13984 # RAW: Index: 1
14085 # RAW-NEXT: Name: .sec1
14186 # RAW-NEXT: Type: SHT_PROGBITS (0x1)
169114 # RAW-NEXT: Offset: 0x4A
170115 # RAW-NEXT: Size: 11
171116
117 ## Check section contents.
118 # RUN: llvm-objcopy -O ihex --only-section=.sec1 %t-raw - | FileCheck %s --check-prefix=RAW-SEC1
119
172120 # RAW-SEC1: :020000021000EC
173121 # RAW-SEC1-NEXT: :08FFF8000001020304050607E5
174122 # RAW-SEC1-NEXT: :020000022000DC
175123 # RAW-SEC1-NEXT: :0300000008090AE2
124
125 # RUN: llvm-objcopy -O ihex --only-section=.sec2 %t-raw - | FileCheck %s --check-prefix=RAW-SEC2
176126
177127 # RAW-SEC2: :02000002F0000C
178128 # RAW-SEC2-NEXT: :08FFF800303132333435363765
180130 # RAW-SEC2-NEXT: :020000040010EA
181131 # RAW-SEC2-NEXT: :030000003839404C
182132
133 # RUN: llvm-objcopy -O ihex --only-section=.sec3 %t-raw - | FileCheck %s --check-prefix=RAW-SEC3
134
183135 # RAW-SEC3: :02000004001FDB
184136 # RAW-SEC3-NEXT: :08FFF8004041424344454647E5
185137 # RAW-SEC3-NEXT: :020000040020DA
186138 # RAW-SEC3-NEXT: :030000004849501C
187139
140 ## Check that line is trimmed from whitespace.
141 # RUN: echo " :0100000001FE " | llvm-objcopy -I ihex -O elf64-x86-64 - - \
142 # RUN: | llvm-objcopy -O ihex - - | FileCheck %s --check-prefix=SPACES
143
188144 # SPACES: :0100000001FE
189145 # SPACES-NEXT: :00000001FF
190146
147 ## Check for various parsing errors.
148 ## 1. String too short.
149 # RUN: echo "01000000FF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_LENGTH
150
191151 # BAD_LENGTH: error: '{{.*}}': line 1: line is too short: 10 chars
152
153 ## 2. Missing ':'.
154 # RUN: echo "0100000000FF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=MISSING_COLON
155
192156 # MISSING_COLON: error: '{{.*}}': line 1: missing ':' in the beginning of line
157
158 ## 3. Invalid charatcer.
159 # RUN: echo ":01000000xF" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_CHAR
160
193161 # BAD_CHAR: error: '{{.*}}': line 1: invalid character at position 10
162
163 ## 4. Incorrect string length.
164 # RUN: echo ":010000000000000F" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_LENGTH2
165
194166 # BAD_LENGTH2: error: '{{.*}}': line 1: invalid line length 17 (should be 13)
167
168 ## 5. Invalid type (06).
169 # RUN: echo ":00000006FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_TYPE
170
195171 # BAD_TYPE: error: '{{.*}}': line 1: unknown record type: 6
172
173 ## 6. Invalid checksum.
174 # RUN: echo ":00000001FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_CKSUM
175
196176 # BAD_CKSUM: error: '{{.*}}': line 1: incorrect checksum
177
178 ## 7. Zero data length.
179 # RUN: echo ":00010000FF" | not llvm-objcopy -I ihex - - 2>&1 | FileCheck %s --check-prefix=ZERO_DATA_LEN
180
197181 # ZERO_DATA_LEN: error: '{{.*}}': line 1: zero data length is not allowed for data records
182
183 ## 8. Bad data length for '02' (SegmentAddr) record.
184 # RUN: echo ":03000002000000FB" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_SEGADDR_LEN
185
198186 # BAD_SEGADDR_LEN: error: '{{.*}}': line 1: segment address data should be 2 bytes in size
187
188 ## 9. Bad data length for '03' (StartAddr80x86) record.
189 # RUN: echo ":03000003000000FA" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR_LEN
190
191 ## 10. Bad data length for '05' (StartAddr) record.
192 # RUN: echo ":03000005000000F8" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR_LEN
193
199194 # BAD_STARTADDR_LEN: error: '{{.*}}': line 1: start address data should be 4 bytes in size
195
196 ## 11. Address value for 'StartAddr80x86' is greater then 0xFFFFFU.
197 # RUN: echo ":04000003FFFFFFFFFD" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_STARTADDR
198
200199 # BAD_STARTADDR: error: '{{.*}}': line 1: start address exceeds 20 bit for 80x86
200
201 ## 12. Invalid extended address data size.
202 # RUN: echo ":04000004FFFFFFFFFC" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=BAD_EXTADDR_LEN
203
201204 # BAD_EXTADDR_LEN: error: '{{.*}}': line 1: extended address data should be 2 bytes in size
205
206 ## 13. No sections in the hex file.
207 ## a) try empty file:
208 # RUN: echo "" | not llvm-objcopy -I ihex -O elf32-i386 - - 2>&1 | FileCheck %s --check-prefix=NO_SECTIONS
209 ## b) EOF record should cancel processing further records. Not having any section data
210 ## before EOF should trigger an error.
211 # RUN: echo ":00000001FF" > %t-bad14.hex
212 # RUN: echo ":0100000001FE" >> %t-bad14.hex
213 # RUN: not llvm-objcopy -I ihex %t-bad14.hex %t-none 2>&1 | FileCheck %s --check-prefix=NO_SECTIONS
214
202215 # NO_SECTIONS: error: '{{.*}}': no sections