From 7b2566e32979502cd142fbf53e9eea518209193d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Mon, 13 Oct 2025 21:34:36 +0200 Subject: [PATCH] Simplify test scripts. --- tools/nettle-pbkdf2-test | 6 +--- tools/sexp-conv-test | 65 ++++++++++------------------------------ 2 files changed, 16 insertions(+), 55 deletions(-) diff --git a/tools/nettle-pbkdf2-test b/tools/nettle-pbkdf2-test index 6e9b25ac..b963b6f1 100755 --- a/tools/nettle-pbkdf2-test +++ b/tools/nettle-pbkdf2-test @@ -19,11 +19,7 @@ test_pbkdf2 () { -i "$iters" -l "$length" "$salt" | tr -d '\r' > test1.out echo "$expected" | tr -d '\r' > test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1 } test_pbkdf2 passwd salt 1 "55ac046e56e3089f ec1691c22544b605" diff --git a/tools/sexp-conv-test b/tools/sexp-conv-test index c1cb7b3d..32664b79 100755 --- a/tools/sexp-conv-test +++ b/tools/sexp-conv-test @@ -14,82 +14,47 @@ print_nl () { test_advanced () { print_raw "$1" test.in - if $EMULATOR ./sexp-conv$EXEEXT -s advanced test1.out ; then - true - else - exit 1 - fi + $EMULATOR ./sexp-conv$EXEEXT -s advanced test1.out || exit 1 + print_nl "$2" test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1; } test_advanced_hex () { print_raw "$1" test.in - if $EMULATOR ./sexp-conv$EXEEXT -s hex test1.out ; then - true - else - exit 1 - fi + $EMULATOR ./sexp-conv$EXEEXT -s hex test1.out || exit 1 + print_nl "$2" test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1; } test_transport () { print_raw "$1" test.in - if $EMULATOR ./sexp-conv$EXEEXT -s transport test1.out ; then - true - else - exit 1 - fi + $EMULATOR ./sexp-conv$EXEEXT -s transport test1.out || exit 1 + print_nl "$2" test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1; } test_canonical () { print_raw "$1" test.in - if $EMULATOR ./sexp-conv$EXEEXT -s canonical test1.out ; then - true - else - exit 1 - fi + $EMULATOR ./sexp-conv$EXEEXT -s canonical test1.out || exit 1 + print_raw "$2" test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1; } test_hash () { print_raw "$1" test.in - if $EMULATOR ./sexp-conv$EXEEXT --hash=sha256 test1.out ; then - true - else - exit 1 - fi + $EMULATOR ./sexp-conv$EXEEXT --hash=sha256 test1.out || exit 1 + print_nl "$2" test2.out - if cmp test1.out test2.out ; then - true - else - exit 1; - fi + cmp test1.out test2.out || exit 1 } test_advanced '0:' '""' -- 2.47.3