xref: /freebsd/usr.bin/lastcomm/tests/legacy_test.sh (revision d37eb51047221dc3322b34db1038ff3aa533883f)
1#!/bin/sh
2#
3#
4
5DIR=`dirname $0`
6ARCH=`uname -m`
7
8TZ=UTC; export TZ
9
10check()
11{
12	NUM=$1
13	shift
14	# Remove tty field, which varies between systems.
15	awk '{$4 = ""; print}' |
16	if diff -a - $1 >&2
17	then
18		echo "ok $NUM"
19	else
20		echo "not ok $NUM"
21	fi
22}
23
24
25cat $DIR/v1-$ARCH-acct.in $DIR/v2-$ARCH-acct.in >v1v2-$ARCH-acct.in
26cat $DIR/v2-$ARCH.out $DIR/v1-$ARCH.out >v1v2-$ARCH.out
27
28echo 1..6
29
30lastcomm -cesuS -f $DIR/v1-$ARCH-acct.in | check 1 $DIR/v1-$ARCH.out
31lastcomm -cesuS -f - <$DIR/v1-$ARCH-acct.in | tail -r | check 2 $DIR/v1-$ARCH.out
32lastcomm -cesuS -f $DIR/v2-$ARCH-acct.in | check 3 $DIR/v2-$ARCH.out
33lastcomm -cesuS -f - <$DIR/v2-$ARCH-acct.in | tail -r | check 4 $DIR/v2-$ARCH.out
34lastcomm -cesuS -f v1v2-$ARCH-acct.in | check 5 v1v2-$ARCH.out
35lastcomm -cesuS -f - <v1v2-$ARCH-acct.in | tail -r | check 6 v1v2-$ARCH.out
36
37exit 0
38