# HG changeset patch # User Bruno Haible # Date 1316550394 -7200 # Node ID 8897fe9c964dcb3c563663b861b61dd14a729edf # Parent a4ad24b6e079ae93b53e0e5fa0952d40388ab21b Tests for function fstat(). * modules/fstat-tests: New file. * tests/test-fstat.c: New file. * modules/sys_stat-tests (Depends-on): Add fstat-tests. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/modules/fstat-tests b/modules/fstat-tests new file mode 100644 --- /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 --- a/modules/sys_stat-tests +++ b/modules/sys_stat-tests @@ -4,6 +4,7 @@ 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 --- /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; +}