Skip to content

Commit

Permalink
Merge PR #44
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed May 15, 2024
2 parents 365012e + 6949475 commit c0a8445
Show file tree
Hide file tree
Showing 52 changed files with 122 additions and 68 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/distcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: make distcheck
on:
pull_request:
branches:
- main
push:
workflow_dispatch:
jobs:
distcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Fetch tags so that Autoconf can discover the version.
fetch-depth: 0
- run: autoreconf -fviW all,error
- run: ./configure
- run: make distcheck
- uses: actions/upload-artifact@v4
with:
name: distribution-tarball
path: pgpdump-*.tar.gz
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/configure
/pgpdump-*.tar.gz
/stamp-h1
/test-suite.log
/test/*.log
/test/*.trs
Makefile
config.h
config.log
Expand Down
29 changes: 29 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,35 @@ pgpdump_SOURCES = \
uatfunc.c
dist_man1_MANS = pgpdump.1

AM_TESTS_ENVIRONMENT = PGPDUMP='$(builddir)/pgpdump'
TEST_EXTENSIONS = .res
RES_LOG_COMPILER = $(srcdir)/test/test
RES_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
TESTS = \
test/enc1.res \
test/enc2.res \
test/enc3.res \
test/enc.res \
test/gpg1.res \
test/gpg233_dsa_elgamal_test_key.pub.der.res \
test/gpg233_ecc_sign_encrypt_Brainpool_P-256_test-key.pub.der.res \
test/gpg233_ecc_sign_encrypt_Curve25519_test_key.pub.der.res \
test/gpg233_ecc_sign_encrypt_NIST_P_384_test_key.pub.der.res \
test/gpg233_ecc_sign_only_Brainpool_P-256_test_key.pub.der.res \
test/gpg233_ecc_sign_only_Curve_25519_test_key.pub.der.res \
test/gpg233_ecc_sign_only_NIST_P-384_test_key.pub.der.res \
test/gpg-2.3.3_rsa_dsa_test_key.pub.der.res \
test/gpg233_rsa_sign_only_test_key.pub.der.res \
test/gpg2.res \
test/gpg3.res \
test/pub1.res \
test/pub.res \
test/sig1.res \
test/sig2.res \
test/sig3.res \
test/sig.res
EXTRA_DIST += $(TESTS) $(TESTS:.res=) test/test

EXTRA_DIST += build-aux/git-version-gen
dist-hook:
printf %s\\n '$(VERSION)' >'$(distdir)'/.dist-version
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Here is an example:

% pgpdump data/sig1
% pgpdump test/sig1
Old: Marker Packet(tag 10)(3 bytes)
String - ...
New: One-Pass Signature Packet(tag 4)(13 bytes)
Expand Down Expand Up @@ -51,7 +51,8 @@ Binaries are available for Mac OS X via Homebrew:

To know how to use pgpdump, type `pgpdump -h`.

Some examples are stored in the `data` directory. Also, you can visualize your pubring and secring.
Some examples are stored in the `test` directory. Also, you can visualize your
pubring and secring.

## Home page

Expand All @@ -65,12 +66,20 @@ The official home page of pgpdump is:

## Testing

The test program is written in Haskell. I recommend to install [Haskell Platform](https://www.haskell.org/platform/) if you want to test. After that, please install necessary libraries:
To run all of the tests:

% cabal install test-framework-hunit
% make check

or:

Now you can execute the test program:
% make
% ./test/test

To run specific tests:

% make check TESTS="test/pub.res test/sig.res"

% cd data
% runghc test.hs
or:

% make
% ./test/test test/pub.res test/sig.res
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AC_INIT([pgpdump],
[https://www.mew.org/~kazu/proj/pgpdump/])
AC_CONFIG_SRCDIR([pgpdump.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects no-define])

dnl Checks for programs.
Expand Down
41 changes: 0 additions & 41 deletions data/test.hs

This file was deleted.

20 changes: 0 additions & 20 deletions data/test.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions test/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

# The output of this script is intended to follow the Test Anything Protocol (TAP):
# https://testanything.org

pecho() ( unset IFS; printf %s\\n "$*"; )
log() { pecho "# $@"; }
bailout() { pecho "Bail out! $@"; exit 1; }

mydir=${0%/*}
: "${PGPDUMP=${mydir}/../pgpdump}"
[ "$#" -gt 0 ] || set -- "$mydir"/*.res
status=0
i=0

do_test() {
want=$1
in=${want%.res}
# Command substitution strips all trailing newlines. Echo a character to be stripped later
# so that all trailing newlines are preserved for accurate stdout comparison.
got=$("${PGPDUMP}" -u <${in} && pecho x) || {
log "pgpdump exited with non-zero status $?"
return 1
}
got=${got%x}
diff=$(printf %s "${got}" | diff -au "${want}" -)
[ -z "${diff}" ] || {
log "unexpected stdout; diff from want to got:"
while IFS= read -r line; do
log "$line"
done <<EOF
$diff
EOF
return 1
}
}

pecho "TAP version 14"
pecho "1..$#"
[ -x "${PGPDUMP}" ] || bailout "${PGPDUMP} is not executable"
for want in "$@"; do
i=$((i+1))
if do_test "${want}"; then
pecho "ok ${i} - ${want}"
else
status=1
pecho "not ok ${i} - ${want}"
fi
done

exit "$status"

0 comments on commit c0a8445

Please sign in to comment.