| 1 |
#!/bin/sh |
| 2 |
# 20210206 |
| 3 |
# Jan Mojzis |
| 4 |
# Public domain. |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
dir=`dirname "$0"` |
| 9 |
|
| 10 |
# change directory to $AUTOPKGTEST_TMP |
| 11 |
cd "${AUTOPKGTEST_TMP}" |
| 12 |
|
| 13 |
cleanup() { |
| 14 |
ex=$? |
| 15 |
rm -f 01seeder.bin 01seeder.ldd |
| 16 |
exit "${ex}" |
| 17 |
} |
| 18 |
trap "cleanup" EXIT TERM INT |
| 19 |
|
| 20 |
CC="cc -I/usr/include/bearssl/" |
| 21 |
|
| 22 |
# build the dynamic binary |
| 23 |
${CC} -Os -o 01seeder.bin "${dir}/01seeder.c" -lbearssl |
| 24 |
|
| 25 |
# SO check |
| 26 |
ldd ./01seeder.bin > 01seeder.ldd |
| 27 |
if ! grep -q 'libbearssl.so' < 01seeder.ldd; then |
| 28 |
echo "binary is not linked against dynamic library:" >&2 |
| 29 |
cat 01seeder.ldd >&2 |
| 30 |
exit 1 |
| 31 |
fi |
| 32 |
|
| 33 |
# run and remove the binary |
| 34 |
./01seeder.bin |
| 35 |
rm -f 01seeder.bin 01seeder.ldd |
| 36 |
|
| 37 |
|
| 38 |
# use compiler without -I/usr/include/bearssl/ |
| 39 |
CC="cc" |
| 40 |
|
| 41 |
# build the static binary |
| 42 |
${CC} -Os -o 01seeder.bin "${dir}/01seeder.c" "/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libbearssl.a" |
| 43 |
|
| 44 |
# SO check |
| 45 |
ldd ./01seeder.bin > 01seeder.ldd |
| 46 |
if grep -q 'libbearssl.so' < 01seeder.ldd; then |
| 47 |
echo "binary IS linked against dynamic library:" >&2 |
| 48 |
cat 01seeder.ldd >&2 |
| 49 |
exit 1 |
| 50 |
fi |
| 51 |
|
| 52 |
# run and remove the binary |
| 53 |
./01seeder.bin |
| 54 |
rm -f 01seeder.bin 01seeder.ldd |
| 55 |
|
| 56 |
exit 0 |