c-api.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ;;;; c-api.test --- complementary test suite for the c-api -*- scheme -*-
  2. ;;;; MDJ 990915 <djurfeldt@nada.kth.se>
  3. ;;;;
  4. ;;;; Copyright (C) 1999, 2006, 2012, 2014, 2022 Free Software Foundation, Inc.
  5. ;;;;
  6. ;;;; This library is free software; you can redistribute it and/or
  7. ;;;; modify it under the terms of the GNU Lesser General Public
  8. ;;;; License as published by the Free Software Foundation; either
  9. ;;;; version 3 of the License, or (at your option) any later version.
  10. ;;;;
  11. ;;;; This library is distributed in the hope that it will be useful,
  12. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;;;; Lesser General Public License for more details.
  15. ;;;;
  16. ;;;; You should have received a copy of the GNU Lesser General Public
  17. ;;;; License along with this library; if not, write to the Free Software
  18. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. (use-modules (test-suite lib))
  20. (define srcdir (cdr (assq 'srcdir %guile-build-info)))
  21. (define (egrep string filename)
  22. (zero? (system (string-append "grep -E \"" string "\" " filename
  23. " >" %null-device))))
  24. (define (seek-offset-test dirname)
  25. (let ((dir (opendir dirname)))
  26. (do ((filename (readdir dir) (readdir dir)))
  27. ((eof-object? filename))
  28. (if (and
  29. (eqv? (string-ref filename (- (string-length filename) 1)) #\c)
  30. (eqv? (string-ref filename (- (string-length filename) 2)) #\.))
  31. (let ((file (string-append dirname "/" filename)))
  32. (if (and (file-exists? file)
  33. (egrep "SEEK_(SET|CUR|END)" file))
  34. (pass-if file (egrep "unistd.h" file))))))))
  35. ;;; A rough conservative test to check that all source files
  36. ;;; which use SEEK_SET, SEEK_CUR, and SEEK_END include unistd.h.
  37. ;;;
  38. ;;; If this test start to trigger without reason, we just modify it
  39. ;;; to be more precise.
  40. (with-test-prefix "SEEK_XXX => #include <unistd.h>"
  41. (if (file-exists? srcdir)
  42. (seek-offset-test srcdir)))