1 ;; Copyright (C) 2016 g10 Code GmbH
3 ;; This file is part of GnuPG.
5 ;; GnuPG is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; GnuPG is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
18 (if (string=? "" (getenv "abs_top_srcdir"))
19 (error "not called from make"))
21 (let ((verbose (string->number (getenv "verbose"))))
23 (*set-verbose!* verbose)))
25 (define (qualify executable)
26 (string-append executable (getenv "EXEEXT")))
28 ;; We may not use a relative name for gpg-agent.
29 (define gpgconf (path-join (getenv "objdir") "tools" (qualify "gpgconf")))
30 (define GPG-AGENT (path-join (getenv "objdir") "agent" (qualify "gpg-agent")))
31 (define GPG `(,(path-join (getenv "objdir") "g10" (qualify "gpg"))
32 --no-permission-warning --no-greeting
33 --no-secmem-warning --batch
34 ,(string-append "--agent-program=" GPG-AGENT
35 "|--debug-quick-random")))
37 (filter (lambda (arg) (not (equal? arg '--batch))) GPG))
39 (define GPGTAR (path-join (getenv "objdir") "tools" (qualify "gpgtar")))
41 (define (untar-armored source-name)
42 (with-ephemeral-home-directory (lambda ()) (lambda ())
44 (pipe:open source-name (logior O_RDONLY O_BINARY))
45 (pipe:spawn `(,@GPG --dearmor))
46 (pipe:spawn `(,GPGTAR --extract --directory=. -)))))
48 (define (run-test message src-tarball test)
49 (catch (skip "gpgtar not built")
50 (call-check `(,GPGTAR --help)))
52 (with-temporary-working-directory
54 (untar-armored src-tarball)
55 (setenv "GNUPGHOME" (getcwd) #t)
57 (catch (log "Warning: Creating socket directory failed:" (car *error*))
58 (call-popen `(,gpgconf --create-socketdir) ""))
60 (catch (log "Warning: Removing socket directory failed.")
61 (call-popen `(,gpgconf --remove-socketdir) ""))))