From 94873a2ddca6fab4cf2a89f553f39cecc427f141 Mon Sep 17 00:00:00 2001 From: DTB Date: Mon, 8 Jul 2024 22:25:18 -0600 Subject: [PATCH] tests: bonsai/dj.sh: iron out some existing tests --- tests/bonsai/dj.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/bonsai/dj.sh b/tests/bonsai/dj.sh index 8016ec3..9919d60 100755 --- a/tests/bonsai/dj.sh +++ b/tests/bonsai/dj.sh @@ -11,17 +11,19 @@ ! dj -h -# This test is theoretically Linux-dependent; write(2) should return -1 on -# error. -# Right now dj(1) interprets the return value of write(2) as the amount of -# bytes written. This can decrement the stored quantity of bytes written, -# which is an int, so doesn't underflow but goes negative. dj(1) tries to -# again to write(2) if an error occurs in which no bytes are written, so in -# total two write(2)s are attempted and so the written byte quantity is -2. -# This is a bug and will change, but for now is at least documented. -dj -Hi /dev/zero -o /dev/full \ - | xargs -I out "$BIN/strcmp" '1+0 > 0+0; 1024 > -2' out +# Linux has a /dev/full pseudodevice useful for testing errors. +case "$(uname)" in +Linux) + dj -Hi /dev/zero -o /dev/full 2>&1 \ + | xargs -I out "$BIN"/strcmp '1+0 > 0+0; 1024 > 0' out + ;; +esac # Read nothing from /dev/null, write nothing to /dev/null. -dj -Hi /dev/null -o /dev/null \ - | xargs -I out "$BIN/strcmp" '0+0 > 0+0; 0 > 0' out +dj -Hi /dev/null -o /dev/null 2>&1 \ + | xargs -I out "$BIN"/strcmp '0+0 > 0+0; 0 > 0' out + +# Test skipping stdin. +#dd count=1 bs=1024 /dev/null \ +# | dj -H -s 24 -o /dev/null 2>&1 \ +# | xargs -I out "$BIN"/strcmp '1+0 > 1+0; 1024 > 1000' out