Compare commits
3 Commits
ee7b7e89b2
...
acdbecf178
Author | SHA1 | Date | |
---|---|---|---|
acdbecf178 | |||
0f2d357476 | |||
588680406a |
@ -20,7 +20,7 @@ dj_full: $(BIN)/dj /dev/full
|
||||
case "$$(uname)" in \
|
||||
Linux) \
|
||||
$(BIN)/dj -Hi /dev/zero -o /dev/full 2>&1 \
|
||||
| tee /dev/tty \
|
||||
| tee /dev/stderr \
|
||||
| xargs -I out test '1+0 > 0+0; 1024 > 0' = out \
|
||||
;; \
|
||||
esac
|
||||
@ -33,7 +33,7 @@ dj_help: $(BIN)/dj
|
||||
# Read nothing from /dev/null, write nothing to /dev/null.
|
||||
dj_null: $(BIN)/dj /dev/null
|
||||
$(BIN)/dj -Hi /dev/null -o /dev/null 2>&1 \
|
||||
| tee /dev/tty \
|
||||
| tee /dev/stderr \
|
||||
| xargs -I out test '0+0 > 0+0; 0 > 0' = out
|
||||
|
||||
# This test currently fails. This is probably due to dj(1) being stale relative
|
||||
@ -44,5 +44,5 @@ dj_null: $(BIN)/dj /dev/null
|
||||
# # Pipe 1024B of '\0' into dj(1); skip the first 24B; expect 1000B written.
|
||||
# dd count=1 bs=1024 </dev/zero 2>/dev/null \
|
||||
# | $(BIN)/dj -H -s 24 -o /dev/null 2>&1 \
|
||||
# | tee /dev/tty \
|
||||
# | tee /dev/stderr \
|
||||
# | xargs -I out test '1+0 > 1+0; 1024 > 1000' = out
|
||||
|
@ -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
|
||||
! $(BIN)/npc -et 5 </dev/null
|
||||
|
||||
.PHONY: npc_help
|
||||
npc_help: $(BIN)/npc
|
||||
! $(BIN)/npc -h
|
||||
.PHONY: npc_ascii
|
||||
# Test 0x00 to 0x7f in input; in other words, the full 7b ASCII range.
|
||||
npc_ascii: npc_ascii_controls npc_ascii_symbols npc_ascii_uppers # \
|
||||
# npc_ascii_lowers
|
||||
|
||||
#i=0; while "$BIN"/intcmp -l $i 178; do
|
||||
# printf '\\%s\\n' "$i" \
|
||||
# | xargs -I fmt printf fmt
|
||||
#
|
||||
# # simulate octal
|
||||
# i="$(printf '1 + %s\n' "$i" | bc)"
|
||||
# printf '%s\n' "$i" \
|
||||
# | tail -c 1 \
|
||||
# | xargs "$BIN"/intcmp -e 8 \
|
||||
# && i="$(printf '2 + %s\n' "$i" | bc)"
|
||||
# printf '%s\n' "$i" \
|
||||
# | tail -c 2 \
|
||||
# | dd count=1 bs=1 2>/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
|
||||
|
46
tests/bonsai/scrut.mk
Executable file
46
tests/bonsai/scrut.mk
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
||||
# SPDX-License-Identifier: FSFAP
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice and this
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
.PRAGMA: command_comment
|
||||
|
||||
.PHONY: scrut_tests
|
||||
scrut_tests: scrut_help scrut_options
|
||||
|
||||
.PHONY: scrut_help
|
||||
scrut_help: $(BIN)/scrut
|
||||
! $(BIN)/scrut -h
|
||||
|
||||
.PHONY: scrut_options
|
||||
# scrut tests file attributes, but files of a certain attribute aren't
|
||||
# guaranteed to be present on a system. This test checks all of the files in
|
||||
# harakit and, if test(1p) says a file matches a certain attribute, then checks
|
||||
# scrut.
|
||||
# opts are space-delimited (for command splitting), sel is not
|
||||
scrut_options: $(BIN)/scrut
|
||||
set -e; \
|
||||
opts="b c d e f g k p r s u w x L S"; \
|
||||
sel=; \
|
||||
find . -name .git -prune -o -print \
|
||||
| while read -r f; do \
|
||||
for opt in $$opts; \
|
||||
do if ! printf "%s\n" $$sel | grep $$opt >/dev/null; then \
|
||||
if test -$$opt "$$f"; then \
|
||||
if ! $(BIN)/scrut -$$opt "$$f"; \
|
||||
then printf "[!!] scrut -%s failed on %s.\n" \
|
||||
$$opt "$$f"; \
|
||||
fi; \
|
||||
sel="$$sel$$opt"; \
|
||||
printf "[OK] Tested scrut -%s using %s\n" \
|
||||
$$opt "$$f"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
if printf "%s\n" "$$opts" | sed 's/ //g' | xargs test "$$sel" =; \
|
||||
then break; \
|
||||
fi; \
|
||||
done
|
Loading…
Reference in New Issue
Block a user