]> git.proxmox.com Git - swtpm.git/blob - tests/test_swtpm_setup_misc
packaging: track dbgsym package for swtpm-libs and swtpm-tools
[swtpm.git] / tests / test_swtpm_setup_misc
1 #!/usr/bin/env bash
2
3 # For the license, see the LICENSE file in the root directory.
4
5 if [ "$(id -u)" -eq 0 ]; then
6 echo "Not running this test as root."
7 exit 77
8 fi
9
10 ROOT=${abs_top_builddir:-$(dirname "$0")/..}
11 TESTDIR=${abs_top_testdir:-$(dirname "$0")}
12 SRCDIR=${abs_top_srcdir:-$(dirname "$0")/..}
13
14 source ${TESTDIR}/common
15
16 trap "cleanup" SIGTERM EXIT
17
18 function cleanup()
19 {
20 rm -rf ${workdir}
21 }
22
23 workdir="$(mktemp -d)" || exit 1
24
25 FILES="swtpm-localca.conf swtpm-localca.options swtpm_setup.conf"
26
27 XDG_CONFIG_HOME="${workdir}" ${SWTPM_SETUP} \
28 --create-config-files 1>/dev/null
29
30 if [ $? -ne 0 ]; then
31 echo "Error: Could not created config files (without parameters)"
32 exit 1
33 fi
34 for f in ${FILES}; do
35 if ! [ -f "${workdir}/${f}" ]; then
36 echo "Error: File ${workedir}/${f} was not created"
37 exit 1
38 fi
39 done
40 if ! [ -d "${workdir}/var/lib/swtpm-localca" ]; then
41 echo "Error: Directory var/lib/swtpm-localca was not created"
42 exit 1
43 fi
44
45 XDG_CONFIG_HOME="${workdir}" ${SWTPM_SETUP} \
46 --create-config-files skip-if-exist 1>/dev/null
47
48 if [ $? -ne 0 ]; then
49 echo "Error: skip-if-exists should have exit'ed with 0."
50 exit 1
51 fi
52
53 echo "Test 1: Ok"
54 cleanup
55
56 workdir="$(mktemp -d)" || exit 1
57
58 XDG_CONFIG_HOME="${workdir}" ${SWTPM_SETUP} \
59 --create-config-files skip-if-exist 1>/dev/null
60
61 if [ $? -ne 0 ]; then
62 echo "Error: skip-if-exists should have exit'ed with 0."
63 exit 1
64 fi
65 for f in ${FILES}; do
66 if ! [ -f "${workdir}/${f}" ]; then
67 echo "Error: File ${workedir}/${f} was not created"
68 exit 1
69 fi
70 done
71 if ! [ -d "${workdir}/var/lib/swtpm-localca" ]; then
72 echo "Error: Directory var/lib/swtpm-localca was not created"
73 exit 1
74 fi
75
76 echo "Test 2: Ok"
77 cleanup
78
79 exit 0