The fix updates the llvm-strings stdin lit tests to use `printf` instead of `echo -n` when generating input via stdin. The behavior of `echo -n` is not portable and varies across shells and platforms, particularly on AIX where `/bin/sh` handles `-n` and escape processing differently from GNU-compatible shells. This causes the tests to fail despite correct llvm-strings functionality. In contrast, `printf` has well-defined, POSIX-specified semantics and provides consistent handling of newlines, escape sequences, and non-printable characters. Using `printf` eliminates the dependency on shell-specific `echo` behavior and makes the tests deterministic.
23 lines
927 B
Plaintext
23 lines
927 B
Plaintext
## Show that llvm-strings can handle stdin input properly.
|
|
|
|
## Case 1: output with single string.
|
|
RUN: printf "abcdefg" | llvm-strings - | FileCheck %s --check-prefix=CASE1 --implicit-check-not={{.}}
|
|
CASE1: abcdefg
|
|
|
|
## Case 2: output too short for string.
|
|
RUN: printf "abc" | llvm-strings - | FileCheck %s --implicit-check-not={{.}} --allow-empty
|
|
|
|
## Case 3: output with new line.
|
|
RUN: printf "abcd\nefgh" | llvm-strings - | FileCheck %s --check-prefix=CASE3 --implicit-check-not={{.}}
|
|
CASE3: abcd
|
|
CASE3-NEXT: efgh
|
|
|
|
## Case 4: output containing unprintable characters.
|
|
RUN: printf "abcd\000ef\037ghij\177klmn" | 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: printf "abcdefg" | llvm-strings | FileCheck %s --check-prefix=CASE1 --implicit-check-not={{.}}
|