diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cms/Makefile.am | 4 | ||||
-rw-r--r-- | tests/cms/all-tests.scm | 2 | ||||
-rw-r--r-- | tests/cms/run-tests.scm | 2 | ||||
-rw-r--r-- | tests/gpgme/all-tests.scm | 3 | ||||
-rw-r--r-- | tests/gpgscm/ffi.c | 5 | ||||
-rw-r--r-- | tests/gpgscm/tests.scm | 19 | ||||
-rw-r--r-- | tests/migrations/all-tests.scm | 1 | ||||
-rwxr-xr-x | tests/migrations/from-classic.scm | 2 | ||||
-rw-r--r-- | tests/migrations/run-tests.scm | 1 | ||||
-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 | ||||
-rw-r--r-- | tests/pkits/Makefile.am | 2 |
15 files changed, 89 insertions, 56 deletions
diff --git a/tests/cms/Makefile.am b/tests/cms/Makefile.am index 999bd4fb8..60fdf0281 100644 --- a/tests/cms/Makefile.am +++ b/tests/cms/Makefile.am @@ -28,13 +28,15 @@ include $(top_srcdir)/am/cmacros.am AM_CFLAGS = +GPGSM = ../../sm/gpgsm + # Note that we need to use /bin/pwd so that we don't get into trouble # if the shell used for inittests would uses an internal version of # pwd which handles symlinks differently. OLD_TESTS_ENVIRONMENT = GNUPGHOME=`/bin/pwd` GPG_AGENT_INFO= LC_ALL=C \ GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GNUPG_IN_TEST_SUITE=fact \ - GPGSM="$(GPGSM)" "$(srcdir)/runtest" + GPGSM="$(GPGSM)$(EXEEXT)" "$(srcdir)/runtest" TESTS_ENVIRONMENT = LC_ALL=C \ EXEEXT=$(EXEEXT) \ diff --git a/tests/cms/all-tests.scm b/tests/cms/all-tests.scm index 78ad00678..6d4c5822a 100644 --- a/tests/cms/all-tests.scm +++ b/tests/cms/all-tests.scm @@ -30,12 +30,14 @@ (make-environment-cache (test::scm #f + #f (path-join "tests" "cms" "setup.scm") (in-srcdir "tests" "cms" "setup.scm") "--" "tests" "gpg"))) (map (lambda (name) (test::scm setup + #f (path-join "tests" "cms" name) (in-srcdir "tests" "cms" name))) (parse-makefile-expand (in-srcdir "tests" "cms" "Makefile.am") diff --git a/tests/cms/run-tests.scm b/tests/cms/run-tests.scm index caae86d5b..7079ed3ca 100644 --- a/tests/cms/run-tests.scm +++ b/tests/cms/run-tests.scm @@ -28,6 +28,7 @@ (define setup (make-environment-cache (test::scm #f + #f (path-join "tests" "cms" "setup.scm") (in-srcdir "tests" "cms" "setup.scm")))) @@ -35,5 +36,6 @@ (load-tests "tests" "cms") (map (lambda (name) (test::scm setup + #f (path-join "tests" "cms" name) (in-srcdir "tests" "cms" name))) tests))) diff --git a/tests/gpgme/all-tests.scm b/tests/gpgme/all-tests.scm index f72f8af97..1746c4ee1 100644 --- a/tests/gpgme/all-tests.scm +++ b/tests/gpgme/all-tests.scm @@ -40,6 +40,7 @@ (make-environment-cache (test::scm #f + #f (path-join "tests" "gpgme" "setup.scm" "tests" "gpg") (in-srcdir "tests" "gpgme" "setup.scm") "--" "tests" "gpg"))) @@ -47,6 +48,7 @@ (make-environment-cache (test::scm #f + #f (path-join "tests" "gpgme" "setup.scm" "lang" "python" "tests") (in-srcdir "tests" "gpgme" "setup.scm") "--" "lang" "python" "tests"))) @@ -71,6 +73,7 @@ (map (lambda (name) (apply test::scm `(,(:setup cmpnts) + #f ,(apply path-join `("tests" "gpgme" ,@(:path cmpnts) ,name)) ,(in-srcdir "tests" "gpgme" "wrap.scm") diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c index 58659c1b8..879a05e09 100644 --- a/tests/gpgscm/ffi.c +++ b/tests/gpgscm/ffi.c @@ -360,6 +360,11 @@ do_get_temp_path (scheme *sc, pointer args) #ifdef HAVE_W32_SYSTEM if (GetTempPath (MAX_PATH+1, buffer) == 0) FFI_RETURN_STRING (sc, "/temp"); + else + { + size_t len = strlen (buffer); + buffer[len-1] = 0; + } FFI_RETURN_STRING (sc, buffer); #else FFI_RETURN_STRING (sc, "/tmp"); diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm index 4311b38ca..6a11e55f1 100644 --- a/tests/gpgscm/tests.scm +++ b/tests/gpgscm/tests.scm @@ -677,14 +677,14 @@ name)) (package - (define (scm setup name path . args) + (define (scm setup variant name path . args) ;; Start the process. (define (spawn-scm args' in out err) (process-spawn-fd `(,*argv0* ,@(verbosity (*verbose*)) ,(locate-test (test-name path)) ,@(if setup (force setup) '()) ,@args' ,@args) in out err)) - (new name #f spawn-scm #f #f CLOSED_FD (expect-failure? name))) + (new variant name #f spawn-scm #f #f CLOSED_FD (expect-failure? name))) (define (binary setup name path . args) ;; Start the process. @@ -692,9 +692,9 @@ (process-spawn-fd `(,(test-name path) ,@(if setup (force setup) '()) ,@args' ,@args) in out err)) - (new name #f spawn-binary #f #f CLOSED_FD (expect-failure? name))) + (new #f name #f spawn-binary #f #f CLOSED_FD (expect-failure? name))) - (define (new name directory spawn proc retcode logfd expect-failure) + (define (new variant name directory spawn proc retcode logfd expect-failure) (package ;; XXX: OO glue. @@ -723,7 +723,11 @@ (define (open-log-file) (unless log-file-name - (set! log-file-name (string-append (basename name) ".log"))) + (set! log-file-name (path-join + (getenv "objdir") + (if variant + (string-append name "." variant ".log") + (string-append name ".log"))))) (catch '() (unlink log-file-name)) (open log-file-name (logior O_RDWR O_BINARY O_CREAT) #o600)) @@ -772,7 +776,10 @@ (seek logfd 0 SEEK_SET) (splice logfd STDERR_FILENO) (close logfd)) - (echo (string-append (status-string) ":") name)) + (echo (string-append (status-string) ":") + (if variant + (string-append "<" variant ">" name) + name))) (define (xml) (xx::tag diff --git a/tests/migrations/all-tests.scm b/tests/migrations/all-tests.scm index 421f69679..ba95f5c50 100644 --- a/tests/migrations/all-tests.scm +++ b/tests/migrations/all-tests.scm @@ -28,6 +28,7 @@ (map (lambda (name) (test::scm #f + #f (path-join "tests" "migrations" name) (in-srcdir "tests" "migrations" name))) (parse-makefile-expand (in-srcdir "tests" "migrations" "Makefile.am") diff --git a/tests/migrations/from-classic.scm b/tests/migrations/from-classic.scm index b473d702a..2033a4a77 100755 --- a/tests/migrations/from-classic.scm +++ b/tests/migrations/from-classic.scm @@ -26,7 +26,7 @@ (call-check `(,@GPG --list-secret-keys))) (define (assert-migrated) - (unless (file-exists? ".gpg-v21-migrated") + (unless (or (file-exists? ".gpg-v21-migrated") (file-exists? "gpg-v21-migrated")) (error "Not migrated")) (for-each diff --git a/tests/migrations/run-tests.scm b/tests/migrations/run-tests.scm index f44334c7d..d4db14f56 100644 --- a/tests/migrations/run-tests.scm +++ b/tests/migrations/run-tests.scm @@ -23,5 +23,6 @@ (load-tests "tests" "migrations") (map (lambda (name) (test::scm #f + #f (path-join "tests" "migrations" name) (in-srcdir "tests" "migrations" name))) tests))) 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)))) diff --git a/tests/pkits/Makefile.am b/tests/pkits/Makefile.am index 0b90f86ba..d25dd91a6 100644 --- a/tests/pkits/Makefile.am +++ b/tests/pkits/Makefile.am @@ -23,7 +23,7 @@ GPGSM = ../../sm/gpgsm TESTS_ENVIRONMENT = GNUPGHOME=`/bin/pwd` GPG_AGENT_INFO= LC_ALL=C \ GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GNUPG_IN_TEST_SUITE=fact \ - GPGSM=$(GPGSM) silent=yes + GPGSM=$(GPGSM)$(EXEEXT) silent=yes testscripts = import-all-certs validate-all-certs \ |