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>
52 lines
1.7 KiB
Bash
52 lines
1.7 KiB
Bash
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# Test of the sync port. src/tests/bin/sync does not exist and sync(8) has
|
|
# no options: it invokes sync(2), "force completion of pending disk writes",
|
|
# writes nothing and exits 0. The cases prove that, that a write made before
|
|
# it is still readable after it, and that it can be called again.
|
|
#
|
|
# Usage: test.sh SYNC DATADIR
|
|
# SYNC the command that runs the port (a path, or "qemu-aarch64 -L
|
|
# <sysroot> <path>"; tools/userland-test.sh passes it)
|
|
# DATADIR unused: there is no NetBSD test data for sync ("/nonexistent")
|
|
# Prints one line per case and exits non-zero if one failed.
|
|
|
|
[ $# -eq 2 ] || { echo "usage: $0 SYNC DATADIR" >&2; exit 2; }
|
|
s=$1 d=$2
|
|
fails=0
|
|
t=${TMPDIR:-/tmp}/sync-test.$$
|
|
mkdir -p "$t" || exit 1
|
|
trap 'rm -rf "$t"' EXIT
|
|
|
|
ok() { echo "PASS $1"; }
|
|
no() { echo "FAIL $1"; fails=$((fails + 1)); }
|
|
|
|
# quiet NAME: the run that just happened exited 0 and wrote nothing
|
|
quiet() {
|
|
if [ $? -eq 0 ] && [ ! -s "$t/out" ] && [ ! -s "$t/err" ]; then
|
|
ok "$1"
|
|
else
|
|
no "$1"
|
|
fi
|
|
}
|
|
|
|
# sync(8): "The sync program simply invokes the sync(2) system call"
|
|
$s > "$t/out" 2> "$t/err"
|
|
quiet no-arguments
|
|
|
|
# sync(8): "ensure that all disk writes have been completed" -- the write
|
|
# made before it is still there, unchanged, after it
|
|
printf 'written before sync\n' > "$t/file"
|
|
$s > "$t/out" 2> "$t/err"
|
|
quiet after-a-write
|
|
printf 'written before sync\n' > "$t/exp"
|
|
if cmp -s "$t/exp" "$t/file"; then ok write-survives; else no write-survives; fi
|
|
|
|
# ... and nothing prevents calling it a second time
|
|
$s > "$t/out" 2> "$t/err"
|
|
quiet called-twice
|
|
|
|
echo "sync: $fails failed"
|
|
[ "$fails" -eq 0 ]
|