Using the process group (now that we've got one that's exclusive
to the testrunner) allows us to also clean up children that have
been detached from their original parent (and now have PID 1 as
their parent).
The process already has some existing file descriptors open, e.g. stdin,
stdout and stderr, so we can't assume we can open as many files as the
RLIMIT_NOFILE tells us.
A different approach to this is to not use a static limit of maximum
open files, but instead react to EMFILE when trying to open new files,
and then close existing files, but as a stop gap we compute a more
accurate static value for the maximum open files.
Fixes#35
Relying on the process group to figure out which processes to treat
as children and grandchildren of the test run was not correct, as
the testrunner didn't ensure it was creating a new process group.
When running inside 'make check' the process group was actually that
of make, not testrunner.sh.
Since setpgid is not universally available, we iterate the process
tree via ps, and kill the children recursively.
getgrnam is not thread-safe on Linux (but is on macOS). To ensure
we don't call it from two threads at the same time we move its use
inside a lambda that initializes a local static. This is fine, as
we don't expect the 'nogroup' gid to change.
We now reflect the user who mounted the sparsebundle as the owner of
the resulting .dmg file, and try to reflect the state of allow_other
and allow_root through the file permission bits.
These are just informative. The real access control happens in FUSE
based on the allow_other/allow_root options (unless user also passes
the default_permissions option, in which case the permission bits
will also be checked).
Fixes issue #15
The move from off_t to size_t in 90c81b1776 was misguided. Although
it semantically makes sense to use an unsigned datatype for file sizes,
the size_t data type is only 32-bit wide on 32-bit systems, so the move
broke reading of large sparsebundles on 32-bit systems, since we could
no longer represent the file size.
We now use uint64_t explicitly, which is both unsigned, and wide enough
to represent all the files we want.
The uintmax_t datatype has been demoted to be used only for printing,
to make it clearer what width is actually expected and used in the code.
Fixes#26
Tests are run using 'make check', and can be combined with the
existing Makefile targets, e.g. 'make check all' to run checks
on all available platforms.
Pass DEBUG=1 for additional test output.