* tests/openpgp/defs.scm (have-opt-always-trust): Execute in empty
ephemeral home directory. This prevents gpg from picking up the
configuration from the current gnupghome (if any).
* tests/migrations/common.scm (untar-armored): Likewise.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/defs.scm (with-home-directory,
with-ephemeral-home-directory): Move...
* tests/gpgscm/gnupg.scm: ... to this new file.
* tests/gpgscm/main.c (main): Load the new file.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_0): Consider 'op', not 'sc->op'. The
former is the opcode we are currently executing.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/main.c (load): Try to mmap the script.
* tests/gpgscm/scheme.c (scheme_load_memory): New function, a
generalization of 'scheme_load_string'.
* tests/gpgscm/scheme.h (scheme_load_memory): New prototype.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (op_code_info): Fix type, add forward
declaration.
(check_arguments): New function.
(Eval_cycle): Use the new function.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/opdefines.h: Make tags mandatory.
* tests/gpgscm/scheme.c: Likewise.
* tests/gpgscm/scheme.h: Likewise.
--
Tags provide a constant-time lookup mechanism for almost every object.
This is useful for the interpreter itself, and the code for tags is
tiny.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_6): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_5): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_4): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_3): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_2): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_1): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--
Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file.
* tests/gpgscm/scheme-private.h (struct cell): Move number to the top
of the union so that we can initialize it.
(struct scheme): Remove 'integer_segment'.
* tests/gpgscm/scheme.c (initialize_small_integers): Remove function.
(small_integers): New variable.
(MAX_SMALL_INTEGER): Compute.
(mk_small_integer): Adapt.
(mark): Avoid marking objects already marked. This allows us to run
the algorithm over objects in the rodata section if they are already
marked.
(scheme_init_custom_alloc): Remove initialization.
(scheme_deinit): Remove deallocation.
* tests/gpgscm/small-integers.h: New file.
--
Allocate small integers from a fixed pool in the rodata section. This
spares us the initialization, and deduplicates integers across
different processes. It also makes the integers immutable, increasing
memory safety.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme-private.h (struct scheme): Make 'vptr' const.
* tests/gpgscm/scheme.c (num_zero): Statically initialize and turn
into constant.
(num_one): Likewise.
(charnames): Change type so that it can be stored in rodata.
(is_ascii_name): Adapt slightly.
(assign_proc): Make argument const char *.
(op_code_info): Make some fields const char *.
(tests): Make const.
(dispatch_table): Make const. At least it can be made read-only after
relocation.
(Eval_Cycle): Adapt slightly.
(vtbl): Make const.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme-private.h (struct scheme): Remove fixed-size
arrays for cell segments, replace them with a pointer to the new
'struct cell_segment' instead.
* tests/gpgscm/scheme.c (struct cell_segment): New definition.
(_alloc_cellseg): Allocate the header within the segment, return a
pointer to the header.
(_dealloc_cellseg): New function.
(alloc_cellseg): Insert the segments into a list.
(_get_cell): Allocate a new segment if less than a quarter of
CELL_SIGSIZE is recovered during garbage collection.
(initialize_small_integers): Adapt callsite.
(gc): Walk the list of segments.
(scheme_init_custom_alloc): Remove initialization of removed field.
(scheme_deinit): Adapt deallocation.
--
Previously the number of cells that could be allocated was a
compile-time limit. Remove this limit.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme-private.h (struct cell): Use uintptr_t for
'_flags'. This way, '_flags' has the size of a machine word.
--
The compact vector representation introduced in 49e2ae65 requires that
we can tell apart pointers and type flags. This did not work on
64-bit big-endian architectures.
Fixes a crash on 64-bit big-endian architectures.
Hat-tip-to: gniibe
Fixes-commit: 49e2ae65e8
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (opexe_5): Do not modify the integer in-place
while printing an vector. Integer objects may be shared, so they must
not be mutated.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (get_vector_object): Initialize unused slots
at the end of vectors.
--
They should not be used for anything, but let's just initialize them
to something benign to be sure.
GnuPG-bug-id: 3014
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/Makefile.am (SUBDIRS): Add 'pkits' again. Simply dropping it
makes 'make distcheck' unhappy.
* tests/pkits/Makefile.am (TESTS): Remove all tests.
--
Disable the 'pkits' tests in a way that keeps 'make distcheck' happy.
To run tests individually, do
make -Ctests/pkits check TESTS=some-test
GnuPG-bug-id: 3067
Fixes-commit: af1c1a57e4
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/Makefile.am (SUBDIRS): Drop 'pkits'.
* tests/pkits/common.sh: Fix locating 'PKITS_data.tar.bz2'.
* tests/pkits/inittests: Likewise.
--
These tests are unmaintained and broken, and were previously only run
when doing in-tree builds, hence nobody noticed that they were badly
broken.
GnuPG-bug-id: 3067
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/4gb-packet.scm: Skip if we do not have BZIP2.
* tests/openpgp/defs.scm (have-compression-algo?): New function.
GnuPG-bug-id: 3028
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/defs.scm (with-ephemeral-home-directory): Set
GNUPGHOME and cwd to the ephemeral directory before calling the setup
function.
GnuPG-bug-id: 3047
Fixes-commit: 32b75fb774
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/defs.scm (with-ephemeral-home-directory): Create
configuration files when we enter the context.
* tests/openpgp/setup.scm: Do not use an ephemeral home directory.
Tests should always use the cwd.
* tests/gpgsm/setup.scm: Likewise.
* tests/gpgsm/export.scm: Add explicit constructor function.
* tests/openpgp/decrypt-session-key.scm: Likewise.
* tests/openpgp/decrypt-unwrap-verify.scm: Likewise.
--
Previously, ephemeral homedirectories lacked a configuration, hence
GnuPG tried to start backend daemons using their installed locations.
Fix this by explicitly creating a suitable configuration.
GnuPG-bug-id: 3047
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (copy_value): New function.
(mk_tagged_value): Use new function.
(opexe_4): Likewise for OP_SAVE_FORCED.
--
Occasionally, we need to copy a value from one location in the storage
to another. Scheme objects are fine. Some primitive objects,
however, require finalization, usually to free resources.
For these values, we either make a copy or acquire a reference.
Fixes e.g. a double free if a delayed expression evaluating to a
string is forced.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (procnum): Procedures always have an integer
number, so we can safely use the cheaper 'ivalue_unchecked'.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/defs.scm (stop-agent): Swap order of actions. Kill
all daemons using gpgconf.
* tools/gpgconf.c (main) <aRemoveSocketDir>: Try to remove known
socketfails on rmdir failure. Do no fail for ENONET.
--
Killing all daemons is not really required but it does not harm to be
prepared for the future.
Signed-off-by: Werner Koch <wk@gnupg.org>
* tests/gpgscm/tests.scm (mkdtemp-autoremove): New function that
cleans up at interpreter shutdown.
(run-tests-parallel): Use the new function.
(run-tests-sequential): Likewise.
(make-environment-cache): Execute setup with an temporary working
directory.
--
Make sure to remove all resources created in the filesystem even if
the test runner is interrupted. Make sure to remove anything that the
setup script creates.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/ffi.c (do_get_temp_path): New function.
(ffi_init): Make function available.
* tests/gpgscm/tests.scm (mkdtemp): Use the new function.
Fixes-commit: 06f1f163e9
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/tests.scm (mkdtemp): Create temporary directories in
'/tmp' on UNIX, or in '%Temp' on Windows.
* tests/migrations/common.scm (run-test): Turn error into a warning.
* tests/openpgp/defs.scm (start-agent): Likewise.
--
This fixes the problem of GnuPG components being unable to communicate
because of too long GnuPG home directories in important build
environments like the Debian build servers despite the use of socket
directories.
This reverts d75d20909d.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/migrations/common.scm (run-test): Turn warning into an error.
* tests/openpgp/defs.scm (start-agent): Likewise.
--
We use separate directories to create the sockets in so that the
absolute path to the every socket fits into sun_path.
Fixes-commit: 7e19786a5d
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (oblist_add_by_name): We now always get a
slot. Simplify accordingly.
(oblist_find_by_name): Always return the slot.
(vector_elem_slot): New function.
(new_slot_spec_in_env): We now always get a slot. Remove parameter
'env'. Simplify accordingly.
(find_slot_spec_in_env): Always return a slot.
(new_slot_in_env): Adapt callsite.
(opexe_0): Likewise.
(opexe_1): Likewise.
(scheme_define): Likewise.
--
Now that the ill-devised immediate values framework is gone, there is
no need to tag the pointers in vectors anymore. Therefore, we can
always return a pointer to the slot in the hash table lookup
functions.
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/gpgscm/scheme.c (IMMEDIATE_TAG): Remove macro.
(is_immediate): Likewise.
(set_immediate): Likewise.
(clr_immediate): Likewise.
(enum scheme_types): Set the LSB in every value.
(fill_vector): Adapt.
(vector_elem): Likewise.
(set_vector_elem): Likewise.
(mark): Likewise.
(gc): Test for the LSB to tell typeflags apart from pointers stored in
the same memory location.
--
Supporting immediate values would require invasive changes to the
interpreter and is likely not worth the trouble. On the other hand,
tagging pointers in vectors complicated the hash table implementation
needlessly. Therefore, I remove this again.
This fixes a crash on big endian architectures.
GnuPG-bug-id: 2996
Signed-off-by: Justus Winter <justus@g10code.com>
* tests/openpgp/defs.scm (gpg-conf'): Explicitly pass the build prefix
to gpgconf here...
(gpg-components): ... instead of only here.
--
Previously, gpgconf was not invoked with '--build-prefix' when
changing the configuration. This made tests using this facility fail
(e.g. the TOFU test). This only affected release builds, because in
development builds gpgconf picks up the build prefix from the
environment.
GnuPG-bug-id: 2979
Signed-off-by: Justus Winter <justus@g10code.com>