summaryrefslogtreecommitdiff
path: root/keyutils-1.5.6/tests/keyctl/show/noargs/runtest.sh
blob: 1cde112c2b418c2a91e0f397a98f0a38845b27ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh

. ../../../prepare.inc.sh
. ../../../toolbox.inc.sh


# ---- do the actual testing ----

result=PASS
echo "++++ BEGINNING TEST" >$OUTPUTFILE

# check that show shows us our session keyring
marker "SHOW SESSION KEYRING"
keyctl show >>$OUTPUTFILE 2>&1
if [ $? != 0 ]
then
    failed
fi

# must be at least two lines in the output (plus the test banner lines)
nlines=`wc -l $OUTPUTFILE | cut -d\  -f1`
if [ "$nlines" -lt 4 ]
then
    failed
fi

# there must be a session keyring section on the third line
if [ "`sed -n -e 3p $OUTPUTFILE`" != "Session Keyring" ]
then
    failed
fi

# the first key listed (line 2) should be a keying (the session keyring) ...
keyring1="`grep -n keyring $OUTPUTFILE | cut -d: -f1 | head -1`"
if [ "$keyring1" != "4" ]
then
    failed
fi

# ... and it should be the session keyring
keyring1name="`sed -n -e 4p $OUTPUTFILE | awk '{print $6}'`"
if ! expr "$keyring1name" : "^RHTS/keyctl" >&/dev/null
then
    failed
fi


echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE

# --- then report the results in the database ---
toolbox_report_result $TEST $result