Index: test/tools/llvm-strings/Inputs/abcd =================================================================== --- test/tools/llvm-strings/Inputs/abcd +++ test/tools/llvm-strings/Inputs/abcd @@ -1 +0,0 @@ -abcd \ No newline at end of file Index: test/tools/llvm-strings/Inputs/numbers =================================================================== --- test/tools/llvm-strings/Inputs/numbers +++ test/tools/llvm-strings/Inputs/numbers @@ -1,10 +0,0 @@ -one -two -three -four -five -six -seven -eight -nine -ten Index: test/tools/llvm-strings/Inputs/variable-length =================================================================== --- test/tools/llvm-strings/Inputs/variable-length +++ test/tools/llvm-strings/Inputs/variable-length @@ -1,4 +0,0 @@ -a -ab -abc -abcd Index: test/tools/llvm-strings/all-sections.test =================================================================== --- test/tools/llvm-strings/all-sections.test +++ test/tools/llvm-strings/all-sections.test @@ -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 Index: test/tools/llvm-strings/archive-filename.test =================================================================== --- test/tools/llvm-strings/archive-filename.test +++ test/tools/llvm-strings/archive-filename.test @@ -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: ! CHECK: archive.a: abcd/ 0 0 0 644 4 ` CHECK: archive.a: abcd - Index: test/tools/llvm-strings/eof-no-string.test =================================================================== --- test/tools/llvm-strings/eof-no-string.test +++ test/tools/llvm-strings/eof-no-string.test @@ -1,2 +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 Index: test/tools/llvm-strings/eof.test =================================================================== --- test/tools/llvm-strings/eof.test +++ test/tools/llvm-strings/eof.test @@ -1,2 +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 Index: test/tools/llvm-strings/file-filename.test =================================================================== --- test/tools/llvm-strings/file-filename.test +++ test/tools/llvm-strings/file-filename.test @@ -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 Index: test/tools/llvm-strings/help.test =================================================================== --- test/tools/llvm-strings/help.test +++ test/tools/llvm-strings/help.test @@ -1,7 +1,13 @@ -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 --implicit-check-not="General options:" --implicit-check-not="Generic Options:" CHECK: OVERVIEW: llvm string dumper CHECK: USAGE: llvm-strings{{(.exe)?}} [options] {{$}} CHECK: OPTIONS: +CATEG: General options: +CATEG: Generic Options: CHECK: @FILE Index: test/tools/llvm-strings/length.test =================================================================== --- test/tools/llvm-strings/length.test +++ test/tools/llvm-strings/length.test @@ -1,24 +1,41 @@ -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 - -STDIN: a -STDIN: ab -STDIN: abc -STDIN: abcd +# Show that llvm-strings prints only strings with length of at least the +# requested number of bytes. -CHECK-DEFAULT: 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={{.}} + +# 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-2-NOT: a -CHECK-2: ab -CHECK-2: abc -CHECK-2: 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-5: abcde Index: test/tools/llvm-strings/multiple-inputs.test =================================================================== --- test/tools/llvm-strings/multiple-inputs.test +++ test/tools/llvm-strings/multiple-inputs.test @@ -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 Index: test/tools/llvm-strings/negative-char.test =================================================================== --- test/tools/llvm-strings/negative-char.test +++ test/tools/llvm-strings/negative-char.test @@ -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 Index: test/tools/llvm-strings/nested-archives.test =================================================================== --- test/tools/llvm-strings/nested-archives.test +++ test/tools/llvm-strings/nested-archives.test @@ -1,11 +0,0 @@ -RUN: rm -rf %t && mkdir -p %t -RUN: llvm-ar --format=gnu crs %t/inner.a %S/Inputs/abcd -RUN: llvm-ar --format=gnu crs %t/outer.a %t/inner.a -RUN: llvm-strings %t/outer.a | FileCheck %s - -CHECK: ! -CHECK: inner.a/ 0 0 0 644 72 ` -CHECK: ! -CHECK: abcd/ 0 0 0 644 4 ` -CHECK: abcd - Index: test/tools/llvm-strings/option-grouping.test =================================================================== --- test/tools/llvm-strings/option-grouping.test +++ test/tools/llvm-strings/option-grouping.test @@ -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 Index: test/tools/llvm-strings/radix-filename.test =================================================================== --- test/tools/llvm-strings/radix-filename.test +++ test/tools/llvm-strings/radix-filename.test @@ -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 - -CHECK-NONE: numbers: three -CHECK-NONE: numbers: four -CHECK-NONE: numbers: five -CHECK-NONE: numbers: seven -CHECK-NONE: numbers: eight -CHECK-NONE: numbers: nine - -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 - -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-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 +# Show that --radix combined with --print-file-name produces correct output. + +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 + +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-NONE: [[FILE]]: three +CHECK-NONE: [[FILE]]: four +CHECK-NONE: [[FILE]]: five +CHECK-NONE: [[FILE]]: seven +CHECK-NONE: [[FILE]]: eight +CHECK-NONE: [[FILE]]: 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 Index: test/tools/llvm-strings/radix.test =================================================================== --- test/tools/llvm-strings/radix.test +++ test/tools/llvm-strings/radix.test @@ -1,7 +1,29 @@ -RUN: llvm-strings %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-NONE -RUN: llvm-strings -t d %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace -RUN: llvm-strings -t o %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-OCT --strict-whitespace -RUN: llvm-strings -t x %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-HEX --strict-whitespace +# Show that llvm-strings can handle the -t/--radix switch properly. + +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 + +RUN: llvm-strings %t | FileCheck %s -check-prefix CHECK-NONE --implicit-check-not={{.}} +RUN: llvm-strings -t d %t | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace --implicit-check-not={{.}} +RUN: llvm-strings -t o %t | FileCheck %s -check-prefix CHECK-OCT --strict-whitespace --implicit-check-not={{.}} +RUN: llvm-strings -t x %t | FileCheck %s -check-prefix CHECK-HEX --strict-whitespace --implicit-check-not={{.}} + +# Show --radix works too. +RUN: llvm-strings --radix d %t | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace +RUN: llvm-strings --radix o %t | FileCheck %s -check-prefix CHECK-OCT --strict-whitespace +RUN: llvm-strings --radix x %t | FileCheck %s -check-prefix CHECK-HEX --strict-whitespace + +# Show different syntaxes work. +RUN: llvm-strings --radix=d %t | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace +RUN: llvm-strings -t=d %t | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace CHECK-NONE: {{^}}three CHECK-NONE: {{^}}four @@ -30,3 +52,7 @@ CHECK-HEX: {{^}} 1c seven CHECK-HEX: {{^}} 22 eight CHECK-HEX: {{^}} 28 nine + +# Show that an invalid value is rejected. +RUN: not llvm-strings --radix z %t 2>&1 | FileCheck %s --check-prefix=INVALID +INVALID: llvm-strings{{.*}}: for the --radix option: Cannot find option named 'z'! Index: test/tools/llvm-strings/response-file.test =================================================================== --- test/tools/llvm-strings/response-file.test +++ test/tools/llvm-strings/response-file.test @@ -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 Index: test/tools/llvm-strings/stdin-filename.test =================================================================== --- test/tools/llvm-strings/stdin-filename.test +++ test/tools/llvm-strings/stdin-filename.test @@ -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 Index: test/tools/llvm-strings/stdin.test =================================================================== --- test/tools/llvm-strings/stdin.test +++ test/tools/llvm-strings/stdin.test @@ -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={{.}} Index: test/tools/llvm-strings/terminator-neg.test =================================================================== --- test/tools/llvm-strings/terminator-neg.test +++ test/tools/llvm-strings/terminator-neg.test @@ -1,2 +0,0 @@ -RUN: echo -n abc | llvm-strings - | FileCheck -allow-empty %s -CHECK-NOT: abc Index: test/tools/llvm-strings/terminator.test =================================================================== --- test/tools/llvm-strings/terminator.test +++ test/tools/llvm-strings/terminator.test @@ -1,2 +0,0 @@ -RUN: echo -n abcdefg | llvm-strings - | FileCheck %s -CHECK: abcdefg Index: test/tools/llvm-strings/version.test =================================================================== --- test/tools/llvm-strings/version.test +++ test/tools/llvm-strings/version.test @@ -0,0 +1,4 @@ +# Show that --version works for llvm-strings. + +RUN: llvm-strings --version | FileCheck %s +CHECK: LLVM version Index: test/tools/llvm-strings/whitespace.test =================================================================== --- test/tools/llvm-strings/whitespace.test +++ test/tools/llvm-strings/whitespace.test @@ -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{{$}}