diff options
Diffstat (limited to 'test/signal')
| -rw-r--r-- | test/signal/Makefile | 8 | ||||
| -rw-r--r-- | test/signal/Makefile.in | 10 | ||||
| -rw-r--r-- | test/signal/tst-raise.c | 5 | ||||
| -rw-r--r-- | test/signal/tst-signalfd.c | 63 | ||||
| -rw-r--r-- | test/signal/tst-sigsimple.c | 5 |
5 files changed, 81 insertions, 10 deletions
diff --git a/test/signal/Makefile b/test/signal/Makefile index 2ff96fa73..c2afb5f50 100644 --- a/test/signal/Makefile +++ b/test/signal/Makefile @@ -1,8 +1,8 @@ # uClibc signal tests # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),) -TESTS_DISABLED := tst-sigsimple -endif - +top_builddir=../../ +top_srcdir=../../ +include ../Rules.mak +-include Makefile.in include ../Test.mak diff --git a/test/signal/Makefile.in b/test/signal/Makefile.in new file mode 100644 index 000000000..27791a911 --- /dev/null +++ b/test/signal/Makefile.in @@ -0,0 +1,10 @@ +# uClibc signal tests +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + +ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),) +TESTS_DISABLED := tst-sigsimple +endif + +CFLAGS_tst-signalfd = -fPIC +CFLAGS_tst-sigset = -fPIC +CFLAGS_tst-sigsimple = -fPIC diff --git a/test/signal/tst-raise.c b/test/signal/tst-raise.c index d24c316cf..534ae7151 100644 --- a/test/signal/tst-raise.c +++ b/test/signal/tst-raise.c @@ -13,9 +13,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <string.h> diff --git a/test/signal/tst-signalfd.c b/test/signal/tst-signalfd.c new file mode 100644 index 000000000..1fbb748aa --- /dev/null +++ b/test/signal/tst-signalfd.c @@ -0,0 +1,63 @@ +/* vi: set sw=4 ts=4 sts=4: */ +/* + * signalfd test for uClibc + * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <error.h> +#include <signal.h> +#include <sys/signalfd.h> +#include <sys/fcntl.h> + +static int +do_test(void) +{ + int fd, ret, result = 0; + struct signalfd_siginfo ssi; + sigset_t mask; + + sigemptyset(&mask); + sigaddset(&mask, SIGUSR1); + sigprocmask(SIG_BLOCK, &mask, NULL); + + fd = signalfd(-1, &mask, SFD_NONBLOCK); + if (fd < 0) { + printf("signalfd() failed: %s\n", strerror(errno)); + result = 1; + } + + /* this should return immediately with EAGAIN due to SFD_NONBLOCK */ + memset(&ssi, 0, sizeof(ssi)); + ret = read(fd, &ssi, sizeof(ssi)); + if (ret != -1 || errno != EAGAIN) { + error(0, 0, "first read() returned %d", ret); + result = 1; + } + + kill(getpid(), SIGUSR1); + + /* this should return a struct ssi indicating receipt of SIGUSR1 */ + ret = read(fd, &ssi, sizeof(ssi)); + if (ret != sizeof(ssi)) { + error(0, 0, "second read() returned %d", ret); + result = 1; + } + + if (ssi.ssi_signo != SIGUSR1) { + error(0, 0, "ssi contains bogus signo"); + result = 1; + } + + return result; +} + +#define TIMEOUT 5 +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test/signal/tst-sigsimple.c b/test/signal/tst-sigsimple.c index 22bb85cba..80220eed0 100644 --- a/test/signal/tst-sigsimple.c +++ b/test/signal/tst-sigsimple.c @@ -13,9 +13,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <signal.h> |
