Attach t_exect to ATF tests and distribution

Add missing SIGTRAP handler. Assert there that the signal is SIGTRAP as
expected and si_code TRAP_TRACE.

This test will break on some ports that have dummy or incomplete
implementation of exect(2).

This test works on amd64 correctly.

Sponsored by <The NetBSD Foundation>
This commit is contained in:
kamil 2016-12-09 06:12:02 +00:00
parent b5e1bd240f
commit 5e8d31ff24
5 changed files with 31 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.183 2016/12/02 05:54:14 kamil Exp $
# $NetBSD: mi,v 1.184 2016/12/09 06:12:02 kamil Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile
@ -1863,6 +1863,7 @@
./usr/libdata/debug/usr/tests/lib/libc/db/h_db.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/db/h_lfsr.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/db/t_db_hash_seq.debug tests-lib-debug debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/gen/exect/t_exect.debug tests-kernel-tests debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/gen/execve/t_execve.debug tests-kernel-tests debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/gen/posix_spawn/h_fileactions.debug tests-kernel-tests debug,atf,compattestfile
./usr/libdata/debug/usr/tests/lib/libc/gen/posix_spawn/h_spawn.debug tests-kernel-tests debug,atf,compattestfile

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.706 2016/12/02 05:54:14 kamil Exp $
# $NetBSD: mi,v 1.707 2016/12/09 06:12:02 kamil Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -90,6 +90,7 @@
./usr/libdata/debug/usr/tests/lib/libc/c063 tests-lib-debug compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/db tests-lib-debug compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/gen tests-lib-debug compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/gen/exect tests-kernel-tests compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/gen/execve tests-kernel-tests compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/gen/posix_spawn tests-kernel-tests compattestfile,atf
./usr/libdata/debug/usr/tests/lib/libc/getaddrinfo tests-obsolete obsolete
@ -2417,6 +2418,10 @@
./usr/tests/lib/libc/gen tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/gen/Atffile tests-lib-tests compattestfile,atf
./usr/tests/lib/libc/gen/Kyuafile tests-lib-tests compattestfile,atf,kyua
./usr/tests/lib/libc/gen/exect tests-kernel-tests compattestfile,atf
./usr/tests/lib/libc/gen/exect/Atffile tests-kernel-tests compattestfile,atf
./usr/tests/lib/libc/gen/exect/Kyuafile tests-kernel-tests compattestfile,atf,kyua
./usr/tests/lib/libc/gen/exect/t_exect tests-kernel-tests compattestfile,atf
./usr/tests/lib/libc/gen/execve tests-kernel-tests compattestfile,atf
./usr/tests/lib/libc/gen/execve/Atffile tests-kernel-tests compattestfile,atf
./usr/tests/lib/libc/gen/execve/Kyuafile tests-kernel-tests compattestfile,atf,kyua

View File

@ -1,4 +1,4 @@
# $NetBSD: NetBSD.dist.tests,v 1.136 2016/12/02 05:54:14 kamil Exp $
# $NetBSD: NetBSD.dist.tests,v 1.137 2016/12/09 06:12:02 kamil Exp $
./usr/libdata/debug/usr/tests
./usr/libdata/debug/usr/tests/atf
@ -80,6 +80,7 @@
./usr/libdata/debug/usr/tests/lib/libc/c063
./usr/libdata/debug/usr/tests/lib/libc/db
./usr/libdata/debug/usr/tests/lib/libc/gen
./usr/libdata/debug/usr/tests/lib/libc/gen/exect
./usr/libdata/debug/usr/tests/lib/libc/gen/execve
./usr/libdata/debug/usr/tests/lib/libc/gen/posix_spawn
./usr/libdata/debug/usr/tests/lib/libc/hash
@ -262,6 +263,7 @@
./usr/tests/lib/libc/c063
./usr/tests/lib/libc/db
./usr/tests/lib/libc/gen
./usr/tests/lib/libc/gen/exect
./usr/tests/lib/libc/gen/execve
./usr/tests/lib/libc/gen/posix_spawn
./usr/tests/lib/libc/hash

View File

@ -1,10 +1,11 @@
# $NetBSD: Makefile,v 1.49 2015/12/22 14:25:58 christos Exp $
# $NetBSD: Makefile,v 1.50 2016/12/09 06:12:02 kamil Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/lib/libc/gen
TESTS_SUBDIRS= execve
TESTS_SUBDIRS= exect
TESTS_SUBDIRS+= execve
TESTS_SUBDIRS+= posix_spawn
TESTS_C+= t_alarm

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_exect.c,v 1.1 2016/12/09 04:00:36 kamil Exp $ */
/* $NetBSD: t_exect.c,v 1.2 2016/12/09 06:12:02 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -29,6 +29,7 @@
#include <atf-c.h>
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
@ -41,14 +42,24 @@ ATF_TC_HEAD(t_exect_null, tc)
"Tests an empty exect(2) executing");
}
static void
sigtrap_handler(int sig, siginfo_t *info, void *ctx)
{
ATF_REQUIRE_EQ(sig, SIGTRAP);
ATF_REQUIRE_EQ(info->si_code, TRAP_TRACE);
}
ATF_TC_BODY(t_exect_null, tc)
{
int err;
struct sigaction act;
err = exect(NULL, NULL, NULL);
ATF_REQUIRE(err == -1);
ATF_REQUIRE_MSG(errno == EFAULT,
"wrong error returned %d instead of %d", errno, EFAULT);
ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0);
act.sa_sigaction = sigtrap_handler;
act.sa_flags = SA_SIGINFO;
ATF_REQUIRE(sigaction(SIGTRAP, &act, 0) == 0);
ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1);
}
ATF_TP_ADD_TCS(tp)