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
|
#!/bin/sh
log_begin()
{
printf ' %s ... ' "$*"
}
log_end()
{
if [ -n "$*" ]
then
printf 'ok\n'
return 0
else
printf 'FAIL\n'
return 1
fi
}
set -e -u
export LC_ALL=C
rc=0
build_time=
make_flags=-s
if [ "$*" = '--build-time' ]
then
build_time=build-time
ADTTMP=debian/tmp/adt/
mkdir -p $ADTTMP
rm -rf $ADTTMP/*
fi
cp -a base64/ "$ADTTMP/cmdline"
cd "$ADTTMP"
if [ -z "$build_time" ]
then
make $make_flags -C cmdline
# Check if it's dynamically linked:
log_begin 'dynamic linking to libb64'
ok=yes
ldd cmdline/base64 | grep -w libb64.so >/dev/null || ok=
log_end $ok || rc=1
fi
ln -sf /bin/sh big.orig
printf 'x' > tiny.orig
for tc in *.orig
do
base=${tc%.orig}
# ---------
log_begin "$base: decoder"
ok=yes
base64 $base.orig > $base.coreutils
cmdline/base64 -d $base.coreutils $base.coreutils.libb64 || ok=
cmp $base.orig $base.coreutils.libb64 || ok=
log_end $ok || rc=1
# ---------
log_begin "$base: encoder"
ok=yes
cmdline/base64 -e $base.orig $base.libb64 || ok=
base64 -d $base.libb64 > $base.libb64.coreutils || ok=
cmp $base.orig $base.libb64.coreutils || ok=
log_end $ok || rc=1
# ---------
log_begin "$base: round-trip"
ok=yes
cmdline/base64 -d $base.libb64 $base.libb64.libb64 || ok=
cmp $base.orig $base.libb64.libb64 || ok=
log_end $ok || rc=1
done
exit $rc
# vim:ts=4 sw=4 et
|