tests/pkd: support -L, --temp-dir=<mkdtemp-template>

Teach `pkd` a new flag `-L, --temp-dir=<mkdtemp-template>` to enable
behavior whereby `pkd` creates a new temporary directory and uses it
for a workspace while running.

The original design of `pkd` assumed that it could freely use the
current working directory from wherever it happened to be invoked.
But, this could pose a problem when multiple `pkd` instances are run
in parallel from the same working directory, due to the usage of
various temporary files within that directory.

To avoid the problem of multiple `pkd` instances interfering with
each other, expose a `-L` flag for optionally specifying a `mkdtemp`
template string such that a temporary scratch space is used instead.

Testing notes:
 - I ran handfuls of iterations locally using the new flag
   and observed `pkd` is indeed using scratch space as desired.

Resolves https://gitlab.com/libssh/libssh-mirror/-/issues/143.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Jon Simons
2022-11-12 17:06:31 -05:00
committed by Jakub Jelen
parent aa206cbfe5
commit b610757e63
2 changed files with 101 additions and 4 deletions

View File

@@ -30,6 +30,8 @@ struct pkd_daemon_args {
uint64_t rekey_data_limit;
int original_dir_fd;
struct {
int list;
@@ -44,6 +46,10 @@ struct pkd_daemon_args {
struct {
char *mkdtemp_str;
} socket_wrapper;
struct {
char *mkdtemp_str;
} temp_dir;
} opts;
};