Just a simple script to match constants with functions

This commit is contained in:
Frank Denis 2017-08-03 16:28:29 +02:00
parent f711c6d049
commit 544ce64000

18
test/constcheck.sh Executable file
View File

@ -0,0 +1,18 @@
#! /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 ' 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"
cc "$CT" -lsodium && ./a.out
rm -f a.out "$CT"