73 lines
2.2 KiB
Makefile
Executable File
73 lines
2.2 KiB
Makefile
Executable File
#!/bin/sh
|
|
# Copyright (c) 2024 DTB <trinity@trinity.moe>
|
|
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
|
# 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: npc_tests
|
|
npc_tests: npc_help npc_args npc_ascii
|
|
|
|
.PHONY: npc_help
|
|
npc_help: $(BIN)/npc
|
|
! $(BIN)/npc -h
|
|
|
|
.PHONY: npc_args
|
|
# arg parsing
|
|
npc_args:
|
|
$(BIN)/npc -e </dev/null
|
|
$(BIN)/npc -t </dev/null
|
|
$(BIN)/npc -et </dev/null
|
|
! $(BIN)/npc -et 5 </dev/null
|
|
|
|
.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
|
|
|
|
.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
|