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