Skip to content

Commit 86a88ea

Browse files
committed
rq_cxl_tests.sh: stop losing lines longer than 1024 bytes
Fix dumpfile() to split lines longer than 1024 lines. They were silently dropped; the "invalid write" message was generally lost in the various redirections. Also define IFS= to stop trimming whitespace and use the filename as a message prefix. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 6c2a047 commit 86a88ea

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/rq_cxl_tests.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,23 @@ set +e
3333
# disable make check here until ndctl re-enables it for libcxl
3434
meson test -C build --suite cxl > "$logfile" 2>&1
3535

36-
# cat logfile > /dev/kmsg doesn't work (-EINVAL)
36+
# /dev/kmsg has a 1024 bytes limit ("invalid write")
37+
#
38+
# When testing this limit interactively, /bin/printf may hit it while
39+
# the shell's built-in printf command may not. That's because the shell
40+
# may read or write less than 1024 bytes at a time. It's unpredictable
41+
# which is why we need "-n $maxlen"
3742
dumpfile()
3843
{
39-
set +x
40-
while read -r line; do
41-
echo "$line" > /dev/kmsg
44+
( set +x
45+
local filename; filename=$(basename "$1")
46+
local filenamelen
47+
filenamelen=$(printf '%s' "$filename" | wc -c)
48+
local maxlen; maxlen=$((1024-filenamelen-6))
49+
while IFS= read -t 60 -n "$maxlen" -r line; do
50+
printf '<5>%s: %s\n' "$filename" "$line" > /dev/kmsg
4251
done < "$1"
43-
set -x
52+
)
4453
}
4554

4655
dumpfile "$NDCTL"/build/meson-logs/testlog.txt

0 commit comments

Comments
 (0)