xref: /freebsd/usr.sbin/sa/tests/legacy_test.sh (revision 51e235148a4becba94e824a44bd69687644a7f56)
1#!/bin/sh
2#
3#
4
5DIR=`dirname $0`
6LCDIR=`dirname $0`/../../usr.bin/lastcomm
7ARCH=`uname -m`
8
9collapse_whitespace()
10{
11	sed -E 's,[ 	]+, ,g'
12}
13
14check()
15{
16	NUM=$1
17	shift
18	collapse_whitespace | \
19	if diff -q - $1
20	then
21		echo "ok $NUM"
22	else
23		echo "not ok $NUM"
24	fi
25}
26
27install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
28install -c -m 644 $LCDIR/v2-$ARCH-acct.in v2-$ARCH-acct.in
29
30echo 1..13
31
32# Command listings of the two acct versions
33sa -u v1-$ARCH-acct.in | check 1 $DIR/v1-$ARCH-u.out
34sa -u v2-$ARCH-acct.in | check 2 $DIR/v2-$ARCH-u.out
35
36# Plain summaries of user/process
37sa -i v1-$ARCH-acct.in | check 3 $DIR/v1-$ARCH-sav.out
38sa -im v1-$ARCH-acct.in | check 4 $DIR/v1-$ARCH-usr.out
39
40# Backward compatibility of v1 summary files
41sa -P $DIR/v1-$ARCH-sav.in -U $DIR/v1-$ARCH-usr.in /dev/null |
42	check 5 $DIR/v1-$ARCH-sav.out
43sa -m -P $DIR/v1-$ARCH-sav.in -U $DIR/v1-$ARCH-usr.in /dev/null |
44	check 6 $DIR/v1-$ARCH-usr.out
45
46# Convert old summary format to new
47install -c -m 644 $DIR/v1-$ARCH-sav.in v2c-$ARCH-sav.in
48install -c -m 644 $DIR/v1-$ARCH-usr.in v2c-$ARCH-usr.in
49sa -s -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null >/dev/null
50sa -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
51	check 7 $DIR/v1-$ARCH-sav.out
52sa -m -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
53	check 8 $DIR/v1-$ARCH-usr.out
54
55# Reading v2 summary files
56sa -P $DIR/v2-$ARCH-sav.in -U $DIR/v2-$ARCH-usr.in /dev/null |
57	check 9 $DIR/v1-$ARCH-sav.out
58sa -m -P $DIR/v2-$ARCH-sav.in -U $DIR/v2-$ARCH-usr.in /dev/null |
59	check 10 $DIR/v1-$ARCH-usr.out
60
61# Summarize
62sa -is -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in >/dev/null
63sa -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
64	check 11 $DIR/v1-$ARCH-sav.out
65sa -m -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
66	check 12 $DIR/v1-$ARCH-usr.out
67
68# Accumulate
69install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
70sa -is -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in >/dev/null
71install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
72sa -s -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in \
73    | collapse_whitespace >double
74cp $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
75sa -i v1-$ARCH-acct.in v1-$ARCH-acct.in | check 13 double
76
77exit 0
78