diff options
author | Werner Koch <[email protected]> | 2016-12-20 17:38:12 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-12-20 17:39:30 +0000 |
commit | 6204f8104fea42d706a68e77e2dc0bca4704bddc (patch) | |
tree | 1a31e26968f9e212299575c6ed11adff819c83e2 | |
parent | tests: Add test suite for gpgsm. (diff) | |
download | gnupg-6204f8104fea42d706a68e77e2dc0bca4704bddc.tar.gz gnupg-6204f8104fea42d706a68e77e2dc0bca4704bddc.zip |
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 <[email protected]>
-rw-r--r-- | common/t-exectool.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/common/t-exectool.c b/common/t-exectool.c index 8b6ee6ae7..9cea2d1be 100644 --- a/common/t-exectool.c +++ b/common/t-exectool.c @@ -39,21 +39,27 @@ static void test_executing_true (void) { 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; size_t len; - if (access (argv[0], X_OK)) + if (access (pgmname, X_OK)) { - fprintf (stderr, "skipping test: %s not executable: %s", - argv[0], strerror (errno)); - return; + if (access (alt_pgmname, X_OK)) + { + fprintf (stderr, "skipping test: %s not executable: %s\n", + pgmname, strerror (errno)); + return; + } + pgmname = alt_pgmname; } 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) fail ("gnupg_exec_tool", err); @@ -66,24 +72,31 @@ static void test_executing_false (void) { 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; size_t len; - if (access (argv[0], X_OK)) + if (access (pgmname, X_OK)) { - fprintf (stderr, "skipping test: %s not executable: %s", - argv[0], strerror (errno)); - return; + if (access (alt_pgmname, X_OK)) + { + fprintf (stderr, "skipping test: %s not executable: %s\n", + pgmname, strerror (errno)); + return; + } + pgmname = alt_pgmname; } 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); } + static void test_executing_cat (const char *vector) { @@ -94,7 +107,7 @@ test_executing_cat (const char *vector) 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)); return; } @@ -131,7 +144,7 @@ test_catting_cat (void) 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)); return; } @@ -139,7 +152,7 @@ test_catting_cat (void) in = es_fopen (argv[1], "r"); 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)); return; } @@ -147,7 +160,7 @@ test_catting_cat (void) err = es_fseek (in, 0L, SEEK_END); 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)); return; } |