c-api.test 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 program is free software; you can redistribute it and/or modify
  7. ;;;; it under the terms of the GNU General Public License as published by
  8. ;;;; the Free Software Foundation; either version 2, or (at your option)
  9. ;;;; any later version.
  10. ;;;;
  11. ;;;; This program 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
  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 this software; see the file COPYING. If not, write to
  18. ;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. ;;;; Boston, MA 02110-1301 USA
  20. (define srcdir (cdr (assq 'srcdir %guile-build-info)))
  21. (define (egrep string filename)
  22. (zero? (system (string-append "egrep '" string "' " filename " >/dev/null"))))
  23. (define (seek-offset-test dirname)
  24. (let ((dir (opendir dirname)))
  25. (do ((filename (readdir dir) (readdir dir)))
  26. ((eof-object? filename))
  27. (if (and
  28. (eqv? (string-ref filename (- (string-length filename) 1)) #\c)
  29. (eqv? (string-ref filename (- (string-length filename) 2)) #\.))
  30. (let ((file (string-append dirname "/" filename)))
  31. (if (and (file-exists? file)
  32. (egrep "SEEK_(SET|CUR|END)" file)
  33. (not (egrep "unistd.h" file)))
  34. (fail 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)))