gremlin.scm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (test-gremlin)
  19. #:use-module (guix elf)
  20. #:use-module (guix build utils)
  21. #:use-module (guix build gremlin)
  22. #:use-module (srfi srfi-1)
  23. #:use-module (srfi srfi-26)
  24. #:use-module (srfi srfi-64)
  25. #:use-module (rnrs io ports)
  26. #:use-module (ice-9 match))
  27. (define %guile-executable
  28. (match (command-line)
  29. ((program . _)
  30. (and (file-exists? program) (elf-file? program)
  31. program))
  32. (_
  33. #f)))
  34. (define read-elf
  35. (compose parse-elf get-bytevector-all))
  36. (test-begin "gremlin")
  37. (unless %guile-executable (test-skip 1))
  38. (test-assert "elf-dynamic-info-needed, executable"
  39. (let* ((elf (call-with-input-file %guile-executable read-elf))
  40. (dyninfo (elf-dynamic-info elf)))
  41. (or (not dyninfo) ;static executable
  42. (lset<= string=?
  43. (list (string-append "libguile-" (effective-version))
  44. "libgc" "libunistring" "libffi")
  45. (map (lambda (lib)
  46. (string-take lib (string-contains lib ".so")))
  47. (elf-dynamic-info-needed dyninfo))))))
  48. (test-equal "expand-origin"
  49. '("OOO/../lib"
  50. "OOO"
  51. "../OOO/bar/OOO/baz"
  52. "ORIGIN/foo")
  53. (map (cut expand-origin <> "OOO")
  54. '("$ORIGIN/../lib"
  55. "${ORIGIN}"
  56. "../${ORIGIN}/bar/$ORIGIN/baz"
  57. "ORIGIN/foo")))
  58. (test-end "gremlin")