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