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>
69 lines
2.5 KiB
Bash
69 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 paste port. src/tests/usr.bin/paste does not exist, so there is
|
|
# no NetBSD test to translate; the cases are the ones paste(1) documents:
|
|
# parallel merging with the default tab, an input file shorter than the other
|
|
# ("treated as if it were an endless source of empty lines"), -d (including
|
|
# "\t" and "the characters in list are used circularly"), and -s.
|
|
#
|
|
# The input files are made here, since the port has no test data in src/.
|
|
#
|
|
# Usage: test.sh PASTE DATADIR
|
|
# PASTE 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/paste does not exist)
|
|
# Prints one line per case and exits non-zero if one failed.
|
|
|
|
[ $# -eq 2 ] || { echo "usage: $0 PASTE DATADIR" >&2; exit 2; }
|
|
paste=$1 d=$2
|
|
fails=0
|
|
t=${TMPDIR:-/tmp}/paste-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 'a\nb\nc\n' > "$t/f1"
|
|
printf '1\n2\n' > "$t/f2"
|
|
|
|
# paste(1): corresponding lines, "replacing all but the last file's newline
|
|
# characters with a single tab"; the exhausted second file is "an endless
|
|
# source of empty lines", so the third line ends in the tab alone.
|
|
$paste "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'a\t1\nb\t2\nc\t\n' > "$t/exp"
|
|
same parallel-default "$t/exp"
|
|
|
|
# paste(1) -d list: the listed character replaces the tab.
|
|
$paste -d , "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'a,1\nb,2\nc,\n' > "$t/exp"
|
|
same delimiter "$t/exp"
|
|
|
|
# paste(1) -d '\t': the escape stands for the tab character, so this is the
|
|
# default output.
|
|
$paste -d '\t' "$t/f1" "$t/f2" > "$t/out"
|
|
printf 'a\t1\nb\t2\nc\t\n' > "$t/exp"
|
|
same delimiter-tab-escape "$t/exp"
|
|
|
|
# paste(1) -s: "Concatenate all of the lines of each separate input file in
|
|
# command line order", newlines replaced by the tab.
|
|
$paste -s "$t/f1" > "$t/out"
|
|
printf 'a\tb\tc\n' > "$t/exp"
|
|
same sequential "$t/exp"
|
|
|
|
# paste(1) -s -d: "The characters in list are used circularly, i.e., when
|
|
# list is exhausted the first character from list is reused" -- three lines
|
|
# need two separators, ':' then '@'.
|
|
$paste -s -d ':@' "$t/f1" > "$t/out"
|
|
printf 'a:b@c\n' > "$t/exp"
|
|
same sequential-circular-delimiters "$t/exp"
|
|
|
|
echo "paste: $fails failed"
|
|
[ "$fails" -eq 0 ]
|