1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-02 22:38:02 +02:00
Commit Graph

399 Commits

Author SHA1 Message Date
Justus Winter
a3b258d1d1 gpgscm: Refactor.
* tests/gpgscm/scheme.c (opexe_0): Reduce code duplication.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Justus Winter
d8df804272 gpgscm: Fix property lists.
* tests/gpgscm/opdefines.h (put, get): Check arguments.  Also rename
to 'set-symbol-property' and 'symbol-property', the names used by
Guile, because put and get are too unspecific.
* tests/gpgscm/scheme.c (hasprop): Only symbols have property lists.
(get_property): New function.
(set_property): Likewise.
(opexe_4): Use the new functions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Justus Winter
7b4e2ea274 gpgscm: Fix installation of error handler.
* tests/gpgscm/ffi.scm: Set '*error-hook*' again so that the
interpreter will use our function.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Justus Winter
66834eb838 gpgscm: Use a static pool of cells for small integers.
* tests/gpgscm/scheme-private.h (struct scheme): New fields for the
static integer cells.
* tests/gpgscm/scheme.c (_alloc_cellseg): New function.
(alloc_cellseg): Use the new function.
(MAX_SMALL_INTEGER): New macro.
(initialize_small_integers): New function.
(mk_small_integer): Likewise.
(mk_integer): Return a small integer if possible.
(_s_return): Do not free 'op' if it is a small integer.
(s_save): Use a small integer to box the opcode.
(scheme_init_custom_alloc): Initialize small integers.
(scheme_deinit): Free chunk of small integers.
* tests/gpgscm/scheme.h (USE_SMALL_INTEGERS): New macro.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Justus Winter
893a3f7fb4 tests: Delay querying the avaliable algorithms.
* tests/openpgp/defs.scm: Set verbosity earlier, turn 'all-*-algos'
into promises.
* tests/openpgp/conventional-mdc.scm: Force the promises.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Neal H. Walfield
037f9de092 g10: Cache the effective policy. Recompute it when required.
* g10/tofu.c (initdb): Add column effective_policy to the bindings
table.
(record_binding): New parameters effective_policy and set_conflict.
Save the effective policy.  If SET_CONFLICT is set, then set conflict
according to CONFLICT.  Otherwise, preserve the current value of
conflict.  Update callers.
(get_trust): Don't compute the effective policy here...
(get_policy): ... do it here, if it was not cached.  Take new
parameters, PK, the public key, and NOW, the time that the operation
started.  Update callers.
(show_statistics): New parameter PK.  Pass it to get_policy.  Update
callers.
(tofu_notice_key_changed): New function.
* g10/gpgv.c (tofu_notice_key_changed): New stub.
* g10/import.c (import_revoke_cert): Take additional argument CTRL.
Pass it to keydb_update_keyblock.
* g10/keydb.c (keydb_update_keyblock): Take additional argument CTRL.
Update callers.
[USE_TOFU]: Call tofu_notice_key_changed.
* g10/test-stubs.c (tofu_notice_key_changed): New stub.
* tests/openpgp/tofu.scm: Assume that manually setting a binding's
policy to auto does not cause the tofu engine to forget about any
conflict.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

We now store the computed policy in the tofu DB (in the
effective_policy column of the bindings table) to avoid computing it
every time, which is expensive.  Further, policy is never overridden
in case of a conflict.  Instead, we detect a conflict if CONFLICT is
not empty.

This change is backwards compatible to existing DBs.  The only minor
incompatibility is that unresolved conflicts won't be automatically
resolved in case we import a direct signature, or cross signatures.
2016-11-21 22:47:30 +01:00
Justus Winter
4f189325a4 gpgscm: Re-enable the garbage collector in case of errors.
* tests/gpgscm/scheme.c (opexe_0): Enable gc before calling 'Error_1'.

Fixes-commit: 83c184a66b
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-17 13:25:14 +01:00
Justus Winter
fc53a4d06e gpgscm: Fix string.
* tests/gpgscm/scheme.c (type_to_string): Fix string.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-17 13:24:54 +01:00
Justus Winter
64a58e23c3 gpgscm: Mark cells requiring finalization.
* tests/gpgscm/scheme.c (T_FINALIZE): New macro.
(mk_port): Use the new macro.
(mk_foreign_object): Likewise.
(mk_counted_string): Likewise.
(mk_empty_string): Likewise.
(gc): Only call 'finalize_cell' for cells with the new flag.
--

This speeds up the sweep phase of the garbage collector considerably
because most cells do not require finalization.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-15 11:10:56 +01:00
Justus Winter
93cc322ac0 gpgscm: Recover more cells.
* tests/gpgscm/scheme.c (_s_return): Recover the cell holding the
opcode.

Fixes-commit: e0cbd3389e
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-15 11:10:56 +01:00
Justus Winter
83c184a66b gpgscm: Avoid cell allocation overhead.
* tests/gpgscm/scheme-private.h (struct scheme): New fields
'inhibit_gc', 'reserved_cells', and 'reserved_lineno'.
* tests/gpgscm/scheme.c (GC_ENABLED): New macro.
(USE_GC_LOCKING): Likewise.
(gc_reservations): Likewise.
(gc_reservation_failure): New function.
(_gc_disable): Likewise.
(gc_disable): New macro.
(gc_enable): Likewise.
(gc_enabled): Likewise.
(gc_consume): Likewise.
(get_cell_x): Consume reserved cell if garbage collection is disabled.
(_get_cell): Assert that gc is enabled.
(get_cell): Only record cell in the list of recently allocated cells
if gc is enabled.
(get_vector_object): Likewise.
(gc): Assert that gc is enabled.
(s_return): Add comment, adjust call to '_s_return'.
(s_return_enable_gc): New macro.
(_s_return): Add flag 'enable_gc' and re-enable gc if set.
(oblist_add_by_name): Use the new facilities to protect the
allocations.
(new_frame_in_env): Likewise.
(new_slot_spec_in_env): Likewise.
(s_save): Likewise.
(opexe_0): Likewise.
(opexe_1): Likewise.
(opexe_2): Likewise.
(opexe_5): Likewise.
(opexe_6): Likewise.
(scheme_init_custom_alloc): Initialize the new fields.
--

Every time a cell is allocated, the interpreter may run out of free
cells and do a garbage collection.  This is problematic because it
might garbage collect objects that have been allocated, but are not
yet made available to the interpreter.

Previously, we would plug such newly allocated cells into the list of
newly allocated objects rooted at car(sc->sink), but that requires
allocating yet another cell increasing pressure on the memory
management system.

A faster alternative is to preallocate the cells needed for an
operation and make sure the garbage collection is not run until all
allocated objects are plugged in.  This can be done with gc_disable
and gc_enable.

This optimization can be applied incrementally.  This commit picks all
low-hanging fruits.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-14 16:11:15 +01:00
Justus Winter
ee08677d63 gpgscm: Recover cells from the list of recently allocated cells.
* tests/gpgscm/scheme.c (ok_to_freely_gc): Recover cells.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:57:07 +01:00
Justus Winter
e0cbd3389e gpgscm: Recover cells used to maintain interpreter state.
* tests/gpgscm/scheme.c (free_cell): New function.
(free_cons): Likewise.
(_s_return): Use the new function to recover cells used to save the
state of the interpreter in 's_save'.  This reduces the need to do a
garbage collection considerably.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:57:07 +01:00
Justus Winter
d3a98ff5bc gpgscm: Reduce opcode dispatch overhead.
* tests/gpgscm/scheme.c (s_thread_to): New macro.
(CASE): Likewise.
(opexe_[0-6]): Use 'CASE' instead of 'case' statements, replace
's_goto' with 's_thread_to' where applicable.
--

This is a straight-forward optimization that replaces 's_goto' in
certain cases.  Instead of returning to the calling function, and
dispatching the next opcode, we can jump to the opcode handler.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:57:07 +01:00
Justus Winter
568cfcde45 gpgscm: Make the compile-hook configurable.
* tests/gpgscm/scheme-private.h (struct scheme): Make field
'COMPILE_HOOK' optional.
* tests/gpgscm/scheme.c (opexe_0): Fix guard.
(scheme_init_custom_alloc): Conditionally initialize 'COMPILE_HOOK'.
* tests/gpgscm/scheme.h (USE_COMPILE_HOOK): Define to 1 by default.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:57:07 +01:00
Justus Winter
9ee184bc0a gpgscm: Drop obsolete commented-out code.
* tests/gpgscm/scheme.c (opexe_5): Drop obsolete code.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:57:07 +01:00
Justus Winter
d7c5799c28 gpgscm: Remove dubious stack implementation.
* tests/gpgscm/scheme-private.h (struct scheme): Remove related fields.
* tests/gpgscm/scheme.c: Drop all !USE_SCHEME_STACK code.
* tests/gpgscm/scheme.h (USE_SCHEME_STACK): Remove macro.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-10 14:54:27 +01:00
Justus Winter
1062953d51 tests: Fix environment setup.
* tests/openpgp/defs.scm (setup-legacy-environment): Do not call
'setup-environment' because that will start the agent, and hence
register the atexit function twice.

Fixes: a55393cb5f
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:15:32 +01:00
Justus Winter
2a7615c48e tests: Log and display output from tests when run in parallel.
* tests/openpgp/run-tests.scm (test): Add field 'logfd'.
(test::new, test::set-*): Adapt accordingly.
(test::set-logfd): New function.
(test::open-log-file): Likewise.
(test::run-sync): Use the new function.
(test::run-async): Likewise.
(test::report): Replay the log.
(run-tests-parallel): Reverse the results to restore the original
order.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:03:16 +01:00
Justus Winter
4dd4801bfa tests: Simplify test.
* tests/openpgp/issue2417.scm: Simplify.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:03:16 +01:00
Justus Winter
591d61d80f gpgscm: Expose seek and associated constants.
* tests/gpgscm/ffi.c (do_seek): New function.
(ffi_init): Expose 'seek' and 'SEEK_{SET,CUR,END}'.
* tests/gpgscm/lib.scm: Document the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:02:55 +01:00
Justus Winter
d4454837cd gpgscm: Fix error message.
* tests/gpgscm/ffi.c (do_wait_processes): Fix and improve error
messages.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:02:55 +01:00
Justus Winter
dd13b2a561 tests,w32: Make cleanup more robust.
* tests/openpgp/run-tests.scm (run-tests-parallel): Catch errors when
removing the working directory.  On Windows this can fail if there is
still a process using one of the files there.
(run-tests-sequential): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:02:55 +01:00
Justus Winter
26df829fa2 tests: Write a log file for each test.
* tests/openpgp/Makefile.am (CLEANFILES): Delete logs.
* tests/openpgp/run-tests.scm (test::run-sync): Write logs.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 17:44:34 +01:00
Justus Winter
abe0cc7a21 gpgscm: Generalize splice to write to multiple sinks.
* tests/gpgscm/ffi.c (ordinal_suffix): New function.
(do_splice): Generalize splice to write to multiple sinks.
* tests/gpgscm/lib.scm (splice): Document this fact.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 17:40:43 +01:00
Justus Winter
4d98a72b88 gpgscm: Drop 'len' argument from splice.
* tests/gpgscm/ffi.c (do_splice): Drop 'len' argument, no-one uses it.
* tests/gpgscm/lib.scm (splice): Document foreign function.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 17:01:48 +01:00
Justus Winter
a55393cb5f tests: Move environment creation and teardown into each test.
* tests/gpgscm/tests.scm (log): New function.
* tests/openpgp/run-tests.scm (run-tests-parallel): Do not run the
startup and teardown scripts.
(run-tests-sequential): Likewise.
* tests/openpgp/setup.scm: Move all functions...
* tests/openpgp/defs.scm: ... here and make them less verbose.
(setup-environment): New function.
(setup-legacy-environment): Likewise.
(start-agent): Make less verbose, run 'stop-agent' at interpreter
exit.
(stop-agent): Make less verbose.
* tests/openpgp/finish.scm: Drop file.
* tests/openpgp/Makefile.am (EXTRA_DIST): Drop removed file.
* tests/openpgp/4gb-packet.scm: Use 'setup-environment' or
'setup-legacy-environment' as appropriate.
* tests/openpgp/armdetach.scm: Likewise.
* tests/openpgp/armdetachm.scm: Likewise.
* tests/openpgp/armencrypt.scm: Likewise.
* tests/openpgp/armencryptp.scm: Likewise.
* tests/openpgp/armor.scm: Likewise.
* tests/openpgp/armsignencrypt.scm: Likewise.
* tests/openpgp/armsigs.scm: Likewise.
* tests/openpgp/clearsig.scm: Likewise.
* tests/openpgp/conventional-mdc.scm: Likewise.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/decrypt-dsa.scm: Likewise.
* tests/openpgp/decrypt.scm: Likewise.
* tests/openpgp/default-key.scm: Likewise.
* tests/openpgp/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/export.scm: Likewise.
* tests/openpgp/finish.scm: Likewise.
* tests/openpgp/genkey1024.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/gpgv-forged-keyring.scm: Likewise.
* tests/openpgp/import.scm: Likewise.
* tests/openpgp/issue2015.scm: Likewise.
* tests/openpgp/issue2417.scm: Likewise.
* tests/openpgp/issue2419.scm: Likewise.
* tests/openpgp/key-selection.scm: Likewise.
* tests/openpgp/mds.scm: Likewise.
* tests/openpgp/multisig.scm: Likewise.
* tests/openpgp/quick-key-manipulation.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/shell.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.
* tests/openpgp/ssh.scm: Likewise.
* tests/openpgp/tofu.scm: Likewise.
* tests/openpgp/use-exact-key.scm: Likewise.
* tests/openpgp/verify.scm: Likewise.
* tests/openpgp/version.scm: Likewise.
* tests/openpgp/issue2346.scm: Likewise and simplify.
--

The previous Bourne Shell-based test suite created the environment
before running all tests, and tore it down after executing them.  When
we created the Scheme-based test suite, we kept this design at first,
but introduced a way to run each test in its own environment to
prevent tests from interfering with each other.  Nevertheless, every
test started out with the same environment.

Move the creation of the test environment into each test.  This gives
us finer control over the environment each test is run in.  It also
makes it possible to run each test by simply executing it using gpgscm
without the use of the runner.  Furthermore, it has the neat
side-effect of speeding up the test suite if run in parallel.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 16:36:36 +01:00
Justus Winter
ac078469cb tests: Do not allow tests to be run in a shared environment.
* tests/openpgp/README: Update.
* tests/openpgp/run-tests.scm (run-tests-parallel-shared): Drop
function.
(run-tests-parallel-isolated): Rename to 'run-tests-parallel'.
(run-tests-sequential-shared): Drop function.
(run-tests-sequential-isolated): Rename to 'run-tests-sequential'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 14:57:51 +01:00
Justus Winter
37751d2b19 tests: Fix build.
* tests/openpgp/Makefile.am: Drop dependency on 'mk-tdata'.

Fixes: 70215ff470
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 14:10:38 +01:00
Justus Winter
70215ff470 tests,tools: Reimplement 'mk-tdata' in Scheme.
* tests/openpgp/defs.scm (tools): Drop 'mk-tdata'.
* tests/openpgp/setup.scm (make-test-data): New function.
* tests/openpgp/verify.scm: Avoid 'mk-tdata'.
* tools/Makefile.am (noinst_PROGRAMS): Drop 'mk-tdata'.
* tools/mk-tdata.c: Drop file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 13:28:55 +01:00
Justus Winter
413cc50345 gpgscm,w32: Provide schemish file handling for binary files.
* tests/gpgscm/lib.scm (call-with-binary-input-file): New function.
(call-with-binary-output-file): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 13:13:31 +01:00
Justus Winter
6e677f9b55 gpgscm: Add support for pseudo-random numbers.
* tests/gpgscm/ffi.c (do_getpid): New function.
(do_srandom): Likewise.
(random_scaled): Likewise.
(do_random): Likewise.
(do_make_random_string): Likewise.
(ffi_init): Expose the new functions.
* tests/gpgscm/lib.scm: Document the new functions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 13:00:15 +01:00
Werner Koch
4d7dc432b5
Change all http://www.gnu.org in license notices to https://
--
2016-11-05 12:02:19 +01:00
Justus Winter
1f45878a72 gpgscm: Fix printing strings containing zero bytes.
* tests/gpgscm/scheme.c (atom2str): Fix computing the length of Scheme
strings.  Scheme strings can contain zero bytes.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-04 13:45:30 +01:00
Justus Winter
43f8006f5c gpgscm: Implement 'atexit'.
* tests/gpgscm/ffi.scm (throw): Run *run-atexit-handlers* when
terminating the interpreter.
(*atexit-handlers*): New variable.
(*run-atexit-handlers*): New function.
(atexit): Likewise.
* tests/gpgscm/main.c (main): Run *run-atexit-handlers* at normal
interpreter shutdown.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-04 12:42:00 +01:00
Justus Winter
ab89164be0 g10: Improve and unify key selection for -r and --locate-keys.
* g10/getkey.c (struct pubkey_cmp_cookie): New type.
(key_is_ok, uid_is_ok, subkey_is_ok): New functions.
(pubkey_cmp): Likewise.
(get_best_pubkey_byname): Likewise.
* g10/keydb.h (get_best_pubkey_byname): New prototype.
* g10/keylist.c (locate_one): Use the new function.
* g10/pkclist.c (find_and_check_key): Likewise.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
(TEST_FILES): Add new files.
* tests/openpgp/key-selection.scm: New file.
* tests/openpgp/key-selection/0.asc: Likewise.
* tests/openpgp/key-selection/1.asc: Likewise.
* tests/openpgp/key-selection/2.asc: Likewise.
* tests/openpgp/key-selection/3.asc: Likewise.
* tests/openpgp/key-selection/4.asc: Likewise.
--

When a name resembling a mail address is given to either --locate-keys
or --recipient, rank the search results and use only the most relevant
key.

This also lets us query which key will be used for encryption using
--locate-keys.  However, note that --locate-keys may also return keys
incapable of encryption, though it will prefer keys that have an
encryption subkey.

GnuPG-bug-id: 2359
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-03 15:04:18 +01:00
Justus Winter
1ec07cbc20 gpgscm,tests: Add new functions to the test environment.
* tests/gpgscm/lib.scm (first, last, powerset): New functions.
* tests/gpgscm/tests.scm (interactive-shell): New function.
* tests/openpgp/Makefile.am (EXTRA_DIST): Add new file.
* tests/openpgp/README: Document 'interactive-shell'.
* tests/openpgp/shell.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-03 14:43:23 +01:00
Justus Winter
60ad1a7f37 gpgscm: Fix inclusion of readline header.
* tests/gpgscm/ffi.c: Define magic macro to prevent the completion
function from redefined.

GnuPG-bug-id: 2824
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-02 13:06:06 +01:00
Daniel Kahn Gillmor
68b59bbc42 Spelling: correct spelling of "passphrase".
There were several different variant spellings of "passphrase".  This
should fix them all for all English text.

I did notice that po/it.po contains multiple instances of
"passhprase", which also looks suspect to me, but i do not know
Italian, so i did not try to correct it.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-11-02 12:53:58 +01:00
Werner Koch
21b318452a
tests: Improve portability of fake-pinentry.
* tests/openpgp/fake-pinentry.c: Make all functions static.
(get_passphrase): s/unlink/remove/ because that is standard C.
(spacep): Rename to whitespace and change all callers.
(main): Move macro out of if-then chain.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-10-26 08:34:18 +02:00
Justus Winter
852b8f0b89 agent,tests,w32: Fix relaying pinentry user data, fix fake-pinentry.
* agent/call-pinentry.c (start_pinentry): Also send the user data
using an Assuan 'OPTION' command.
* tests/openpgp/fake-pinentry.c (get_passphrase): Fix updating
passphrase file.
(spacep): Include newline characters.
(rstrip): New function.
(main): Handle Windows line endings.  Handle the userdata option, and
restart with the new options.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-25 17:07:08 +02:00
Justus Winter
f88f11a256 tests: Do not autostart gpg-agents on teardown.
* tests/openpgp/defs.c (stop-agent): Use '--no-autostart' when calling
gpg-connect-agent.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-25 17:06:05 +02:00
Justus Winter
71158d8d5f tests: Simplify test.
* tests/openpgp/quick-key-manipulation.scm: Avoid creating a temporary
home directory, just make the uids unique.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:24 +02:00
Justus Winter
ca9597f080 tests: Flush stdout in the fake pinentry.
* tests/openpgp/fake-pinentry.c (reply): Flush stdout.

Fixes-commit: 94504b3d5a
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:24 +02:00
Justus Winter
8c7c4faf3d common,w32: Fix setting environment variables on Windows.
* common/sysutils.c (gnupg_setenv): Also update the environment block
maintained by the C runtime.
(gnupg_unsetenv): Likewise.
* tests/gpgscm/ffi.c (do_setenv): Fix error handling.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:24 +02:00
Justus Winter
bf37916a23 tests,w32: Cope with Windows line endings.
* tests/openpgp/issue2015.scm: Rstrip line before comparison.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:23 +02:00
Justus Winter
2d794779e0 tests: Create and remove socket directories.
* tests/openpgp/defs.scm (start-agent): Move function here and create
the socket directory prior to starting the agent.
(stop-agent): Move function here and remove the socket directory.
* tests/openpgp/finish.scm: Adapt.
* tests/openpgp/setup.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:23 +02:00
Justus Winter
c2e713d9e2 gpgscm: Initialize nesting stack.
* tests/gpgscm/scheme.c (scheme_init_custom_alloc): Initialize nesting
stack.

Fixes-commit: f2249b7370
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-17 10:49:03 +02:00
Neal H. Walfield
0c56ad5a8d tests: Use shorter filenames.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-1.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-1.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-2.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-2.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-3.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-3.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-secret.gpg: Rename from
  this...
* tests/openpgp/tofu/cross-sigs/EC38277E-secret.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-1.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-1.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-2.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-2.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-3.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-3.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-4.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-4.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-secret.gpg: Rename from
  this...
* tests/openpgp/tofu/cross-sigs/871C2247-secret.gpg: .. to this.
* tests/openpgp/Makefile.am (TEST_FILES): Update accordingly.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Fixed-commit: d2d936fbe8
2016-10-13 21:45:44 +02:00
Neal H. Walfield
95d0f3e5ee g10: Be more careful when checking if a binding is signed by a UTK.
* g10/tofu.c (signed_by_utk): When checking if a key is signed by an
ultimately trusted key, only consider the signatures on the specified
user id.
* tests/openpgp/tofu.scm: Add test for the above.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-10-13 21:14:55 +02:00
Neal H. Walfield
d2d936fbe8 tests: Add test data to TEST_FILES.
* tests/openpgp/Makefile.am (TEST_FILES): Add new test data.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Fixes-commit: 4c0389f8eb
2016-10-13 14:26:53 +02:00
Neal H. Walfield
4c0389f8eb g10: Be more careful when checking cross signatures.
* g10/tofu.c (cross_sigs): When checking cross signatures, only
consider the signatures on the specified user id.
* tests/openpgp/tofu.scm: Add test for the above.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.gpg:
  New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-3.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-secret.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-4.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-secret.gpg: New file.
* tests/openpgp/tofu/cross-sigs/README: New file.

--
Signed-off-by: Neal H. Walfield
2016-10-13 12:44:59 +02:00
Neal H. Walfield
2282c3b761 tests: Remove support for deprecated functionality.
* tests/openpgp/tofu.scm: Don't remove tofu.d.  It's deprecated.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-10-13 12:30:12 +02:00
Justus Winter
cbbf0a7a8d tests: Rework test environment setup.
* tests/openpgp/setup.scm: Import one keyring at a time.  This works
around a yet to be investigated hang on Windows.  It is also much
prettier.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
1f76f8d8bc tests: Improve handling of Windows newlines.
* tests/gpgscm/lib.scm (string-split-newlines): New function.
* tests/openpgp/default-key.scm: Use new function.
* tests/openpgp/defs.scm: Likewise.
* tests/openpgp/export.scm: Likewise.
* tests/openpgp/import.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
11eac7eb2f gpgscm: Improve test of low-level functions.
* tests/gpgscm/t-child.c: Print large amounts of data.
* tests/gpgscm/t-child.scm: Test that this works.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
dff2660598 gpgscm: Improve path handling.
* tests/gpgscm/ffi.c (ffi_init): New Scheme variable '*win32*'.
* tests/gpgscm/tests.scm (canonical-path): Correctly handle paths with
drive letter on Windows.  Use 'path-join'.
(path-expand): Use 'path-join'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
07cfb3b27a gpgscm: Update callsite of 'gnupg_spawn_process'.
* tests/gpgscm/ffi.c (do_spawn_process): Adapt to the changes to
'gnupg_spawn_process'.

Fixes-commit: 44a32455
Fixes-commit: 96c7901e
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-06 14:13:18 +02:00
Justus Winter
4a232d23a8 build,w32: Unconditionally build tests.
* configure.ac (run_tests, RUN_TESTS, RUN_GPG_TESTS): Remove
variables.  They are misleadingly named, as they inhibit building the
tests.  There is no reason not to build the tests even when
cross-compiling, as they are only run if one does 'make check'.
* Makefile: Adapt accordingly.
* tests/Makefile.am: Adapt accordingly.  Avoid building 'asschk' on
Windows as it uses non-portable functions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-04 13:23:17 +02:00
Justus Winter
41b510f9c5 tests,w32: Do not expose 'glob' to gpgscm.
* tests/gpgscm/ffi.c (do_glob): Remove function.
(ffi_init): Likewise.
--
'glob' is not available on mingw, and portability is the whole point
of gpgscm.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-04 13:23:17 +02:00
Justus Winter
949e70115e tests,w32: Avoid using 'glob'.
* tests/openpgp/setup.scm: Avoid 'glob' which is not available on
mingw.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-04 13:23:17 +02:00
Neal H. Walfield
df5353b95e g10: When adding a user id, make sure the keyblock has been prepared.
* g10/keyedit.c (keyedit_quick_adduid): Call merge_keys_and_selfsig on
KEYBLOCK before adding the user id.
* tests/openpgp/quick-key-manipulation.scm: Make sure that the key
capabilities don't change when adding a user id.
(key-data): New function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2697
2016-09-22 21:32:31 +02:00
Justus Winter
7e0379a754 tests: Add documentation, make interactive debugging possible.
* tests/openpgp/README: Add documentation about debugging and
interfacing with GnuPG.
* tests/openpgp/run-tests.scm (test::run-sync): Hand stdin to the
child so that we can use a repl in the tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:55:02 +02:00
Justus Winter
c644962fcf tests: Drop the old shell-based tests.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:55:02 +02:00
Justus Winter
6c4c0e3ac2 tests: Port the quick key manipulation test to Scheme.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/quick-key-manipulation.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
49fae88fd1 tests: Remove list of tests from the test runner.
* tests/openpgp/run-tests.scm: Drop hardcoded list.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
988a04b98d tests: Reduce runtime of excessive test.
* tests/openpgp/conventional-mdc.scm: Use only two plaintexts when
iterating over all cipher algorithms.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
884e78efe1 tests: Refine the repl function.
* tests/gpgscm/repl.scm (repl): Add an argument 'environment'.
(interactive-repl): Add an optional argument 'environment'.
--

With this change, we can drop

  (interactive-repl (current-environment))

anywhere into the code and do some interactive debugging.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
Justus Winter
9a0659a65c tests: Implement interpreter shutdown using exceptions.
* tests/gpgscm/ffi.c (ffi_init): Rename 'exit' to '_exit'.
* tests/gpgscm/ffi.scm (*interpreter-exit*): New variable.
(throw): New function.
(exit): New function.
--
This allows a proper cleanup of resources.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
Justus Winter
58007e5259 tests: Correctly handle exceptions in resource handling macros.
* tests/gpgscm/tests.scm (letfd): Correctly release resources when an
exception is thrown.
(with-working-directory): Likewise.
(with-temporary-working-directory): Likewise.
(lettmp): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
Justus Winter
ab483eff9a tests: Refine exception handling.
* tests/gpgscm/init.scm (catch): Bind all arguments to '*error*' in
the error handler, update and fix comment.
(*error-hook*): Revert to original definition.
* tests/gpgscm/tests.scm (tr:do): Adapt accordingly.
* tests/openpgp/issue2419.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
Justus Winter
83a406b38a tests: Use descriptive temporary file names.
* tests/gpgscm/ffi.c (do_get_isotime): New function.
(ffi_init): Add parameter 'scriptname', bind new function and
scriptname.
* tests/gpgscm/ffi.h (ffi_init): Update prototype.
* tests/gpgscm/main.c (main): Hand in the script name.
* tests/gpgscm/tests.scm (mkdtemp): Use current time and script name
for the names of temporary directories.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
Werner Koch
293d265290
build: Distribute fake pinentries.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-19 10:03:31 +02:00
Werner Koch
3899041cd2
doc: Update license information.
* tests/fake-pinentries/COPYING: Rename to  ...
* COPYING.CC0: this.  Add a note on the scope of this license.
* COPYING.LIB: Add a note on the scope of this license.
* AUTHORS (License): Mention CC) license.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-19 10:03:26 +02:00
Werner Koch
47baeac50c
gpgscm: Fix gcrypt version check.
* tests/gpgscm/main.c (main): Check against required and not installed
version.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-09-19 08:41:51 +02:00
NIIBE Yutaka
7305d27f36 Fix comment and format.
* agent/protect-tool.c (main): Fix comment.
* doc/DETAILS (colon listings): Fix list.
* tests/openpgp/multisig.test: Fix comment.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-09-17 16:16:41 +09:00
Daniel Kahn Gillmor
0d67241e31 Fix more spelling
* NEWS, acinclude.m4, agent/command-ssh.c, agent/command.c,
  agent/gpg-agent.c, agent/keyformat.txt, agent/protect-tool.c,
  common/asshelp.c, common/b64enc.c, common/recsel.c, doc/DETAILS,
  doc/HACKING, doc/Notes, doc/TRANSLATE, doc/dirmngr.texi,
  doc/faq.org, doc/gpg-agent.texi, doc/gpg.texi, doc/gpgsm.texi,
  doc/instguide.texi, g10/armor.c, g10/gpg.c, g10/keyedit.c,
  g10/mainproc.c, g10/pkclist.c, g10/tofu.c, g13/sh-cmd.c,
  g13/sh-dmcrypt.c, kbx/keybox-init.c, m4/pkg.m4, sm/call-dirmngr.c,
  sm/gpgsm.c, tests/Makefile.am, tests/gpgscm/Manual.txt,
  tests/gpgscm/scheme.c, tests/openpgp/gpgv-forged-keyring.scm,
  tests/openpgp/multisig.test, tests/openpgp/verify.scm,
  tests/pkits/README, tools/applygnupgdefaults,
  tools/gpg-connect-agent.c, tools/mime-maker.c, tools/mime-parser.c:
  minor spelling cleanup.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-09-17 16:00:37 +09:00
Daniel Kahn Gillmor
3248182d1b tests/fake-pinentries: fake pinentries for downstream developers.
* tests/fake-pinentries/README.txt and
  tests/fake-pinentries/fake-pinentry.{sh,py,pl,php}}: New public
  domain (CC0) files to encourage better test suite practices from
  downstream developers.
* tests/fake-pinentries/COPYING (new): a copy of
  https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-09-15 10:28:23 +02:00
NIIBE Yutaka
68eb5fbd37 tests/gpgscm: Fix use of pointer.
* tests/gpgscm/scheme-private.h (struct scheme): Use (void *) for
alloc_seg.
* tests/gpgscm/scheme.c (alloc_cellseg): Use (void *) for cp.  Use
(void *) for coercion of address calculation.

--

In old C language, (char *) means an address.  In modern C, it's
specifically an address with alignment=1.  It's good to use (void *) for
an address, because newer compiler emits warnings.  Note: in this
particular case, it is just a warning and the code is safe against
invalid alignment, though.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-09-15 09:17:59 +09:00
Justus Winter
aa81e32df7 tests: Simplify tofu test.
* tests/openpgp/tofu.scm: Simplify now that we only have one db
format.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 11:07:48 +02:00
Neal H. Walfield
a937eef2d4 tests: Don't use --tofu-db-format.
* tests/openpgp/tofu.scm: Remove use of --tofu-db-format, which is
deprecated.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-09-07 11:02:51 +02:00
Justus Winter
f2249b7370 gpgscm: Fix detection of unbalanced parenthesis.
* tests/gpgscm/main.c (load): Print error message.
* tests/gpgscm/scheme.c (opexe_0): Correctly report nesting level when
loading files.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-06 16:46:31 +02:00
Justus Winter
213b3cf465 tests: Fix test.
* tests/openpgp/multisig.scm: Add missing parenthesis.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-06 16:46:31 +02:00
Justus Winter
46c4333c37 tests: Speed up the test suite.
* tests/openpgp/run-tests.scm (test::run-sync): Pass additional
arguments to the test.
(test::run-sync-quiet): Likewise.
(test::run-async): Likewise.
(run-tests-{parallel,sequential}-isolated): Create a tarball of the
gnupghome, then extract it for each test.
* tests/openpgp/setup.scm: Refactor into functions, add an interface
to tar-up the created environment, and untar it multiple times.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 17:26:50 +02:00
Justus Winter
65a7563edb tests: Update README.
* tests/openpgp/README: Update.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 14:05:19 +02:00
Justus Winter
059c79d8b4 tests: Pass flags to test driver.
* tests/openpgp/Makefile.am (xcheck): Pass flags to 'run-tests.scm'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 14:05:19 +02:00
Werner Koch
0a5a854510
gpg: Fix false negatives in Ed25519 signature verification.
* g10/pkglue.c (pk_verify): Fix Ed25519 signatrue values.
* tests/openpgp/verify.scm (msg_ed25519_rshort): New
(msg_ed25519_sshort): New.
("Checking that a valid Ed25519 signature is verified as such"): New.
--

About one out of 256 signature won't verify due to stripped zero
bytes.  See the source comment for details.

Reported-by: Andre Heinecke
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-25 16:18:00 +02:00
Werner Koch
19d12be3ce
gpg: New option --with-tofu-info.
* g10/gpg.c (oWithTofuInfo): New.
(opts): Add --with-tofu-info.
(main): Set opt.with_tofu_info.
* g10/options.h (struct opt): Add field WITH_TOFU_INFO.
* g10/tofu.c (show_statistics): Add optional arg OUTFP and enter
special mode if not NULL.  Change all callers.
(tofu_write_tfs_record): New.
* g10/keylist.c (list_keyblock_colon): Do not print the tofu policy as
part of the "uid" record.  Print a new "tfs" record if the new option
is set.
* tests/openpgp/tofu.scm (getpolicy): Change from UID to TFS record.
--

A separate option is required to avoid slowing down key listings.
Foer example the current code takes for a keylisting in tofu+pgp mode
17 seconds while it takes more than 5 minutes if the option is used.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-25 09:37:56 +02:00
Daniel Kahn Gillmor
61c2a1fa6d
Call log_set_prefix() with human-readable labels.
* agent/preset-passphrase.c, agent/protect-tool.c, dirmngr/dirmngr.c
* dirmngr/t-http.c, g10/gpg.c, g10/gpgv.c, g13/g13-syshelp.c
* g13/g13.c, kbx/kbxutil.c, scd/scdaemon.c, sm/gpgsm.c
* tests/gpgscm/main.c, tools/gpg-check-pattern.c
* tools/gpg-connect-agent.c, tools/gpgconf.c, tools/gpgtar.c
* tools/symcryptrun.c: Invoke log_set_prefix() with
human-readable labels.

--

Some invocations of log_set_prefix() were done with raw numeric values
instead of values that humans can understand.  Use symbolic
representations instead of numeric for better readability.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-12 12:16:19 +02:00
Justus Winter
a6acf1f6b3 tests: Fix distcheck.
* tests/openpgp/issue2417.scm: Copy configuration.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 17:57:32 +02:00
Werner Koch
5b59999ce0
gpg: Remove tofu database format "split".
* g10/options.h (struct opt): Remove field tofu_db_format.
* g10/gpg.h (server_control_s): Add fields tofu.batch_update_ref and
tofu.batch_update_started.
* g10/gpg.c (parse_tofu_db_format): Remove.
(main): Make option --tofu-db-format obsolete.
* g10/tofu.c: Major rework.  Remove the pretty complicated and slower
split format and with that all the caching.  Use the dbs struct
directly.  Move global vars for batch update into CTRL.  Change
calling conventions of some function to take CTRL or DBS pointers
instead of  the former low-level database pointer.
--

The split database format might have been nice for use with Unison but
it bypasses the concept of a relational database by doing parts of
this itself and also risking deadlocks.  Working with the Tofu
database for debugging or experiments is also not possible with parts
of the database logic implemented in gpg.

The Tofu support is quite new and we can assume that it is not in real
use now.  Thus we better remove that now so that we do not need to
maintain it for all future.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-10 16:55:04 +02:00
Justus Winter
a27410a251 g10: Fix opening of trust database.
* g10/tdbio.c (tdbio_set_dbname): This function explicitly checks for
the file size, but handled the case of a zero-sized file incorrectly
by returning success.  Fix this by initializing the database in that
case.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/issue2417.scm: New file.

GnuPG-bug-id: 2417
Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 16:50:29 +02:00
Justus Winter
194b1e979c tests: Fix distcheck.
* tests/openpgp/Makefile.am (EXTRA_DIST): Explicitly add setup and
teardown scripts now that they no longer are included in the list of
tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 11:59:42 +02:00
Justus Winter
d9240a3a46 tests: Improve temporary directory handling.
* tests/gpgscm/ffi.c (ffi_init): Rename 'mkdtemp'.
* tests/gpgscm/tests.scm (mkdtemp): New function that uses a sensible
location and template if no arguments are given.
(with-temporary-working-directory): Simplify accordingly.
(make-temporary-file): Likewise.
* tests/openpgp/run-tests.scm (run-tests-parallel-isolated): Likewise.
(run-tests-sequential-isolated): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 11:59:42 +02:00
Justus Winter
efe973dab7 gpgscm: Make the name of foreign functions more unique.
* tests/gpgscm/ffi-private.h (ffi_define_function_name): Add another
underscore.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 11:50:12 +02:00
Justus Winter
e13f1ea8ff tests: Run each test in a clean environment.
* tests/openpgp/Makefile.am (TESTS_ENVIRONMENT): Drop obsolete
variables, add 'srcdir', use absolute paths.
(TESTS): Rename to 'XTESTS' to avoid emitting the automake test
runner.  Drop 'setup.scm' and 'finish.scm'.
(xcheck): New target that runs 'run-tests.scm', our Scheme test suite
runner.  It will run each test in a clean environment, isolated from
the other tests.
(EXTRA_DIST): Adapt accordingly.
* tests/openpgp/README: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 09:42:00 +02:00
Justus Winter
b2b21580b6 tests: Make ssh test more robust.
* tests/openpgp/ssh.scm: Drop the 'MD5:' which was not printed by
previous ssh versions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 07:58:24 +02:00
NIIBE Yutaka
7dcad0d350 tests: Add openpgp/gpgv-forged-keyring.scm.
* tests/openpgp/gpgv-forged-keyring.scm: New.
* tests/openpgp/forged-keyring.gpg: New.
* tests/openpgp/Makefile.am (TESTS): Add gpgv-forged-keyring.scm.
* tests/openpgp/defs.scm (tools): Add GPGV.
(GPGV): New.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-08-08 13:24:02 +09:00
Werner Koch
0c2a745a2b
tests: Use gpgconf to set the ssh socket envvar.
* tests/openpgp/ssh.scm ("SSH_AUTH_SOCK"): Use gpgconf.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-04 13:04:28 +02:00
Justus Winter
05cb30052c tests: Update list of tests in Scheme test runner.
* tests/openpgp/run-tests.scm: Add missing tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-04 12:10:47 +02:00
Justus Winter
3566544d04 tests: Fix path to fake-pinentry.
* tests/openpgp/defs.scm: Correctly compute the path to fake-pinentry.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-04 12:09:52 +02:00
Daniel Kahn Gillmor
cd45cf782b Fix spelling and grammar.
* agent/learncard.c: s/coccured/occurred/
* doc/dirmngr.texi: s/ommitted/omitted/, s/orginally/originally/,
  s/reponses/responses/i
* doc/gpg-agent.texi, doc/dirmngr.texi, doc/gpg.texi: Fix "allows
  to" to more conventional english usage.
* doc/tools.texi, g10/gpgcommpose.c, tests/openpgp/armor.scm,
  tests/openpgp/armor.test: s/occured/occurred/
* tools/gpgsplit.c: s/calcualting/calculating/
* sm/server.c: s/formated/formatted/

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-03 16:54:01 +02:00
Justus Winter
c971ff0823 tests: Distribute standalone test runner.
* tests/openpgp/Makefile.am (EXTRA_DIST): Add missing file
'run-tests.scm'.

GnuPG-bug-id: 2431
Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-01 11:08:43 +02:00
Justus Winter
9e799b0e4f tests: Fix distcheck.
* tests/openpgp/Makefile.am (sample_msgs): New variable.
(EXTRA_DIST): Also ship the sample msgs.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 18:11:50 +02:00
Justus Winter
b2572b0c38 common: Fix iobuf_peek corner case.
Previously, iobuf_peek on a file smaller than 'buflen' would hang.

* common/iobuf.c (underflow): Generalize by adding a target parameter.
(iobuf_peek): Use this to prevent looping here.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/setup.scm (dearmor): Move function...
* tests/openpgp/defs.scm (dearmor): ... here.
* tests/openpgp/issue2419.scm: New file.
* tests/openpgp/samplemsgs/issue2419.asc: Likewise.

GnuPG-bug-id: 2419
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 18:37:37 +02:00
Justus Winter
046338b849 gpgscm: Do not shadow common function name in catch macro.
* tests/gpgscm/init.scm (catch): Do not shadow 'exit'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 18:37:10 +02:00
Justus Winter
66c0dab3c7 tests: Fix distcheck.
* tests/openpgp/Makefile.am (samplekeys): Add missing key.

Fixes-commit: 4ba11251
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 16:03:06 +02:00
Justus Winter
f17aecbcd9 gpgscm: Make the verbose setting more useful.
* tests/gpgscm/ffi.c (do_get_verbose): New function.
(do_set_verbose): Likewise.
(ffi_init): Turn *verbose* into a function, add *set-verbose!*.
* tests/gpgscm/tests.scm (call): Adapt accordingly.
(call-with-io): Dump output if *verbose* is high.
(pipe-do): Adapt accordingly.
* tests/openpgp/defs.scm: Set verbosity according to environment.
* tests/openpgp/run-tests.scm (test): Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 15:53:50 +02:00
Justus Winter
4ba11251af g10: Fix key import statistics.
'transfer_secret_keys' collects statistics on a subkey-basis, while
the other code does not.  This leads to inflated numbers when
importing secret keys.  E.g. 'count' is incremented by the main
parsing loop in 'import', and again in 'transfer_secret_keys', leading
to a total of 3 if one key with two secret subkeys is imported.

* g10/import.c (import_secret_one): Adjust to the fact that
'transfer_secret_keys' collects subkey statistics.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/issue2346.scm: New file.
* tests/openpgp/samplekeys/issue2346.gpg: Likewise.

GnuPG-bug-id: 2346
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-25 12:50:35 +02:00
Justus Winter
9ee23a715d gpgscm: Make function more general.
* tests/gpgscm/tests.scm (in-srcdir): Accept more path fragments.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-22 17:42:17 +02:00
Justus Winter
d9839c9d30 g10: Properly ignore legacy keys in the keyring cache.
* g10/keyring.c (keyring_rebuild_cache): Properly ignore legacy keys
in the keyring cache.
* tests/migrations/Makefile.am (TESTS): Add new test.
* tests/migrations/common.scm (GPG-no-batch): New variable.
(run-test): New function.
* tests/migrations/issue2276.scm: New file.
* tests/migrations/issue2276.tar.asc: Likewise.

GnuPG-bug-id: 2276
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-22 14:17:24 +02:00
Justus Winter
699c6c9f4b gpgscm: Make assert macro more accurate.
* tests/gpgscm/lib.scm (assert): Print the representation of the
failed expression.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-21 18:05:58 +02:00
Justus Winter
7207b2fe45 gpgscm: Make error message more useful.
* tests/gpgscm/scheme.c (opexe_0): Include names of missing function
parameters in the error message.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-21 18:04:57 +02:00
Justus Winter
270f7f7b8b agent: Add known keys to sshcontrol.
* agent/command-ssh.c (ssh_identity_register): Add a key to sshcontrol
even if it is already in the private key store.
* tests/openpgp/ssh.scm: Test this.

GnuPG-bug-id: 2316
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-19 16:51:16 +02:00
Justus Winter
d7a405de83 tests: Add test for ssh support.
* tests/gpgscm/tests.scm (path-expand): New function.
* tests/openpgp/Makefile.am (TESTS): Add new test.
(sample_keys): Add new keys.
(CLEANFILES): Clean ssh socket and control file.
* tests/openpgp/fake-pinentry.c (main): Add a default passphrase.
* tests/openpgp/gpg-agent.conf.tmpl: Enable ssh support.
* tests/openpgp/samplekeys/ssh-dsa.key: New file.
* tests/openpgp/samplekeys/ssh-ecdsa.key: Likewise.
* tests/openpgp/samplekeys/ssh-ed25519.key: Likewise.
* tests/openpgp/samplekeys/ssh-rsa.key: Likewise.
* tests/openpgp/ssh.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-19 16:38:21 +02:00
Justus Winter
f474249366 agent: Fix passphrase cache lookups.
CACHE_MODE_ANY is supposed to match any cache mode except
CACHE_MODE_IGNORE, but the code used '==' to compare cache modes.

* agent/cache.c (cache_mode_equal): New function.
(agent_set_cache): Use the new function to compare cache modes.
(agent_get_cache): Likewise.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/issue2015.scm: New file.

GnuPG-bug-id: 2015
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-18 12:51:38 +02:00
Justus Winter
7f4dd24b88 build: Always build gpgtar.
We use gpgtar to unpack test data, hence we always build it.  If the
user opts out, we simply don't install it.

* configure.ac: Add comment.
* tests/migrations/Makefile.am (required_pgms): Make sure gpgtar is
built.
* tools/Makefile.am: Always build gpgtar, but do not install it if the
user used '--disable-gpgtar'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 17:24:49 +02:00
Justus Winter
c49c43d7e4 gpgscm: Fix linking.
* tests/gpgscm/Makefile.am: Add -lintl.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 12:35:15 +02:00
Justus Winter
12a887050a tests: Check for gpgtar.
* tests/migrations/extended-pkf.scm: Skip test if gpgtar is not built.
* tests/migrations/from-classic.scm: Likewise.
* tests/openpgp/gpgtar.scm: Fix check for gpgtar.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 11:59:57 +02:00
Werner Koch
fb14bf0a95
gpgscm: Use kludge to avoid improper use of ffi_schemify_name.
* tests/gpgscm/ffi.c (ffi_schemify_name): Use xstrdup instead of
strdup for now.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-14 10:52:03 +02:00
Werner Koch
5811b5c685
tests: 3 more sample messages
--
2016-07-13 18:20:06 +02:00
Justus Winter
2f61aa0ff1 gpgscm: Capture output of spawned processes.
* tests/gpgscm/tests.scm (call-check): Capture stdout and stderr, and
return stdout if the child exited successfully, or include stderr in
the error.
* tests/openpgp/version.scm: Demonstrate this by checking the stdout.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-07 16:18:10 +02:00
Werner Koch
a479804c86
gpg: New options --recipient-file and --hidden-recipient-file.
* g10/gpg.c (oRecipientFile, oHiddenRecipientFile): New.
(opts): Add options --recipient-file and --hidden-recipient-file.
(main): Implement them.  Also remove duplicate code from similar
options.
* g10/keydb.h (PK_LIST_FROM_FILE): New.
(PK_LIST_SHIFT): Bump up.
* g10/pkclist.c (expand_group): Take care of PK_LIST_FROM_FILE.
(find_and_check_key): Add and implement arg FROM_FILE.
(build_pk_list): Pass new value for new arg.
* g10/getkey.c (get_pubkey_fromfile): New.
* g10/gpgv.c (read_key_from_file): New stub.
* g10/test-stubs.c (read_key_from_file): New stub.
* g10/server.c (cmd_recipient): Add flag --file.
* g10/import.c (read_key_from_file): New.

* tests/openpgp/defs.scm (key-file1): New.
(key-file2): New.
* tests/openpgp/setup.scm: Add their private keys and import the
key-file1.
* tests/openpgp/encrypt.scm: Add new test.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-06 15:35:19 +02:00
Justus Winter
8270580a5a tests: Honor environment variable 'TMP'.
This fixes problems with long socket names, e.g. when doing distcheck.

* tests/gpgscm/tests.scm (path-join): New function.
(with-temporary-working-directory): Honor 'TMP'.
(make-temporary-file): Likewise.
* tests/migrations/Makefile.am (TMP): Default to '/tmp'.
(TESTS_ENVIRONMENT): Set 'TMP'.
* tests/openpgp/Makefile.am (TMP): Default to '/tmp'.
(TESTS_ENVIRONMENT): Set 'TMP'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 16:25:21 +02:00
Justus Winter
f26fe4f73e gpgscm: Improve robustness and compatibility.
* tests/gpgscm/ffi.c (do_getenv): Avoid gccism.
(do_mkdtemp): Handle errors.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 16:24:13 +02:00
Justus Winter
b70d08827d tests/migrations: Fix distcheck.
* tests/migrations/Makefile.am (TESTS): Rename test.
(TEST_FILES): Update list.
(EXTRA_DIST): Add common.scm.
* tests/migrations/common.scm (GPGTAR): New variable.
(dearmor): Rename and untar archive.
* tests/migrations/extended-private-key-format.scm: Rename.
(setup): Update.
* tests/migrations/extended-pkf.tar.asc: New file.
* tests/migrations/extended-private-key-format.gpghome: Delete.
* tests/migrations/from-classic.gpghome: Likewise.
* tests/migrations/from-classic.scm (setup): Update.
* tests/migrations/from-classic.tar.asc: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 15:25:21 +02:00
Justus Winter
0b8a335879 tools/gpgtar: Provide --create and --extract.
* tools/gpgtar.c (cmd_and_opt_values): New values.
(opts): New actions.
(parse_arguments): Handle new actions.
* tests/openpgp/gpgtar.scm: Test new interface.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 15:18:30 +02:00
Justus Winter
5003caa8fd gpgscm: Fix reallocating string ports.
* tests/gpgscm/scheme.c (realloc_port_string): Use memcpy because
Scheme strings may contain 0s.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 15:31:37 +02:00
Justus Winter
599ad21104 gpgscm: Free memory backing string ports.
* tests/gpgscm/scheme.c (finalize_cell): Free memory backing string
ports.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 15:31:37 +02:00
Justus Winter
d4ede89981 gpgscm: Use the allocator from libgcrypt.
* tests/gpgscm/main.c (main): Use the allocator from libgcrypt.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 15:31:37 +02:00
Daniel Kahn Gillmor
55d112eeb0
g10: Implement gpg --quick-revuid
* g10/revoke.c (get_default_uid_revocation_reason): New.
* g10/keyedit.c (menu_revuid): Break out creation of uid revocation
into new function core_revuid.
* g10/keyedit.c (keyedit_quick_revuid): New. Selects key and
uid, invokes core_revuid.
* g10/gpg.c (main): Handle --quick-revuid argument.
* doc/gpg.texi: Document --quick-revuid.

--

This functionality is a counterpart to --quick-adduid, and will be
useful for projects that depend programmatically on gpg to revoke user
IDs (one such example is "monkeysphere-host revoke-servicename").

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

- Minor re-indentation work.
- Changed a "0 == memcmp" to "!memcmp"
- Removed tests/openpgp/quick-key-manipulation.test from the
  Makefile.  This test needs to be converted to gpgscm.
- Removed example from whats-new-in-2.1.txt because that is generated.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-30 11:45:13 +02:00
Justus Winter
9c67958c47 gpgscm: Fix memory leaks.
* tests/gpgscm/ffi-private.h (ffi_schemify_name): Fix prototype.
(ffi_define_function_name): Free schemified name.
(ffi_define_function): Likewise.
(ffi_define_constant): Likewise.
(ffi_define_variable_pointer): Likewise.
* tests/gpgscm/ffi.c (do_wait_processes): Free arrays.
(ffi_schemify_name): Fix type.
* tests/gpgscm/main.c (main): Free 'sc'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 18:21:50 +02:00
Justus Winter
6cb2be91a7 gpgscm: Free file names.
* tests/gpgscm/scheme.c (scheme_load_named_file): Free file name.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 18:21:50 +02:00
Justus Winter
56cebdc30c gpgscm: Fix buffer overflow.
* tests/gpgscm/scheme.c (store_string): Avoid writing past allocated
buffer.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 18:21:50 +02:00
Werner Koch
0fc80208db
Add another collection of sample keys
--
2016-06-28 15:53:59 +02:00
Justus Winter
e584d6468a tests/openpgp: Fake the system time for the tofu test.
The keys in the tofu test are set to expire on 2016-09-17.  Fake the
system time for this test.

This commit includes changes to the old test as well, for those who
need to backport it.

* tests/openpgp/gpg-agent.conf.tmpl: Drop trailing newlines.
* tests/openpgp/tofu.scm: Fake system time.
* tests/openpgp/tofu.test: Likewise.

GnuPG-bug-id: 2393
Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 17:42:30 +02:00
Justus Winter
145910afc0 gpgscm: Handle exceptions in the transformation monad.
* tests/gpgscm/tests.scm (pipe:do): Raise errors.
(tr:spawn): Catch and return errors.
(tr:call-with-content): Likewise.
(tr:{open,write-to,pipe-do,assert-identity,assert-weak-identity}):
Adapt.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 17:18:13 +02:00
Justus Winter
1e822654c1 tests/openpgp: Improve tests.
* tests/openpgp/multisig.scm: Simplify test.
* tests/openpgp/setup.scm (dearmor): Use pipe.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 17:14:07 +02:00
Justus Winter
332fa86982 gpgscm: Add types for special objects.
* tests/gpgscm/scheme.c (enum scheme_types): Add types for boolean,
nil, eof, and the sink object.
(type_to_string): Handle new types.
(scheme_init_custom_alloc): Give special objects a type.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 16:14:10 +02:00
Justus Winter
e6e56adf20 gpgscm: Fix Scheme initialization.
This potentially causes a crash if the garbage collector marks an eof
object.

* tests/gpgscm/scheme.c (scheme_init_custom_alloc): Initialize
'EOF_OBJ'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 14:18:20 +02:00
Justus Winter
a4ff2d99d0 gpgscm: Fix manual.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 14:18:06 +02:00
Werner Koch
679aadb03e
tests: Add four more sample messages for the two new keys to the repo.
--

These are uncompressed signed messages
2016-06-23 09:38:12 +02:00
Werner Koch
da63f15d98
tests: Add a set of sample messages for the two new keys to the repo.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-22 11:25:22 +02:00
Werner Koch
ea78b37f0d
tests: Add two more sample keys for OpenPGP.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-22 11:25:22 +02:00
Justus Winter
f548383d9a tests/migrations: Convert to Scheme and re-enable.
* configure.ac: Re-enable.
* tests/Makefile.am: Likewise.
* tests/migrations/Makefile.am (TESTS): Use Scheme tests.
* tests/migrations/common.scm: New file.
* tests/migrations/extended-private-key-format.scm: Likewise.
* tests/migrations/from-classic.scm: Likewise.
* tests/migrations/extended-private-key-format.test: Drop file.
* tests/migrations/from-classic.test: Drop file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 18:15:30 +02:00
Justus Winter
c5e0ca5a59 gpgscm: Add more file handling functions.
* tests/gpgscm/ffi.c (do_glob): New function.
(ffi_init): Define new function.
* tests/gpgscm/tests.scm (basename-suffix): New function.x

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 18:15:30 +02:00
Justus Winter
0340fcdac8 tests/openpgp: Port the remaining tests to Scheme.
* tests/openpgp/Makefile.am (TESTS): Add new tests.
* tests/openpgp/defs.scm (gpg-with-colons): New function.
(get-config): Use new function.
* tests/openpgp/export.scm: New file.
* tests/openpgp/tofu.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 16:22:11 +02:00
Justus Winter
65081c31e7 gpgscm: Improve test framework.
* tests/gpgscm/lib.scm (echo): Move...
* tests/gpgscm/tests.scm (echo): ... here.
(info, error, skip): And use echo here.
(file-exists?): New function.
(tr:spawn): Check that source exists and if the sink has been created.
(tr:call-with-content): Hand in optional arguments.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 16:22:03 +02:00
Justus Winter
5fbbc4b334 gpgscm: Use native string searching functions.
* tests/gpgscm/ffi-private.h: Handle character arguments.
* tests/gpgscm/ffi.c (do_string_index): New function.
(do_string_rindex): Likewise.
(do_string_contains): Likewise.
(ffi_init): Define new functions.
* tests/gpgscm/ffi.scm (ffi-define): New macro.
* tests/gpgscm/lib.scm (string-index): Use native function,
demonstrate behavior.
(string-rindex): Likewise.
(string-contains?): Likewise.
Demonstrate behavior of various other functions.
(read-all): Rework so that it can handle large files.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 16:18:32 +02:00
Justus Winter
d99949fc8c gpgscm: Improve error reporting.
* tests/gpgscm/scheme.c (type_to_string): New function.
(Eval_Cycle): Include actual type in error message.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 16:18:32 +02:00