Debian Codegraph @

debian/tests/testvalgrind

raw symbols SCIP
1 #!/bin/sh
2
3 dir=`dirname "$0"`
4
5 # change directory to $AUTOPKGTEST_TMP
6 cd "${AUTOPKGTEST_TMP}"
7
8 cleanup() {
9 ex=$?
10 rm -f testvalgrind.bin mustfail.log
11 exit "${ex}"
12 }
13 trap "cleanup" EXIT TERM INT
14
15 # test if valgrind package exists
16 echo 'test if valgrind package exists ... START'
17 if which valgrind >/dev/null; then
18 echo 'test if valgrind package exists ... OK'
19 else
20 echo 'test if valgrind package exists ... FAILED, skipping tests'
21 exit 77
22 fi
23
24 # try to install libmceliece1-dbgsym
25 (
26 exec 2>&1
27 dpkg -l libmceliece1-dbgsym >/dev/null && exit 0
28 apt-get update
29 apt-get -y install libmceliece1-dbgsym
30 ) || :
31
32 # test if libmceliece1-dbgsym package exists
33 echo 'test if libmceliece1-dbgsym package exists ... START'
34 if dpkg -l libmceliece1-dbgsym 1>/dev/null 2>&1; then
35 echo 'test if libmceliece1-dbgsym package exists ... OK'
36 else
37 echo 'test if libmceliece1-dbgsym package exists ... NOT EXIST (valgrind will not print debug symbols)'
38 fi
39
40 ulimit -s unlimited
41
42 CC="cc -O2"
43 VALGRIND="env valgrind_multiplier=1 valgrind -q --max-stackframe=16777216 --error-exitcode=99"
44
45 echo 'compilation ... START'
46 if ${CC} -o testvalgrind.bin "${dir}/testvalgrind.c" -lmceliece 2>&1; then
47 echo 'compilation ... OK'
48 else
49 echo 'compilation ... FAILED, skipping tests'
50 exit 77
51 fi
52
53 # test if valgrind works, valgrind must show tracebacks:"
54 # mustfail_keypair ... Conditional jump or move depends on uninitialised value(s)"
55 # mustfail_enc ....... Use of uninitialised value"
56 # mustfail_dec ....... Use of uninitialised value"
57 ${VALGRIND} ./testvalgrind.bin mustfail ref >mustfail.log 2>&1
58 RET=$?
59 if [ $RET -eq 99 ]; then
60 echo 'test if valgrind works ... START'
61 # uncomment to print valgrind traceback
62 # cat mustfail.log
63 echo 'test if valgrind works ... OK'
64 elif [ $RET -eq 0 ]; then
65 echo 'test if valgrind works ... FAILED, skipping tests'
66 exit 77
67 else
68 cat mustfail.log
69 echo 'test if valgrind works ... FAILED, but with exit code not from valgrind, skipping tests'
70 exit 77
71 fi
72
73 # main test
74 EX=0
75 for primitive in 6960119 6688128 8192128 460896 348864; do
76 for variant in '' f; do
77 for implname in vec avx; do
78 echo "mceliece${primitive}${variant} ${implname} ... START"
79 ${VALGRIND} ./testvalgrind.bin "${primitive}${variant}" "${implname}"
80 RET=$?
81 if [ $RET -eq 0 ]; then
82 echo "mceliece${primitive}${variant} ${implname} ... OK"
83 elif [ $RET -eq 10 ]; then
84 echo "mceliece${primitive}${variant} ${implname} ... NOT AVAILABLE (skipping)"
85 else
86 echo "mceliece${primitive}${variant} ${implname} ... FAILED" >&2
87 EX=1
88 fi
89 done
90 done
91 done
92
93 exit "${EX}"