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>
76 lines
2.4 KiB
Bash
76 lines
2.4 KiB
Bash
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# Test of the nice port. src/tests/usr.bin/nice does not exist, so there is
|
|
# no NetBSD test to translate; the cases are the ones nice(1) documents: the
|
|
# usage error when no utility is given, -n with a value the page does not
|
|
# allow, the exit status 127 for a utility that "could not be found", the
|
|
# deprecated -increment form, and that "the exit status of nice will be that
|
|
# of utility".
|
|
#
|
|
# Usage: test.sh NICE DATADIR
|
|
# NICE 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/nice does not exist)
|
|
# Prints one line per case and exits non-zero if one failed.
|
|
|
|
[ $# -eq 2 ] || { echo "usage: $0 NICE DATADIR" >&2; exit 2; }
|
|
nice=$1 d=$2
|
|
fails=0
|
|
t=${TMPDIR:-/tmp}/nice-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)); }
|
|
|
|
# nice(1) SYNOPSIS: a utility is required; without one the usage goes to
|
|
# standard error and the status is 1 (EXIT STATUS "1-125: an error occurred").
|
|
$nice > "$t/out" 2> "$t/err"
|
|
st=$?
|
|
if [ "$st" -eq 1 ] && [ -s "$t/err" ] && [ ! -s "$t/out" ]; then
|
|
ok usage-no-utility
|
|
else
|
|
no usage-no-utility
|
|
fi
|
|
|
|
# nice(1) -n: "A positive or negative decimal integer" -- "abc" is not one,
|
|
# so this is an error (1) and the utility is not run.
|
|
$nice -n abc /nonexistent/program > "$t/out" 2> "$t/err"
|
|
st=$?
|
|
if [ "$st" -eq 1 ] && [ -s "$t/err" ]; then
|
|
ok invalid-increment
|
|
else
|
|
no invalid-increment
|
|
fi
|
|
|
|
# nice(1) EXIT STATUS: "127: the utility could not be found".
|
|
$nice -n 5 /nonexistent/program > "$t/out" 2> "$t/err"
|
|
st=$?
|
|
if [ "$st" -eq 127 ] && [ -s "$t/err" ]; then
|
|
ok utility-not-found
|
|
else
|
|
no utility-not-found
|
|
fi
|
|
|
|
# nice(1) COMPATIBILITY: "The historic -increment option has been deprecated
|
|
# but is still supported" -- so -10 is a niceness of 10, not a bad option,
|
|
# and the missing utility still ends in 127.
|
|
$nice -10 /nonexistent/program > "$t/out" 2> "$t/err"
|
|
st=$?
|
|
if [ "$st" -eq 127 ] && [ -s "$t/err" ]; then
|
|
ok obsolete-increment
|
|
else
|
|
no obsolete-increment
|
|
fi
|
|
|
|
# nice(1) EXIT STATUS: "Otherwise, the exit status of nice will be that of
|
|
# utility".
|
|
$nice -n 0 /bin/sh -c 'exit 3' > "$t/out" 2> "$t/err"
|
|
if [ $? -eq 3 ]; then ok utility-exit-status; else no utility-exit-status; fi
|
|
|
|
echo "nice: $fails failed"
|
|
[ "$fails" -eq 0 ]
|