]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/sa/tests/legacy_test.sh
sqlite3: Vendor import of sqlite3 3.43.1
[FreeBSD/FreeBSD.git] / usr.sbin / sa / tests / legacy_test.sh
1 #!/bin/sh
2 #
3 #
4
5 DIR=`dirname $0`
6 LCDIR=`dirname $0`/../../usr.bin/lastcomm
7 ARCH=`uname -m`
8
9 collapse_whitespace()
10 {
11         sed -E 's,[     ]+, ,g'
12 }
13
14 check()
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
27 install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
28 install -c -m 644 $LCDIR/v2-$ARCH-acct.in v2-$ARCH-acct.in
29
30 echo 1..13
31
32 # Command listings of the two acct versions
33 sa -u v1-$ARCH-acct.in | check 1 $DIR/v1-$ARCH-u.out
34 sa -u v2-$ARCH-acct.in | check 2 $DIR/v2-$ARCH-u.out
35
36 # Plain summaries of user/process
37 sa -i v1-$ARCH-acct.in | check 3 $DIR/v1-$ARCH-sav.out
38 sa -im v1-$ARCH-acct.in | check 4 $DIR/v1-$ARCH-usr.out
39
40 # Backward compatibility of v1 summary files
41 sa -P $DIR/v1-$ARCH-sav.in -U $DIR/v1-$ARCH-usr.in /dev/null |
42         check 5 $DIR/v1-$ARCH-sav.out
43 sa -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 
47 install -c -m 644 $DIR/v1-$ARCH-sav.in v2c-$ARCH-sav.in
48 install -c -m 644 $DIR/v1-$ARCH-usr.in v2c-$ARCH-usr.in
49 sa -s -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null >/dev/null
50 sa -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
51         check 7 $DIR/v1-$ARCH-sav.out
52 sa -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
56 sa -P $DIR/v2-$ARCH-sav.in -U $DIR/v2-$ARCH-usr.in /dev/null |
57         check 9 $DIR/v1-$ARCH-sav.out
58 sa -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
62 sa -is -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in >/dev/null
63 sa -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
64         check 11 $DIR/v1-$ARCH-sav.out
65 sa -m -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in /dev/null |
66         check 12 $DIR/v1-$ARCH-usr.out
67
68 # Accumulate
69 install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
70 sa -is -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in >/dev/null
71 install -c -m 644 $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
72 sa -s -P v2c-$ARCH-sav.in -U v2c-$ARCH-usr.in v1-$ARCH-acct.in \
73     | collapse_whitespace >double
74 cp $LCDIR/v1-$ARCH-acct.in v1-$ARCH-acct.in
75 sa -i v1-$ARCH-acct.in v1-$ARCH-acct.in | check 13 double
76
77 exit 0