summaryrefslogtreecommitdiff
path: root/tests/keyctl/newring/bad-args/runtest.sh
blob: 734b44e0f675adfd40966793732a8a71a735ff80 (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
#!/bin/bash

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


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

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

# check that an max length key description works correctly (4096 inc NUL)
if [ $PAGE_SIZE -lt $maxsquota ]
then
    marker "CHECK MAXLEN DESC"
    create_keyring --new=keyid $maxdesc @s
    clear_keyring @s
else
    marker "CHECK MAXLEN DESC FAILS WITH EDQUOT"
    create_keyring --fail $maxdesc @s
    expect_error EDQUOT
fi

# This doesn't work on MIPS earler than 3.19 because of a kernel bug
kver=`uname -r`
kmch=`uname -m`
if kernel_at_or_later_than 3.19 ||
	[ "$kmch" != "mips" -a "$kmch" != "mips64" ]
then
	# check that an overlong key description fails correctly (>4095 inc NUL)
	marker "CHECK OVERLONG DESC"
	create_keyring --fail a$maxdesc @s
	expect_error EINVAL
fi

# check that an empty keyring name fails
marker "CHECK EMPTY KEYRING NAME"
create_keyring --fail "" @s
expect_error EINVAL

# check that a bad key ID fails correctly
marker "CHECK BAD KEY ID"
create_keyring --fail wibble 0
expect_error EINVAL

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

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