diff options
Diffstat (limited to 'tests/openpgp')
-rw-r--r-- | tests/openpgp/all-tests.scm | 18 | ||||
-rw-r--r-- | tests/openpgp/defs.scm | 3 | ||||
-rw-r--r-- | tests/openpgp/fake-pinentry.c | 75 | ||||
-rwxr-xr-x | tests/openpgp/issue2941.scm | 2 | ||||
-rw-r--r-- | tests/openpgp/run-tests.scm | 6 |
5 files changed, 57 insertions, 47 deletions
diff --git a/tests/openpgp/all-tests.scm b/tests/openpgp/all-tests.scm index 98a8a6507..e40e02dc3 100644 --- a/tests/openpgp/all-tests.scm +++ b/tests/openpgp/all-tests.scm @@ -30,6 +30,7 @@ (make-environment-cache (test::scm #f + #f (path-join "tests" "openpgp" "setup.scm") (in-srcdir "tests" "openpgp" "setup.scm")))) @@ -40,7 +41,8 @@ (make-environment-cache (test::scm #f - (qualify (path-join "tests" "openpgp" "setup.scm") variant) + variant + (path-join "tests" "openpgp" "setup.scm") (in-srcdir "tests" "openpgp" "setup.scm") (string-append "--" variant)))) @@ -62,7 +64,8 @@ (define tests (map (lambda (name) (test::scm setup - (qualify (path-join "tests" "openpgp" name) "standard") + "standard" + (path-join "tests" "openpgp" name) (in-srcdir "tests" "openpgp" name))) all-tests)) (when *run-all-tests* @@ -73,17 +76,16 @@ (if keyboxd-enabled? (map (lambda (name) (test::scm setup-use-keyboxd - (qualify (path-join "tests" "openpgp" name) - "keyboxd") + "keyboxd" + (path-join "tests" "openpgp" name) (in-srcdir "tests" "openpgp" name) "--use-keyboxd")) all-tests)) ;; The third pass uses the legact pubring.gpg (map (lambda (name) (test::scm setup-use-keyring - (qualify (path-join "tests" "openpgp" name) - "keyring") + "keyring" + (path-join "tests" "openpgp" name) (in-srcdir "tests" "openpgp" name) - "--use-keyring")) all-tests) - ))) + "--use-keyring")) all-tests)))) tests) diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm index 57174b56e..1ac25bf65 100644 --- a/tests/openpgp/defs.scm +++ b/tests/openpgp/defs.scm @@ -146,6 +146,9 @@ (gpg-conf' "" args)) (define (gpg-conf' input args) (let ((s (call-popen `(,(tool-hardcoded 'gpgconf) + ,@(if *win32* + (list '--build-prefix (getenv "objdir")) + '()) ,@args) input))) (map (lambda (line) (map percent-decode (string-split line #\:))) (string-split-newlines s)))) diff --git a/tests/openpgp/fake-pinentry.c b/tests/openpgp/fake-pinentry.c index fb0c6ae1b..18b60574b 100644 --- a/tests/openpgp/fake-pinentry.c +++ b/tests/openpgp/fake-pinentry.c @@ -196,28 +196,20 @@ option_value (const char *line, const char *name) return NULL; } -int -main (int argc, char **argv) +static int +parse_pinentry_user_data (const char *args, + char **r_passphrase) { - char *args; - char *option_user_data = NULL; - int got_environment_user_data; char *logfile; char *passphrasefile; char *passphrase; - /* We get our options via PINENTRY_USER_DATA. */ - (void) argc, (void) argv; - - setvbuf (stdin, NULL, _IOLBF, BUFSIZ); - setvbuf (stdout, NULL, _IOLBF, BUFSIZ); + *r_passphrase = NULL; - args = getenv ("PINENTRY_USER_DATA"); - got_environment_user_data = !!args; - if (! args) - args = ""; + if (log_stream) + fclose (log_stream); + log_stream = NULL; - restart: logfile = option_value (args, "--logfile"); if (logfile) { @@ -232,7 +224,7 @@ main (int argc, char **argv) if (! log_stream) { perror (logfile); - return 1; + return -1; } } @@ -251,20 +243,31 @@ main (int argc, char **argv) { reply ("# Passphrasefile '%s' is empty. Terminating.\n", passphrasefile); - return 1; + return -1; } rstrip (passphrase); } else - { - passphrase = skip_options (args); - if (*passphrase == 0) - passphrase = "no PINENTRY_USER_DATA -- using default passphrase"; - } + passphrase = strdup (skip_options (args)); + + *r_passphrase = passphrase; + return 0; +} - reply ("# fake-pinentry(%u) started. Passphrase='%s'.\n", - (unsigned int)getpid (), passphrase); + +int +main (int argc, char **argv) +{ + char *passphrase = NULL; + + /* We get our options via PINENTRY_USER_DATA. */ + (void) argc, (void) argv; + + setvbuf (stdin, NULL, _IOLBF, BUFSIZ); + setvbuf (stdout, NULL, _IOLBF, BUFSIZ); + + reply ("# fake-pinentry(%u) started.\n", (unsigned int)getpid ()); reply ("OK - what's up?\n"); while (! feof (stdin)) @@ -282,7 +285,12 @@ main (int argc, char **argv) #define OPT_USER_DATA "OPTION pinentry-user-data=" if (strncmp (buffer, "GETPIN", 6) == 0) - reply ("D %s\n", passphrase); + { + if (passphrase) + reply ("D %s\n", passphrase); + else + reply ("D deafult\n"); + } else if (strncmp (buffer, "BYE", 3) == 0) { reply ("OK\n"); @@ -290,18 +298,12 @@ main (int argc, char **argv) } else if (strncmp (buffer, OPT_USER_DATA, strlen (OPT_USER_DATA)) == 0) { - if (got_environment_user_data) + if (parse_pinentry_user_data (buffer + strlen (OPT_USER_DATA), + &passphrase) < 0) { - reply ("OK - I already got the data from the environment.\n"); - continue; + /* Failure. */ + return 1; } - - if (log_stream) - fclose (log_stream); - log_stream = NULL; - free (option_user_data); - option_user_data = args = strdup (buffer + strlen (OPT_USER_DATA)); - goto restart; } reply ("OK\n"); @@ -313,6 +315,7 @@ main (int argc, char **argv) if (log_stream) fclose (log_stream); - free (option_user_data); + if (passphrase) + free (passphrase); return 0; } diff --git a/tests/openpgp/issue2941.scm b/tests/openpgp/issue2941.scm index 8f625ebe3..306df6cb5 100755 --- a/tests/openpgp/issue2941.scm +++ b/tests/openpgp/issue2941.scm @@ -29,6 +29,6 @@ (for-each-p "Checking invocation with invalid file descriptors (issue2941)." (lambda (option) - (check-failure `(,(string-append "--" option "=23") --sign gpg.conf))) + (check-failure `(,(string-append "--" option "=233") --sign gpg.conf))) '("status-fd" "attribute-fd" "logger-fd" "override-session-key-fd" "passphrase-fd" "command-fd")) diff --git a/tests/openpgp/run-tests.scm b/tests/openpgp/run-tests.scm index 8f9435943..faf52d80b 100644 --- a/tests/openpgp/run-tests.scm +++ b/tests/openpgp/run-tests.scm @@ -29,6 +29,7 @@ (define setup (make-environment-cache (test::scm #f + #f (path-join "tests" "openpgp" "setup.scm") (in-srcdir "tests" "openpgp" "setup.scm")))) @@ -55,11 +56,12 @@ (if use-keyboxd? (map (lambda (name) (test::scm setup-use-keyboxd - (qualify (path-join "tests" "openpgp" name) - "keyboxd") + "keyboxd" + (path-join "tests" "openpgp" name) (in-srcdir "tests" "openpgp" name) "--use-keyboxd")) tests) (map (lambda (name) (test::scm setup + #f (path-join "tests" "openpgp" name) (in-srcdir "tests" "openpgp" name))) tests)))) |