From f55bb4f13cc783805ac42d4ecf6e75999902b879 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 20 Sep 2011 22:26:34 +0200 Subject: [PATCH] Tests for function fstat(). * modules/fstat-tests: New file. * tests/test-fstat.c: New file. * modules/sys_stat-tests (Depends-on): Add fstat-tests. --- ChangeLog | 7 +++++++ modules/fstat-tests | 12 ++++++++++++ modules/sys_stat-tests | 1 + tests/test-fstat.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 modules/fstat-tests create mode 100644 tests/test-fstat.c diff --git a/ChangeLog b/ChangeLog index 8e970c234..ead3b9571 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-09-20 Bruno Haible + Tests for function fstat(). + * modules/fstat-tests: New file. + * tests/test-fstat.c: New file. + * modules/sys_stat-tests (Depends-on): Add fstat-tests. + +2011-09-20 Bruno Haible + test-ttyname_r tests: EBADF tests. * tests/test-ttyname_r.c (main): Add tests for EBADF. diff --git a/modules/fstat-tests b/modules/fstat-tests new file mode 100644 index 000000000..27ebb38bb --- /dev/null +++ b/modules/fstat-tests @@ -0,0 +1,12 @@ +Files: +tests/test-fstat.c +tests/signature.h +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-fstat +check_PROGRAMS += test-fstat diff --git a/modules/sys_stat-tests b/modules/sys_stat-tests index a5ede77ab..bfdc1a26c 100644 --- a/modules/sys_stat-tests +++ b/modules/sys_stat-tests @@ -4,6 +4,7 @@ tests/test-sys_stat.c Depends-on: verify sys_stat-c++-tests +fstat-tests configure.ac: diff --git a/tests/test-fstat.c b/tests/test-fstat.c new file mode 100644 index 000000000..6c120d9dd --- /dev/null +++ b/tests/test-fstat.c @@ -0,0 +1,48 @@ +/* Tests of fstat() function. + Copyright (C) 2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (fstat, int, (int, struct stat *)); + +#include + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (-1, &statbuf) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (99, &statbuf) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} -- 2.11.0