consmirror.c: the BSD notice is replaced (Makronix's own file). Files with changes of other sessions pending are left for their commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
70 lines
2.5 KiB
Bash
70 lines
2.5 KiB
Bash
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# Test of the comm port. src/tests/usr.bin/comm does not exist, so there is
|
|
# no NetBSD test to translate; the cases are the ones comm(1) documents: the
|
|
# three columns, the number of tabs that "equal to the number of lower
|
|
# numbered columns that are being printed", the suppression options -1, -2,
|
|
# -3, and -f ("Fold case in line comparisons").
|
|
#
|
|
# The two input files are made here, since the port has no test data in src/.
|
|
#
|
|
# Usage: test.sh COMM DATADIR
|
|
# COMM the command that runs the port (a path, or "qemu-aarch64 -L
|
|
# <sysroot> <path>"; tools/userland-test.sh passes it)
|
|
# DATADIR unused (src/tests/usr.bin/comm does not exist)
|
|
# Prints one line per case and exits non-zero if one failed.
|
|
|
|
[ $# -eq 2 ] || { echo "usage: $0 COMM DATADIR" >&2; exit 2; }
|
|
comm=$1 d=$2
|
|
fails=0
|
|
t=${TMPDIR:-/tmp}/comm-test.$$
|
|
mkdir -p "$t" || exit 1
|
|
trap 'rm -rf "$t"' EXIT
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
ok() { echo "PASS $1"; }
|
|
no() { echo "FAIL $1"; fails=$((fails + 1)); }
|
|
same() { # NAME EXPECTED-FILE: compare $t/out with it
|
|
if cmp -s "$2" "$t/out"; then ok "$1"; else no "$1"; fi
|
|
}
|
|
|
|
printf 'apple\nbanana\ncherry\n' > "$t/f1"
|
|
printf 'banana\ncherry\ndate\n' > "$t/f2"
|
|
|
|
# comm(1): "three text columns as output: lines only in file1; lines only in
|
|
# file2; and lines in both files", each column preceded by one tab per
|
|
# printed lower-numbered column: none for column 1, two for column 3.
|
|
$comm "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'apple\n\t\tbanana\n\t\tcherry\n\tdate\n' > "$t/exp"
|
|
same three-columns "$t/exp"
|
|
|
|
# comm(1) -1: column 1 is not printed, so column 2 loses its tab and column 3
|
|
# keeps one.
|
|
$comm -1 "$t/f1" "$t/f2" > "$t/out"
|
|
printf '\tbanana\n\tcherry\ndate\n' > "$t/exp"
|
|
same suppress-column-1 "$t/exp"
|
|
|
|
# comm(1) -3: only the two "only in one file" columns remain.
|
|
$comm -3 "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'apple\n\tdate\n' > "$t/exp"
|
|
same suppress-column-3 "$t/exp"
|
|
|
|
# comm(1) -1 -2: only the common lines, and as the first printed column they
|
|
# carry no tab at all.
|
|
$comm -12 "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'banana\ncherry\n' > "$t/exp"
|
|
same common-only "$t/exp"
|
|
|
|
# comm(1) -f: "Fold case in line comparisons" -- Apple and apple are the same
|
|
# line; the text printed is the one of file1.
|
|
printf 'Apple\nbanana\n' > "$t/f3"
|
|
printf 'apple\nBanana\n' > "$t/f4"
|
|
$comm -12 -f "$t/f3" "$t/f4" > "$t/out"
|
|
printf 'Apple\nbanana\n' > "$t/exp"
|
|
same fold-case "$t/exp"
|
|
|
|
echo "comm: $fails failed"
|
|
[ "$fails" -eq 0 ]
|