File: test-invocation.sh

package info (click to toggle)
libkcapi 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,992 kB
  • sloc: ansic: 13,808; sh: 2,422; perl: 1,949; makefile: 287
file content (138 lines) | stat: -rwxr-xr-x 2,771 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#
# Copyright (C) 2016 - 2022, Stephan Mueller <smueller@chronox.de>
#
# License: see LICENSE file in root directory
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
# WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#

DIRNAME="$(dirname "$0")"
. "$DIRNAME/libtest.sh"

COMPILE_OPTS="--enable-kcapi-test --enable-kcapi-encapp --enable-kcapi-hasher --enable-kcapi-dgstapp --enable-kcapi-rngapp --enable-lib-kpp --enable-lib-asym"

exec_test()
{
	"$DIRNAME/test.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	"$DIRNAME/kcapi-enc-test.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	"$DIRNAME/kcapi-dgst-test.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	"$DIRNAME/hasher-test.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	"$DIRNAME/kcapi-enc-test-large.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	"$DIRNAME/kcapi-convenience.sh"
	ret=$?
	if [ $ret -ne 0 ]
	then
		exit $ret
	fi

	# Run optionally.
	if [ ! -z "$ENABLE_FUZZ_TEST" ]
	then
		"$DIRNAME/kcapi-fuzz-test.sh"
		ret=$?
		if [ $ret -ne 0 ]
		then
			exit $ret
		fi
	fi

	# Only execute on bare metal
	if ! dmesg | grep -i Hypervisor | grep -q -i detected
	then
		"$DIRNAME/virttest.sh"
		ret=$?
		if [ $ret -ne 0 ]
		then
			exit $ret
		fi
	fi
}

# Only execute tests without compilation on virtual environment
if [ "$KCAPI_TEST_LOCAL" -ne 1 ] || mount | grep -q "9p2000"
then
	exec_test
	exit 0
fi

# default invocation
(cd "$DIRNAME/.." && ./configure $COMPILE_OPTS && make)
if [ $? -ne 0 ]
then
	echo "Compilation failure"
	exit 1
fi
exec_test

"$DIRNAME/compile-test.sh"
ret=$?
if [ $ret -ne 0 ]
then
	exit $ret
fi

(cd "$DIRNAME/.." && make distclean > /dev/null 2>&1)

# if we are on 64 bit system, test 32 bit alternative mode,
# except is has been disabled explicitly.
if $(uname -m | grep -q "x86_64") && [ -z "$NO_32BIT_TEST" ]
then
	(
		cd "$DIRNAME/.." && \
		LDFLAGS="-m32 $LDFLAGS" \
		CFLAGS="-m32 $CFLAGS" \
		./configure $COMPILE_OPTS && \
		make
	)
	if [ $? -ne 0 ]
	then
		echo "32 bit compilation failure"
		exit 1
	fi
	exec_test
	(cd "$DIRNAME/.." && make distclean > /dev/null 2>&1)
fi

exit 0