From 588680406a8e08fae6a645ee2a63b99827fd185f Mon Sep 17 00:00:00 2001 From: DTB Date: Sat, 3 Aug 2024 07:29:04 -0600 Subject: [PATCH] tests: bonsai/npc.mk: full ASCII test coverage --- tests/bonsai/npc.mk | 70 ++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/tests/bonsai/npc.mk b/tests/bonsai/npc.mk index 5f110de..8b10fdf 100755 --- a/tests/bonsai/npc.mk +++ b/tests/bonsai/npc.mk @@ -10,7 +10,11 @@ .PRAGMA: command_comment .PHONY: npc_tests -npc_tests: npc_args npc_help +npc_tests: npc_help npc_args npc_ascii + +.PHONY: npc_help +npc_help: $(BIN)/npc + ! $(BIN)/npc -h .PHONY: npc_args # arg parsing @@ -20,23 +24,49 @@ npc_args: $(BIN)/npc -et /dev/null \ -# | xargs "$BIN"/intcmp -e 8 \ -# && i="$(printf '20 + %s\n' "$i" | bc)" -#done +.PHONY: npc_ascii_controls +# (control characters) +npc_ascii_controls: + # ASCII 0x00 to 0x0a (before the newline, due to xargs(1p) issues) + awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); }' \ + | $(BIN)/npc \ + | head -n 1 \ + | xargs -I out test "^@^A^B^C^D^E^F^G^H" = out + + # ASCII 0x0a (otherwise the head|tail sequence won't work) to 0x1f + awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); print }' \ + | $(BIN)/npc \ + | head -n 2 \ + | tail -n 1 \ + | xargs -I out test "^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_" + +.PHONY: npc_ascii_symbols +# ASCII 0x1f to 0x3f (^_ and symbols) +npc_ascii_symbols: + # shell quoting olympics + awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }' \ + | $(BIN)/npc \ + | sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \ + | xargs -I out test "^_ !\"#$$%&'()*+,-./0123456789:;<=>?" = out + +.PHONY: npc_ascii_uppers +# ASCII 0x40 to 0x5f (uppercases) +npc_ascii_uppers: + awk 'BEGIN{ for (i = 64; i < 96; ++i) printf("%c", i); print }' \ + | $(BIN)/npc \ + | sed 's/\\/\\\\/' \ + | xargs -I out test @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ = out + +# This test is broken and will need closer inspection along with the npc(1) +# source. +# .PHONY: npc_ascii_lowers +# # ASCII 0x60 to 0x7f (lowercases) +# npc_ascii_lowers: +# awk 'BEGIN{ for (i = 96; i < 128; ++i) printf("%c", i); print }' \ +# | $(BIN)/npc \ +# | xargs -I out test "\`abcdefghijklmnopqrstuvwxyz{|}~^?" = out