xref: /freebsd/usr.bin/lastcomm/tests/values.sh (revision e1c4c8dd8d2d10b6104f06856a77bd5b4813a801)
1#!/bin/sh
2#
3#
4
5ACCT=acct
6RESULTS=acct.`uname -m`.tar.gz
7TMPDIR=$$.tmp
8TZ=UTC; export TZ
9
10run()
11{
12	/usr/bin/time -l -o $1.time "$@"
13}
14
15if [ `whoami` != "root" ]; then
16	echo "You need to be root to run this test."
17	exit 1
18fi
19
20echo Redirecting accounting.
21
22mkdir $TMPDIR
23cd $TMPDIR
24
25:>$ACCT
26accton $ACCT
27
28echo Running commands. This should not take more than 30s.
29
30# User time
31run awk 'BEGIN {for (i = 0; i < 1000000; i++) cos(.3)}' /dev/null
32run egrep '(.)(.)(.)(.)(.)(.)(.)(.)(.)\9\8\7\6\5\4\3\2\1' /usr/share/dict/words
33
34# System time
35run find /usr/src -name xyzzy
36
37# Elapsed time
38run sleep 3
39
40# IO
41run dd if=/dev/zero bs=512 count=4096 of=zero 2>/dev/null
42
43# Memory
44run diff /usr/share/dict/words /dev/null >/dev/null
45
46# AC_COMM_LEN - 1
47ln /usr/bin/true 123456789012345
48run ./123456789012345
49
50# AC_COMM_LEN
51ln /usr/bin/true 1234567890123456
52run ./1234567890123456
53
54# AC_COMM_LEN + 1
55ln /usr/bin/true 12345678901234567
56run ./12345678901234567
57
58# Flags: core, fork, signal
59echo 'main(){volatile int s; fork(); s = *(int *)0;}' >core.c
60cc -o core core.c
61echo Generating segmentation fault.
62./core
63
64echo Turning off redirected accounting.
65
66accton
67
68echo Packing the results.
69
70sa -u $ACCT >sa.u
71lastcomm -cesuS -f $ACCT >lastcomm.cesuS
72tar -cf - acct sa.u lastcomm.cesuS *.time |
73gzip -c |
74uuencode $RESULTS >../$RESULTS.uue
75
76echo Cleaning up.
77cd ..
78rm -rf $TMPDIR
79
80echo "Done!  Please send your reply, enclosing the file $RESULTS.uue"
81echo If your system runs with accounting enabled you probably need to run:
82echo accton /var/account/acct
83