c-api.test 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 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. (define srcdir (cdr (assq 'srcdir %guile-build-info)))
  20. (define (egrep string filename)
  21. (zero? (system (string-append "egrep '" string "' " filename " >/dev/null"))))
  22. (define (seek-offset-test dirname)
  23. (let ((dir (opendir dirname)))
  24. (do ((filename (readdir dir) (readdir dir)))
  25. ((eof-object? filename))
  26. (if (and
  27. (eqv? (string-ref filename (- (string-length filename) 1)) #\c)
  28. (eqv? (string-ref filename (- (string-length filename) 2)) #\.))
  29. (let ((file (string-append dirname "/" filename)))
  30. (if (and (file-exists? file)
  31. (egrep "SEEK_(SET|CUR|END)" file)
  32. (not (egrep "unistd.h" file)))
  33. (fail file)))))))
  34. ;;; A rough conservative test to check that all source files
  35. ;;; which use SEEK_SET, SEEK_CUR, and SEEK_END include unistd.h.
  36. ;;;
  37. ;;; If this test start to trigger without reason, we just modify it
  38. ;;; to be more precise.
  39. (with-test-prefix "SEEK_XXX => #include <unistd.h>"
  40. (if (file-exists? srcdir)
  41. (seek-offset-test srcdir)))