brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.7 KiB · 0eca56a Raw
152 lines · plain
1## This test checks that llvm-objcopy accepts glob (or "shell wildcard") syntax2## for the --wildcard (-w) flag correctly.3 4# RUN: yaml2obj --docnum=1 %s -o %t.o5 6## * matches all characters.7# RUN: llvm-objcopy --remove-section='.f*' %t.o %t.glob.o8# RUN: llvm-readobj --sections %t.glob.o \9# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR10 11## Glob matches are full matches. ("*a" does not match ".bar").12# RUN: llvm-objcopy --remove-section='*a' %t.o %t.full.o13# RUN: llvm-readobj --sections %t.full.o \14# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO,BAR15 16## ? matches one character.17# RUN: llvm-objcopy --remove-section='.b?r' %t.o %t.question.o18# RUN: llvm-readobj --sections %t.question.o \19# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO20 21## ! (as a leading character) prevents matches, and is not dependent on22## ordering.23# RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \24# RUN:   %t.o %t.negmatch1.o25# RUN: llvm-readobj --sections %t.negmatch1.o \26# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO27# RUN: llvm-objcopy --remove-section='!.f*' --remove-section='.???' \28# RUN:   %t.o %t.negmatch2.o29# RUN: llvm-readobj --sections %t.negmatch2.o \30# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO31# RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \32# RUN:   --remove-section='.???' %t.o %t.negmatch3.o33# RUN: llvm-readobj --sections %t.negmatch3.o \34# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO35 36## [a-z] matches a range of characters.37# RUN: llvm-objcopy --remove-section='.[a-c][a-a][q-s]' %t.o %t.range.o38# RUN: llvm-readobj --sections %t.range.o \39# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO40 41## [^a-z] or [!a-z] match a negated range of characters.42# RUN: llvm-objcopy --remove-section='.[^x]oo' %t.o %t.negrange.1.o43# RUN: llvm-readobj --sections %t.negrange.1.o \44# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR45# RUN: llvm-objcopy --remove-section='.[!x]oo' %t.o %t.negrange.2.o46# RUN: llvm-readobj --sections %t.negrange.2.o \47# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR48 49--- !ELF50FileHeader:51  Class:   ELFCLASS6452  Data:    ELFDATA2LSB53  Type:    ET_REL54  Machine: EM_X86_6455Sections:56  - Name: .foo57    Type: SHT_PROGBITS58  - Name: .bar59    Type: SHT_PROGBITS60Symbols: []61 62## Use a separate test file with special characters for the following tests.63 64# RUN: yaml2obj --docnum=2 %s -o %t.special.o65 66## \ escapes wildcard characters.67# RUN: llvm-objcopy --remove-section='\*' %t.special.o %t.escape.1.o68# RUN: llvm-readobj --sections %t.escape.1.o \69# RUN:   | FileCheck %s --implicit-check-not=Name: \70# RUN:   --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO71# RUN: llvm-objcopy --remove-section='\?' %t.special.o %t.escape.2.o72# RUN: llvm-readobj --sections %t.escape.2.o \73# RUN:   | FileCheck %s --implicit-check-not=Name: \74# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO75 76## Special characters are not treated like regular expression characters.77# RUN: llvm-objcopy --remove-section='.' %t.special.o %t.dot.o78# RUN: llvm-readobj --sections %t.dot.o \79# RUN:   | FileCheck %s --implicit-check-not=Name: \80# RUN:   --check-prefixes=CHECK,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO81 82## Special characters in character classes are treated literally.83## [*] should not get expanded to [.*], which would match both '.' and '*'84# RUN: llvm-objcopy --remove-section='[*]' %t.special.o %t.class.1.o85# RUN: llvm-readobj --sections %t.class.1.o \86# RUN:   | FileCheck %s --implicit-check-not=Name: \87# RUN:   --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO88 89## ] doesn't close the character class as a first character. This glob matches90## a single character which is one of ']xyz'. ']' and 'z' are removed, and more explicitly,91## section 'xyz]' is not removed, i.e. the glob is not interpreted as "an empty92## character class followed by 'xyz]'"93# RUN: llvm-objcopy --remove-section='[]xyz]' %t.special.o %t.class.2.o94# RUN: llvm-readobj --sections %t.class.2.o \95# RUN:   | FileCheck %s --implicit-check-not=Name: \96# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,INVALID-GLOB,XYZ,FOO97 98## An invalid glob expression is interpreted as a literal instead.99# RUN: llvm-objcopy --remove-section='][]' %t.special.o %t.class.3.o 2>&1 \100# RUN:   | FileCheck %s --check-prefix=WARN101# RUN: llvm-readobj --sections %t.class.3.o \102# RUN:   | FileCheck %s --implicit-check-not=Name: \103# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,Z,XYZ,FOO104 105--- !ELF106FileHeader:107  Class:   ELFCLASS64108  Data:    ELFDATA2LSB109  Type:    ET_REL110  Machine: EM_X86_64111Sections:112  - Name: .113    Type: SHT_PROGBITS114  - Name: '*'115    Type: SHT_PROGBITS116  - Name: '?'117    Type: SHT_PROGBITS118  - Name: '['119    Type: SHT_PROGBITS120  - Name: ']'121    Type: SHT_PROGBITS122  - Name: '][]'123    Type: SHT_PROGBITS124  - Name: z125    Type: SHT_PROGBITS126  - Name: 'xyz]'127    Type: SHT_PROGBITS128  - Name: '[]xyz]'129    Type: SHT_PROGBITS130  - Name: .foo131    Type: SHT_PROGBITS132Symbols: []133 134# WARN: warning: invalid glob pattern, unmatched '['135 136# CHECK: LoadName:137# CHECK:         Name: (0)138# DOT:           Name: .139# ASTERISK:      Name: *140# QUESTION:      Name: ?141# LEFT-BRACKET:  Name: [142# RIGHT-BRACKET: Name: ]143# INVALID-GLOB:  Name: ][]144# Z:             Name: z145# XYZ:           Name: xyz]146# XYZ:           Name: []xyz]147# FOO:           Name: .foo148# BAR:           Name: .bar149# CHECK:         Name: .symtab150# CHECK:         Name: .strtab151# CHECK:         Name: .shstrtab152