chiark / gitweb /
asshelp.c: add a lot of debug logging
[gnupg2.git] / tests / gpgme / wrap.scm
1 #!/usr/bin/env gpgscm
2
3 ;; Copyright (C) 2016 g10 Code GmbH
4 ;;
5 ;; This file is part of GnuPG.
6 ;;
7 ;; GnuPG is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
11 ;;
12 ;; GnuPG is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
19
20 (load (with-path "gpgme-defs.scm"))
21
22 (define executable (flag "--executable" *args*))
23 (unless (and executable (not (null? executable)))
24         (error "Usage: wrap.scm --executable <file> [args...]"))
25
26 (setup-gpgme-environment "tests" "gpg")
27
28 (setenv "abs_builddir" (getcwd) #t)
29 (setenv "top_srcdir" gpgme-srcdir #t)
30 (setenv "srcdir" (path-join gpgme-srcdir "tests" "gpg") #t)
31
32 (define (run what)
33   (if (string-suffix? (car what) ".py")
34       (begin
35         (setenv "LD_LIBRARY_PATH"
36                 (if (< 0 (string-length (getenv "LD_LIBRARY_PATH")))
37                     (string-append (path-join gpgme-builddir "src/.libs")
38                                    (string *pathsep*)
39                                    (getenv "LD_LIBRARY_PATH"))
40                     (path-join gpgme-builddir "src/.libs"))
41                 #t)
42         (call-with-fds
43          `("/usr/bin/python"
44            ,(in-gpgme-srcdir "lang" "python" "tests" "run-tests.py")
45            --quiet
46            --interpreters=/usr/bin/python
47            --builddir ,(path-join gpgme-builddir "lang" "python" "tests")
48            ,@what)
49          STDIN_FILENO STDOUT_FILENO STDERR_FILENO))
50       (if #f 77 (call-with-fds what STDIN_FILENO STDOUT_FILENO STDERR_FILENO))))
51
52 (let ((name (basename (car executable))))
53   (cond
54    ((string=? "t-keylist" name)
55     ;; This test assumes that 't-import' imported a key.
56     (log "Importing extra key...")
57     (call-check `(,@GPG --yes --import ,(in-srcdir "pubkey-1.asc"))))))
58
59 (log "Running" (car executable))
60 (exit (run executable))