summaryrefslogtreecommitdiff
path: root/p11-kit/test-server.sh
blob: e9455dc4db82af5f4976f0c0d46b3c34a8a4035b (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
52
53
54
55
#!/bin/sh

testdir=$PWD/test-server-$$
test -d "$testdir" || mkdir "$testdir"

cleanup () {
	rm -rf "$testdir"
}
trap cleanup 0

cd "$testdir"

unset P11_KIT_SERVER_ADDRESS
unset P11_KIT_SERVER_PID

XDG_RUNTIME_DIR="$testdir"
export XDG_RUNTIME_DIR

echo 1..4

"$abs_top_builddir"/p11-kit-server -s --provider "$abs_top_builddir"/.libs/mock-one.so pkcs11: > start.env 2> start.err
if test $? -eq 0; then
	echo "ok 1 /server/start"
else
	echo "not ok 1 /server/start"
	sed 's/^/# /' start.err
	exit 1
fi

. ./start.env

if test "${P11_KIT_SERVER_ADDRESS+set}" = "set" -a "${P11_KIT_SERVER_PID+set}" = "set"; then
	echo "ok 2 /server/start-env"
else
	echo "not ok 2 /server/start-env"
	exit 1
fi

"$abs_top_builddir"/p11-kit-server -s -k > stop.env 2> stop.err
if test $? -eq 0; then
	echo "ok 3 /server/stop"
else
	echo "not ok 3 /server/stop"
	sed 's/^/# /' stop.err
	exit 1
fi

. ./stop.env

if test "${P11_KIT_SERVER_ADDRESS-unset}" = "unset" -a "${P11_KIT_SERVER_PID-unset}" = "unset"; then
	echo "ok 4 /server/stop-env"
else
	echo "not ok 4 /server/stop-env"
	exit 1
fi