1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 10:05:05 -07:00
libsodium/test/constcheck.sh

22 lines
631 B
Bash
Raw Normal View History

#! /bin/sh
CT='ct.c'
echo '#include <assert.h>' > "$CT"
echo '#include <sodium.h>' >> "$CT"
echo 'int main(void) {' >> "$CT"
2023-11-23 05:34:36 -07:00
for macro in $(grep -Er '#define crypto_.*BYTES(_[A-Z]+)? ' src/libsodium/include | \
cut -d: -f2- | cut -d' ' -f2 | sort -u); do
func=$(echo "$macro" | tr A-Z a-z)
2017-08-25 05:49:47 -07:00
echo " assert($func() == $macro);" >> "$CT"
done
echo "return 0; }" >> "$CT"
CPPFLAGS="${CPPFLAGS} -Wno-deprecated-declarations"
CPPFLAGS="${CPPFLAGS} -I/opt/homebrew/include"
LDFLAGS="${LDFLAGS} -L/opt/homebrew/lib"
${CC:-cc} "$CT" $CPPFLAGS $CFLAGS $LDFLAGS -lsodium || exit 1
2017-08-25 05:49:47 -07:00
./a.out || exit 1
rm -f a.out "$CT"