Debian Codegraph @

debian/tests/run-stable-test

raw
1 #!/bin/sh
2 set -e
3
4 pkg=secrecy
5
6 export LC_ALL=C.UTF-8
7 if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
8 AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
9 trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
10 fi
11
12 cd "${AUTOPKGTEST_TMP}"
13
14 set -v
15 ################################################################################
16 # Second run
17 # This is done because the main run is flaky. It allows one to identify
18 # crashes unrelated to the flaky property of the main test, hopefully.
19 ################################################################################
20 # I. Test secrecy
21 # 0. Preparation
22 HOME="${AUTOPKGTEST_TMP}"
23 export HOME
24 cp -r /usr/share/doc/secrecy/* .
25 gunzip *.gz
26 readonly GPGID="[email protected]"
27 readonly EXPIRY="$(date +'%F' -d 'tomorrow + 1 hour')"
28 gpg --batch --pinentry-mode loopback --passphrase '' \
29 --quick-generate-key "$GPGID" default default "$EXPIRY"
30
31 # 1. Create key
32 readonly KEYNAME="autpkgtest_key"
33 readonly KEYHASH="$( secrecy createKey AES256 "$GPGID" "$KEYNAME")"
34 secrecy listKeys
35
36 # NOTE: Further secrecy tests were flaky from that point, so not running them
37 # for the stable part of that autopkgtest script.
38
39 ################################################################################
40 # II. Test libsecrecy-dev
41 # 0. Preparation
42 CXXFLAGS="$( pkg-config libsecrecy --cflags )"
43 LDFLAGS="$( pkg-config libsecrecy --libs )"
44 export CXXFLAGS LDFLAGS
45 printf -- 'CXXFLAGS=%s\nLDFLAGS=%s\n' "$CXXFLAGS" "$LDFLAGS"
46
47 # 1. Encryption program
48 cat > encrypt.cpp <<-END
49 #include <libsecrecy/GCMOutputStream.hpp>
50 #include <iostream>
51
52 int main()
53 {
54 std::string const scipher = "AES256";
55 std::string const shexhash = "$KEYHASH";
56 static std::size_t const buffersize = 16*1024;
57 libsecrecy::GCMOutputStream GOS(std::cout, shexhash);
58 char B[buffersize];
59
60 while ( std::cin )
61 {
62 std::cin.read(&B[0],buffersize);
63 GOS.write(&B[0],std::cin.gcount());
64 }
65 }
66 END
67 CXX=g++
68 "$CXX" $CXXFLAGS -c encrypt.cpp -o encrypt.o
69 "$CXX" $CXXFLAGS encrypt.o -o encrypt $LDFLAGS
70 CXX=clang++
71 "$CXX" $CXXFLAGS -c encrypt.cpp -o encrypt.o
72 "$CXX" $CXXFLAGS encrypt.o -o encrypt $LDFLAGS
73 # NOTE: program execution flaky, so not tested in this stable pass.
74
75 # 2. Decryption program
76 cat > decrypt.cpp <<-END
77 #include <libsecrecy/GCMInputStream.hpp>
78 #include <iostream>
79
80 int main()
81 {
82 libsecrecy::GCMInputStream GIS(std::cin);
83 static std::size_t const buffersize = 16*1024;
84 char B[buffersize];
85
86 while ( GIS )
87 {
88 GIS.read(&B[0],buffersize);
89 std::cout.write(&B[0],GIS.gcount());
90 }
91 }
92 END
93 CXX=g++
94 "$CXX" $CXXFLAGS -c decrypt.cpp -o decrypt.o
95 "$CXX" $CXXFLAGS decrypt.o -o decrypt $LDFLAGS
96 CXX=clang++
97 "$CXX" $CXXFLAGS -c decrypt.cpp -o decrypt.o
98 "$CXX" $CXXFLAGS decrypt.o -o decrypt $LDFLAGS
99 # NOTE: program execution flaky, so not tested in this stable pass.
100
101 ################################################################################