Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-strings] Improve testing of llvm-strings
This patch tidies up the llvm-strings testing by: 1. Adding comments to every test. 2. Getting rid of canned input files, and having the tests generate them on the fly (this makes the tests self-contained). 3. Adding missing test coverage. 4. Renaming some tests that weren't clear as to their purpose. 5. Adding extra checking of various cases, formatting etc. 6. Removing a test that didn't seem to have any useful purpose for testing llvm-strings. Reviewed by: rupprecht, grimar, MaskRay Differential Revision: https://reviews.llvm.org/D66015 llvm-svn: 368555
- Loading branch information
Showing
23 changed files
with
216 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
RUN: llvm-strings -a %S/Inputs/abcd | FileCheck %s | ||
RUN: llvm-strings --all %S/Inputs/abcd | FileCheck %s | ||
## Show that the -a/--all switch is accepted. GNU strings checks specific object | ||
## file sections unless --all is specified. llvm-strings just looks at the entire | ||
## file, so this option is silently ignored. | ||
|
||
RUN: echo abcd | llvm-strings -a | FileCheck %s | ||
RUN: echo abcd | llvm-strings --all | FileCheck %s | ||
CHECK: abcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
## Show that --print-file-name prints just the archive name for an archive and | ||
## not the member names. | ||
|
||
RUN: rm -rf %t && mkdir -p %t | ||
RUN: llvm-ar --format=gnu crs %t/archive.a %S/Inputs/abcd | ||
RUN: echo -n abcd > %t/abcd | ||
RUN: llvm-ar --format=gnu crs %t/archive.a %t/abcd | ||
RUN: llvm-strings -f %t/archive.a | FileCheck %s | ||
RUN: llvm-strings --print-file-name %t/archive.a | FileCheck %s | ||
|
||
CHECK: archive.a: !<arch> | ||
CHECK: archive.a: abcd/ 0 0 0 644 4 ` | ||
CHECK: archive.a: abcd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Show that llvm-strings does not print the last string in the input if it is | ||
## too short and no unprintable character follows it. | ||
|
||
RUN: echo -n abc | llvm-strings - | FileCheck --allow-empty %s | ||
CHECK-NOT: abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Show that llvm-strings prints the last string in the input even if no | ||
## unprintable character follows it. | ||
|
||
RUN: echo -n abcdefg | llvm-strings - | FileCheck %s | ||
CHECK: abcdefg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
RUN: llvm-strings -f %S/Inputs/abcd | FileCheck %s | ||
RUN: llvm-strings --print-file-name %S/Inputs/abcd | FileCheck %s --strict-whitespace | ||
CHECK: {{[\\/]}}abcd: abcd | ||
## Show that --print-file-name prints the name of the file before each line in | ||
## the output. | ||
|
||
RUN: echo abcd > %t | ||
RUN: echo efg >> %t | ||
RUN: echo hijk >> %t | ||
RUN: llvm-strings -f %t | FileCheck %s --strict-whitespace -DFILE=%t | ||
RUN: llvm-strings --print-file-name %t | FileCheck %s --strict-whitespace -DFILE=%t | ||
CHECK: [[FILE]]: abcd | ||
CHECK-NEXT: [[FILE]]: hijk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
RUN: llvm-strings -h | FileCheck %s | ||
RUN: llvm-strings --help | FileCheck %s | ||
## Show that help text is printed correctly when requested. | ||
|
||
RUN: llvm-strings -h | FileCheck %s --check-prefixes=CHECK,CATEG | ||
RUN: llvm-strings --help | FileCheck %s --check-prefixes=CHECK,CATEG | ||
RUN: llvm-strings --help-list \ | ||
RUN: | FileCheck %s --check-prefixes=CHECK,LIST | ||
|
||
CHECK: OVERVIEW: llvm string dumper | ||
CHECK: USAGE: llvm-strings{{(.exe)?}} [options] <input object files>{{$}} | ||
CHECK: OPTIONS: | ||
CATEG: General options: | ||
LIST-NOT: General options: | ||
CATEG: Generic Options: | ||
LIST-NOT: Generic Options: | ||
CHECK: @FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,46 @@ | ||
RUN: not llvm-strings -n 0 2>&1 %S/Inputs/variable-length | FileCheck --check-prefix CHECK-0 %s | ||
RUN: llvm-strings -n 1 %S/Inputs/variable-length | FileCheck --check-prefix CHECK-1 %s | ||
RUN: llvm-strings -n 2 %S/Inputs/variable-length | FileCheck --check-prefix CHECK-2 %s | ||
RUN: llvm-strings %S/Inputs/variable-length | FileCheck --check-prefix CHECK-DEFAULT %s | ||
## Show that llvm-strings prints only strings with length of at least the | ||
## requested number of bytes. | ||
|
||
STDIN: a | ||
STDIN: ab | ||
STDIN: abc | ||
STDIN: abcd | ||
RUN: echo a > %t | ||
RUN: echo ab >> %t | ||
RUN: echo abc >> %t | ||
RUN: echo abcd >> %t | ||
RUN: echo abcde >> %t | ||
RUN: not llvm-strings -n 0 2>&1 %t | FileCheck --check-prefix CHECK-0 %s | ||
RUN: llvm-strings -n 1 %t | FileCheck --check-prefix CHECK-1 %s --implicit-check-not={{.}} | ||
RUN: llvm-strings -n 2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}} | ||
RUN: llvm-strings -n 4 %t | FileCheck --check-prefix CHECK-4 %s --implicit-check-not={{.}} | ||
RUN: llvm-strings -n 5 %t | FileCheck --check-prefix CHECK-5 %s --implicit-check-not={{.}} | ||
RUN: llvm-strings -n 6 %t | FileCheck %s --implicit-check-not={{.}} --allow-empty | ||
|
||
CHECK-DEFAULT: abcd | ||
## Default is equivalent to -n 4. | ||
RUN: llvm-strings %t | FileCheck --check-prefix CHECK-4 %s --implicit-check-not={{.}} | ||
|
||
## Show --bytes works too. | ||
RUN: llvm-strings --bytes 2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}} | ||
|
||
## Show different syntaxes work. | ||
RUN: llvm-strings --bytes=2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}} | ||
RUN: llvm-strings -n=2 %t | FileCheck --check-prefix CHECK-2 %s --implicit-check-not={{.}} | ||
|
||
CHECK-0: invalid minimum string length 0 | ||
|
||
CHECK-1: a | ||
CHECK-1: ab | ||
CHECK-1: abc | ||
CHECK-1: abcd | ||
CHECK-1: a | ||
CHECK-1-NEXT: ab | ||
CHECK-1-NEXT: abc | ||
CHECK-1-NEXT: abcd | ||
CHECK-1-NEXT: abcde | ||
|
||
CHECK-2: ab | ||
CHECK-2-NEXT: abc | ||
CHECK-2-NEXT: abcd | ||
CHECK-2-NEXT: abcde | ||
|
||
CHECK-4: abcd | ||
CHECK-4-NEXT: abcde | ||
|
||
CHECK-2-NOT: a | ||
CHECK-2: ab | ||
CHECK-2: abc | ||
CHECK-2: abcd | ||
CHECK-5: abcde | ||
|
||
## Show that a non-numeric argument is rejected. | ||
RUN: not llvm-strings -n foo %t 2>&1 | FileCheck %s --check-prefix=ERR | ||
ERR: llvm-strings{{.*}}: for the --bytes option: 'foo' value invalid for integer argument! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Show that llvm-strings reads every file specified on the command-line. | ||
## This test uses --print-file-name and --radix to show that the values are | ||
## updated for the second file. | ||
|
||
RUN: echo abcd > %t1 | ||
RUN: echo 1234 >> %t1 | ||
RUN: echo defg > %t2 | ||
RUN: llvm-strings --print-file-name --radix=d %t1 %t2 \ | ||
RUN: | FileCheck %s -DFILE1=%t1 -DFILE2=%t2 --implicit-check-not={{.}} | ||
|
||
CHECK: [[FILE1]]: 0 abcd | ||
CHECK-NEXT: [[FILE1]]: 5 1234 | ||
CHECK-NEXT: [[FILE2]]: 0 defg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## Show that llvm-strings can handle a negative signed char value (i.e. > 0x7f). | ||
## Such characters should form string delimiters like other unprintable ones. | ||
|
||
# RUN: echo -e "z\0\x80\0a\0" | llvm-strings --bytes 1 - | FileCheck %s | ||
# CHECK: z{{$}} | ||
# CHECK-NEXT: {{^}}a |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Show that llvm-strings can handle grouped short options. | ||
|
||
RUN: echo abcd > %t | ||
RUN: llvm-strings -af %t | FileCheck %s -DFILE=%t | ||
|
||
CHECK: [[FILE]]: abcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
RUN: llvm-strings --print-file-name %S/Inputs/numbers \ | ||
RUN: | FileCheck %s --check-prefix CHECK-NONE | ||
RUN: llvm-strings --print-file-name -t d %S/Inputs/numbers \ | ||
RUN: | FileCheck %s --check-prefix CHECK-DEC --strict-whitespace | ||
RUN: llvm-strings --print-file-name -t o %S/Inputs/numbers \ | ||
RUN: | FileCheck %s --check-prefix CHECK-OCT --strict-whitespace | ||
RUN: llvm-strings --print-file-name -t x %S/Inputs/numbers \ | ||
RUN: | FileCheck %s --check-prefix CHECK-HEX --strict-whitespace | ||
## Show that --radix combined with --print-file-name produces correct output. | ||
|
||
CHECK-NONE: numbers: three | ||
CHECK-NONE: numbers: four | ||
CHECK-NONE: numbers: five | ||
CHECK-NONE: numbers: seven | ||
CHECK-NONE: numbers: eight | ||
CHECK-NONE: numbers: nine | ||
RUN: echo one > %t | ||
RUN: echo two >> %t | ||
RUN: echo three >> %t | ||
RUN: echo four >> %t | ||
RUN: echo five >> %t | ||
RUN: echo six >> %t | ||
RUN: echo seven >> %t | ||
RUN: echo eight >> %t | ||
RUN: echo nine >> %t | ||
RUN: echo ten >> %t | ||
|
||
CHECK-DEC: numbers: 8 three | ||
CHECK-DEC: numbers: 14 four | ||
CHECK-DEC: numbers: 19 five | ||
CHECK-DEC: numbers: 28 seven | ||
CHECK-DEC: numbers: 34 eight | ||
CHECK-DEC: numbers: 40 nine | ||
RUN: llvm-strings --print-file-name %t \ | ||
RUN: | FileCheck %s --check-prefix CHECK-NONE -DFILE=%t --implicit-check-not={{.}} | ||
RUN: llvm-strings --print-file-name -t d %t \ | ||
RUN: | FileCheck %s --check-prefix CHECK-DEC --strict-whitespace -DFILE=%t --implicit-check-not={{.}} | ||
RUN: llvm-strings --print-file-name -t o %t \ | ||
RUN: | FileCheck %s --check-prefix CHECK-OCT --strict-whitespace -DFILE=%t --implicit-check-not={{.}} | ||
RUN: llvm-strings --print-file-name -t x %t \ | ||
RUN: | FileCheck %s --check-prefix CHECK-HEX --strict-whitespace -DFILE=%t --implicit-check-not={{.}} | ||
|
||
CHECK-OCT: numbers: 10 three | ||
CHECK-OCT: numbers: 16 four | ||
CHECK-OCT: numbers: 23 five | ||
CHECK-OCT: numbers: 34 seven | ||
CHECK-OCT: numbers: 42 eight | ||
CHECK-OCT: numbers: 50 nine | ||
CHECK-NONE: [[FILE]]: three | ||
CHECK-NONE: [[FILE]]: four | ||
CHECK-NONE: [[FILE]]: five | ||
CHECK-NONE: [[FILE]]: seven | ||
CHECK-NONE: [[FILE]]: eight | ||
CHECK-NONE: [[FILE]]: nine | ||
|
||
CHECK-HEX: numbers: 8 three | ||
CHECK-HEX: numbers: e four | ||
CHECK-HEX: numbers: 13 five | ||
CHECK-HEX: numbers: 1c seven | ||
CHECK-HEX: numbers: 22 eight | ||
CHECK-HEX: numbers: 28 nine | ||
CHECK-DEC: [[FILE]]: 8 three | ||
CHECK-DEC: [[FILE]]: 14 four | ||
CHECK-DEC: [[FILE]]: 19 five | ||
CHECK-DEC: [[FILE]]: 28 seven | ||
CHECK-DEC: [[FILE]]: 34 eight | ||
CHECK-DEC: [[FILE]]: 40 nine | ||
|
||
CHECK-OCT: [[FILE]]: 10 three | ||
CHECK-OCT: [[FILE]]: 16 four | ||
CHECK-OCT: [[FILE]]: 23 five | ||
CHECK-OCT: [[FILE]]: 34 seven | ||
CHECK-OCT: [[FILE]]: 42 eight | ||
CHECK-OCT: [[FILE]]: 50 nine | ||
|
||
CHECK-HEX: [[FILE]]: 8 three | ||
CHECK-HEX: [[FILE]]: e four | ||
CHECK-HEX: [[FILE]]: 13 five | ||
CHECK-HEX: [[FILE]]: 1c seven | ||
CHECK-HEX: [[FILE]]: 22 eight | ||
CHECK-HEX: [[FILE]]: 28 nine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Show that llvm-strings can consume a response file. | ||
|
||
RUN: echo abcd > %t | ||
RUN: echo --print-file-name %t > %t.rsp | ||
RUN: llvm-strings --radix=d @%t.rsp | FileCheck %s -DFILE=%t | ||
|
||
CHECK: [[FILE]]: 0 abcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## Show that --print-file-name works when the input is standard input. | ||
|
||
RUN: echo abcd | llvm-strings -f - | FileCheck %s | ||
RUN: echo abcd | llvm-strings -f | FileCheck %s | ||
RUN: echo abcd | llvm-strings --print-file-name - | FileCheck %s | ||
RUN: echo abcd | llvm-strings --print-file-name | FileCheck %s | ||
CHECK: {standard input}: abcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Show that llvm-strings can handle stdin input properly. | ||
|
||
## Case 1: output with single string. | ||
RUN: echo -n "abcdefg" | llvm-strings - | FileCheck %s --check-prefix=CASE1 --implicit-check-not={{.}} | ||
CASE1: abcdefg | ||
|
||
## Case 2: output too short for string. | ||
RUN: echo -n "abc" | llvm-strings - | FileCheck %s --implicit-check-not={{.}} --allow-empty | ||
|
||
## Case 3: output with new line. | ||
RUN: echo -e "abcd\nefgh" | llvm-strings - | FileCheck %s --check-prefix=CASE3 --implicit-check-not={{.}} | ||
CASE3: abcd | ||
CASE3-NEXT: efgh | ||
|
||
## Case 4: output containing unprintable characters. | ||
RUN: echo -e "abcd\x00ef\x1fghij\x7fklmn" | llvm-strings - | FileCheck %s --check-prefix=CASE4 --implicit-check-not={{.}} | ||
CASE4: abcd | ||
CASE4-NEXT: ghij | ||
CASE4-NEXT: klmn | ||
|
||
## Case 5: no file name specified is equivalent to explicitly requesting stdin. | ||
RUN: echo -n "abcdefg" | llvm-strings | FileCheck %s --check-prefix=CASE1 --implicit-check-not={{.}} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Show that --version works for llvm-strings. | ||
|
||
RUN: llvm-strings --version | FileCheck %s | ||
CHECK: version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
RUN: echo -n abcd | llvm-strings - | FileCheck %s --strict-whitespace | ||
## Show that the default output format matches GNU strings. | ||
RUN: echo -n abcd | llvm-strings - | FileCheck %s --strict-whitespace --implicit-check-not={{.}} | ||
CHECK: {{^}}abcd{{$}} |