freebsd-nq/usr.bin/lastcomm/tests/values.sh
Julio Merino d14afb2adc Migrate tools/regression/{usr.bin/lastcomm,usr.sbin}/ to the new tests layout.
This change was originally going to only migrate the usr.sbin tests but, as
it turns out, the usr.sbin/sa/ tests require files from usr.bin/lastcomm/
so it's better to just also migrate the latter at the same time.  The other
usr.bin tests will be moved separately.

To make these tests work within the test suite, some of them have required
changes to prevent modifying the source directory and instead just rely on
the current directory for file manipulation.
2014-03-16 04:09:22 +00:00

84 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
ACCT=acct
RESULTS=acct.`uname -m`.tar.gz
TMPDIR=$$.tmp
TZ=UTC; export TZ
run()
{
/usr/bin/time -l -o $1.time "$@"
}
if [ `whoami` != "root" ]; then
echo "You need to be root to run this test."
exit 1
fi
echo Redirecting accounting.
mkdir $TMPDIR
cd $TMPDIR
:>$ACCT
accton $ACCT
echo Running commands. This should not take more than 30s.
# User time
run awk 'BEGIN {for (i = 0; i < 1000000; i++) cos(.3)}' /dev/null
run egrep '(.)(.)(.)(.)(.)(.)(.)(.)(.)\9\8\7\6\5\4\3\2\1' /usr/share/dict/words
# System time
run find /usr/src -name xyzzy
# Elapsed time
run sleep 3
# IO
run dd if=/dev/zero bs=512 count=4096 of=zero 2>/dev/null
# Memory
run diff /usr/share/dict/words /dev/null >/dev/null
# AC_COMM_LEN - 1
ln /usr/bin/true 123456789012345
run ./123456789012345
# AC_COMM_LEN
ln /usr/bin/true 1234567890123456
run ./1234567890123456
# AC_COMM_LEN + 1
ln /usr/bin/true 12345678901234567
run ./12345678901234567
# Flags: core, fork, signal
echo 'main(){volatile int s; fork(); s = *(int *)0;}' >core.c
cc -o core core.c
echo Generating segmentation fault.
./core
echo Turning off redirected accounting.
accton
echo Packing the results.
sa -u $ACCT >sa.u
lastcomm -cesuS -f $ACCT >lastcomm.cesuS
tar -cf - acct sa.u lastcomm.cesuS *.time |
gzip -c |
uuencode $RESULTS >../$RESULTS.uue
echo Cleaning up.
cd ..
rm -rf $TMPDIR
echo "Done! Please send your reply, enclosing the file $RESULTS.uue"
echo If your system runs with accounting enabled you probably need to run:
echo accton /var/account/acct