diff options
Diffstat (limited to 'trust')
-rw-r--r-- | trust/Makefile.am | 7 | ||||
-rw-r--r-- | trust/test-extract.sh (renamed from trust/test-extract.in) | 92 | ||||
-rw-r--r-- | trust/test-init.sh.in | 106 |
3 files changed, 112 insertions, 93 deletions
diff --git a/trust/Makefile.am b/trust/Makefile.am index 726d249..dfc64eb 100644 --- a/trust/Makefile.am +++ b/trust/Makefile.am @@ -303,12 +303,15 @@ frob_token_SOURCES = trust/frob-token.c frob_token_LDADD = $(trust_LIBS) frob_token_CFLAGS = $(trust_CFLAGS) -noinst_SCRIPTS += trust/test-extract +noinst_SCRIPTS += trust/test-extract.sh +if !OS_WIN32 installcheck-local: - sh $(builddir)/trust/test-extract + builddir="$(abs_top_builddir)/trust" $(SHELL) $(srcdir)/trust/test-extract.sh +endif EXTRA_DIST += \ trust/input \ trust/fixtures \ + trust/test-extract.sh \ $(NULL) diff --git a/trust/test-extract.in b/trust/test-extract.sh index ec4387d..61745a9 100644 --- a/trust/test-extract.in +++ b/trust/test-extract.sh @@ -1,48 +1,6 @@ #!/bin/sh -set -euf - -# ----------------------------------------------------------------------------- -# Basic fundamentals - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -datarootdir=@datarootdir@ -datadir=@datadir@ -sysconfdir=@sysconfdir@ -libdir=@libdir@ -libexecdir=@libexecdir@ -privatedir=@privatedir@ -with_trust_paths=@with_trust_paths@ -script=$(basename $0) - -# ----------------------------------------------------------------------------- -# Testing - -warning() -{ - echo "$script: $@" >&2 -} - -assert_fail() -{ - warning $@ - exit 1 -} - -assert_contains() -{ - if ! grep -qF $2 $1; then - assert_fail "$1 does not contain $2" - fi -} - -assert_not_contains() -{ - if grep -qF $2 $1; then - assert_fail "$1 contains $2" - fi -} +. "${builddir=.}/test-init.sh" teardown() { @@ -56,12 +14,6 @@ teardown() TD="" } -teardown_dirty() -{ - echo "not ok $TEST_NUMBER $TEST_NAME" - teardown -} - openssl_quiet() ( command='/Generating a|-----|^[.+]+$|writing new private key/d' @@ -69,12 +21,6 @@ openssl_quiet() openssl $@ 2>&1 >&3 3>&- | sed -r "$command" 3>&- ) -skip() -{ - TEST_SKIP=yes - echo "ok $TEST_NUMBER # skip $TEST_NAME: $@" -} - setup() { # Parse the trust paths @@ -126,42 +72,6 @@ setup() TD="$SOURCE_1/anchors/cert_1.pem $SOURCE_2/anchors/cert_2.pem $SOURCE_2/anchors/cert_3.pem $TD" } -run() -{ - TOTAL=0 - for TEST_NAME in $@; do - TOTAL=$(expr $TOTAL + 1) - done - - echo "1..$TOTAL" - - TEST_NUMBER=0 - for TEST_NAME in $@; do - TEST_NUMBER=$(expr $TEST_NUMBER + 1) - ( - trap teardown_dirty EXIT - trap "teardown_dirty; exit 127" INT TERM - TD="" - - TEST_SKIP=no - setup - - if [ $TEST_SKIP != "yes" ]; then - $TEST_NAME - fi - if [ $TEST_SKIP != "yes" ]; then - echo "ok $TEST_NUMBER $TEST_NAME" - fi - - trap - EXIT - teardown - ) - done -} - -# ----------------------------------------------------------------------------- -# Main tests - test_extract() { trust extract --filter=ca-anchors --format=pem-bundle \ diff --git a/trust/test-init.sh.in b/trust/test-init.sh.in new file mode 100644 index 0000000..384fb25 --- /dev/null +++ b/trust/test-init.sh.in @@ -0,0 +1,106 @@ +#!/bin/sh + +set -euf + +# ----------------------------------------------------------------------------- +# Basic fundamentals + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +datarootdir=@datarootdir@ +datadir=@datadir@ +sysconfdir=@sysconfdir@ +libdir=@libdir@ +libexecdir=@libexecdir@ +privatedir=@privatedir@ +with_trust_paths=@with_trust_paths@ +script=$(basename $0) + +# ----------------------------------------------------------------------------- +# Testing + +warning() +{ + echo "$script: $@" >&2 +} + +assert_fail() +{ + warning $@ + exit 1 +} + +assert_contains() +{ + if ! grep -qF $2 $1; then + assert_fail "$1 does not contain $2" + fi +} + +assert_not_contains() +{ + if grep -qF $2 $1; then + assert_fail "$1 contains $2" + fi +} + +teardown() +{ + : +} + +teardown_dirty() +{ + echo "not ok $TEST_NUMBER $TEST_NAME" + teardown +} + +skip() +{ + TEST_SKIP=yes + echo "ok $TEST_NUMBER # skip $TEST_NAME: $@" +} + +setup() +{ + : +} + +run() +{ + TOTAL=0 + for TEST_NAME in $@; do + TOTAL=$(expr $TOTAL + 1) + done + + echo "1..$TOTAL" + + TEST_NUMBER=0 + for TEST_NAME in $@; do + TEST_NUMBER=$(expr $TEST_NUMBER + 1) + ( + trap teardown_dirty EXIT + trap "teardown_dirty; exit 127" INT TERM + TD="" + + PATH="$exec_prefix/bin:$PATH" + export PATH + + PKG_CONFIG_PATH="$libdir/pkgconfig:$datadir/pkgconfig" + export PKG_CONFIG_PATH + + TEST_SKIP=no + setup + + if [ $TEST_SKIP != "yes" ]; then + $TEST_NAME + fi + if [ $TEST_SKIP != "yes" ]; then + echo "ok $TEST_NUMBER $TEST_NAME" + fi + + trap - EXIT + teardown + ) + done +} |