From 1bc0f10a1270aae4cfa81599be016e72da86ace5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 20 Sep 2011 21:38:04 +0200 Subject: [PATCH] Tests for module 'shutdown'. * modules/shutdown-tests: New file. * tests/test-shutdown.c: New file. --- ChangeLog | 4 ++++ modules/shutdown-tests | 14 ++++++++++++++ tests/test-shutdown.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 modules/shutdown-tests create mode 100644 tests/test-shutdown.c diff --git a/ChangeLog b/ChangeLog index 0e3d302fb..9f78886d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-09-20 Bruno Haible + Tests for module 'shutdown'. + * modules/shutdown-tests: New file. + * tests/test-shutdown.c: New file. + Tests for module 'setsockopt'. * modules/setsockopt-tests: New file. * tests/test-setsockopt.c: New file. diff --git a/modules/shutdown-tests b/modules/shutdown-tests new file mode 100644 index 000000000..d90299d4c --- /dev/null +++ b/modules/shutdown-tests @@ -0,0 +1,14 @@ +Files: +tests/test-shutdown.c +tests/signature.h +tests/macros.h + +Depends-on: +sockets + +configure.ac: + +Makefile.am: +TESTS += test-shutdown +check_PROGRAMS += test-shutdown +test_shutdown_LDADD = $(LDADD) @LIBSOCKET@ diff --git a/tests/test-shutdown.c b/tests/test-shutdown.c new file mode 100644 index 000000000..d154f8ef0 --- /dev/null +++ b/tests/test-shutdown.c @@ -0,0 +1,47 @@ +/* Test the shutdown() 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 (shutdown, int, (int, int)); + +#include + +#include "sockets.h" +#include "macros.h" + +int +main (void) +{ + gl_sockets_startup (SOCKETS_1_1); + + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (shutdown (-1, SHUT_RD) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (shutdown (99, SHUT_RD) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} -- 2.11.0