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