1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

tests: Avoid skipping exectool tests.

* common/t-exectool.c (test_executing_true): Try also /usr/bin/true.
(test_executing_false): Try also /usr/bin/false.
--

Reported-by: Nelson H. F. Beebe
  I then ran a test on all our test lab systems, and found that
  /bin/false is missing on DragonFlyBSD, FreeBSD, GhostBSD,
  HardenedBSD, Mac OS X, MidnightBSD, Minix, one version of MirBSD,
  NetBSD, OpenBSD, PacBSD, PCBSD, and TrueOS.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-12-20 18:38:12 +01:00
parent 36c1413928
commit 6204f8104f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -39,21 +39,27 @@ static void
test_executing_true (void) test_executing_true (void)
{ {
gpg_error_t err; gpg_error_t err;
const char *argv[] = { "/bin/true", NULL }; const char *pgmname = "/bin/true";
const char *alt_pgmname = "/usr/bin/true";
const char *argv[] = { NULL, NULL };
char *result; char *result;
size_t len; size_t len;
if (access (argv[0], X_OK)) if (access (pgmname, X_OK))
{ {
fprintf (stderr, "skipping test: %s not executable: %s", if (access (alt_pgmname, X_OK))
argv[0], strerror (errno)); {
fprintf (stderr, "skipping test: %s not executable: %s\n",
pgmname, strerror (errno));
return; return;
} }
pgmname = alt_pgmname;
}
if (verbose) if (verbose)
fprintf (stderr, "Executing %s...\n", argv[0]); fprintf (stderr, "Executing %s...\n", pgmname);
err = gnupg_exec_tool (argv[0], &argv[1], "", &result, &len); err = gnupg_exec_tool (pgmname, argv, "", &result, &len);
if (err) if (err)
fail ("gnupg_exec_tool", err); fail ("gnupg_exec_tool", err);
@ -66,24 +72,31 @@ static void
test_executing_false (void) test_executing_false (void)
{ {
gpg_error_t err; gpg_error_t err;
const char *argv[] = { "/bin/false", NULL }; const char *pgmname = "/bin/false";
const char *alt_pgmname = "/usr/bin/false";
const char *argv[] = { NULL, NULL };
char *result; char *result;
size_t len; size_t len;
if (access (argv[0], X_OK)) if (access (pgmname, X_OK))
{ {
fprintf (stderr, "skipping test: %s not executable: %s", if (access (alt_pgmname, X_OK))
argv[0], strerror (errno)); {
fprintf (stderr, "skipping test: %s not executable: %s\n",
pgmname, strerror (errno));
return; return;
} }
pgmname = alt_pgmname;
}
if (verbose) if (verbose)
fprintf (stderr, "Executing %s...\n", argv[0]); fprintf (stderr, "Executing %s...\n", pgmname);
err = gnupg_exec_tool (argv[0], &argv[1], "", &result, &len); err = gnupg_exec_tool (pgmname, argv, "", &result, &len);
assert (err == GPG_ERR_GENERAL); assert (err == GPG_ERR_GENERAL);
} }
static void static void
test_executing_cat (const char *vector) test_executing_cat (const char *vector)
{ {
@ -94,7 +107,7 @@ test_executing_cat (const char *vector)
if (access (argv[0], X_OK)) if (access (argv[0], X_OK))
{ {
fprintf (stderr, "skipping test: %s not executable: %s", fprintf (stderr, "skipping test: %s not executable: %s\n",
argv[0], strerror (errno)); argv[0], strerror (errno));
return; return;
} }
@ -131,7 +144,7 @@ test_catting_cat (void)
if (access (argv[0], X_OK)) if (access (argv[0], X_OK))
{ {
fprintf (stderr, "skipping test: %s not executable: %s", fprintf (stderr, "skipping test: %s not executable: %s\n",
argv[0], strerror (errno)); argv[0], strerror (errno));
return; return;
} }
@ -139,7 +152,7 @@ test_catting_cat (void)
in = es_fopen (argv[1], "r"); in = es_fopen (argv[1], "r");
if (in == NULL) if (in == NULL)
{ {
fprintf (stderr, "skipping test: could not open %s: %s", fprintf (stderr, "skipping test: could not open %s: %s\n",
argv[1], strerror (errno)); argv[1], strerror (errno));
return; return;
} }
@ -147,7 +160,7 @@ test_catting_cat (void)
err = es_fseek (in, 0L, SEEK_END); err = es_fseek (in, 0L, SEEK_END);
if (err) if (err)
{ {
fprintf (stderr, "skipping test: could not seek in %s: %s", fprintf (stderr, "skipping test: could not seek in %s: %s\n",
argv[1], gpg_strerror (err)); argv[1], gpg_strerror (err));
return; return;
} }