File: constcheck.sh

package info (click to toggle)
libsodium 1.0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, trixie
  • size: 7,372 kB
  • sloc: ansic: 45,151; asm: 4,264; makefile: 870; sh: 640; python: 405; xml: 30; pascal: 11
file content (20 lines) | stat: -rwxr-xr-x 595 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh

CT='ct.c'

echo '#include <assert.h>' > "$CT"
echo '#include <sodium.h>' >> "$CT"
echo 'int main(void) {' >> "$CT"
for macro in $(egrep -r '#define crypto_.*BYTES(_[A-Z]+)? ' src/libsodium/include | \
               cut -d: -f2- | cut -d' ' -f2 | \
               fgrep -v edwards25519sha512batch | sort -u); do
  func=$(echo "$macro" | tr A-Z a-z)
  echo "    assert($func() == $macro);" >> "$CT"
done
echo "return 0; }" >> "$CT"

CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations"
${CC:-cc} "$CT" $CPPFLAGS $CFLAGS $LDFLAGS -lsodium || exit 1
./a.out || exit 1
rm -f a.out "$CT"