From 544ce64000dda1d68ff61490d65d7a78a11d9720 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 3 Aug 2017 16:28:29 +0200 Subject: [PATCH] Just a simple script to match constants with functions --- test/constcheck.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 test/constcheck.sh diff --git a/test/constcheck.sh b/test/constcheck.sh new file mode 100755 index 00000000..350753a1 --- /dev/null +++ b/test/constcheck.sh @@ -0,0 +1,18 @@ +#! /bin/sh + +CT='ct.c' + +echo '#include ' > "$CT" +echo '#include ' >> "$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" +