[llvm-branch-commits] [llvm] release/22.x: [LIT][LLVM-STRINGS]Make stdin tests shell-consistent (#176139) (PR #182756)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Feb 22 09:01:21 PST 2026


https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/182756

Backport 8779cff5e979dee6830268cf49a4736b11308e32

Requested by: @amy-kwan

>From 0e1d9183e444642b28b383e8089bce2e745c1550 Mon Sep 17 00:00:00 2001
From: Midhunesh <midhunesh.p at ibm.com>
Date: Fri, 16 Jan 2026 15:51:29 +0530
Subject: [PATCH] [LIT][LLVM-STRINGS]Make stdin tests shell-consistent
 (#176139)

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.

(cherry picked from commit 8779cff5e979dee6830268cf49a4736b11308e32)
---
 llvm/test/tools/llvm-strings/stdin.test | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/llvm/test/tools/llvm-strings/stdin.test b/llvm/test/tools/llvm-strings/stdin.test
index 63f7194ab973d..d0b6e44aabbea 100644
--- a/llvm/test/tools/llvm-strings/stdin.test
+++ b/llvm/test/tools/llvm-strings/stdin.test
@@ -1,13 +1,11 @@
-# XFAIL: system-aix
-
 ## 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={{.}}
+RUN: printf "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
+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={{.}}
@@ -21,4 +19,4 @@ 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={{.}}
+RUN: printf "abcdefg" | llvm-strings | FileCheck %s --check-prefix=CASE1 --implicit-check-not={{.}}



More information about the llvm-branch-commits mailing list