Module Name: src Committed By: kre Date: Sun Oct 8 08:31:05 UTC 2017
Modified Files: src/tests/lib/libc/sys: t_msgget.c t_msgrcv.c t_msgsnd.c Log Message: Don't bother attempting any of the (real) test cases if the SYSVMSG option isn't configured in the kernel. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_msgget.c cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_msgrcv.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_msgsnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libc/sys/t_msgget.c diff -u src/tests/lib/libc/sys/t_msgget.c:1.2 src/tests/lib/libc/sys/t_msgget.c:1.3 --- src/tests/lib/libc/sys/t_msgget.c:1.2 Thu Feb 27 00:59:50 2014 +++ src/tests/lib/libc/sys/t_msgget.c Sun Oct 8 08:31:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_msgget.c,v 1.2 2014/02/27 00:59:50 joerg Exp $ */ +/* $NetBSD: t_msgget.c,v 1.3 2017/10/08 08:31:05 kre Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_msgget.c,v 1.2 2014/02/27 00:59:50 joerg Exp $"); +__RCSID("$NetBSD: t_msgget.c,v 1.3 2017/10/08 08:31:05 kre Exp $"); #include <sys/msg.h> #include <sys/stat.h> @@ -278,15 +278,55 @@ ATF_TC_CLEANUP(msgget_mode, tc) clean(); } +static volatile int sig_caught; + +static void +sigsys_handler(int signum) +{ + + sig_caught = signum; +} + +static int +no_kernel_sysvmsg(void) +{ + int id; + void (*osig)(int); + + sig_caught = 0; + osig = signal(SIGSYS, sigsys_handler); + id = msgget(MSG_KEY, IPC_CREAT | 0600); + if (sig_caught || id == -1) + return 1; + + (void)msgctl(id, IPC_RMID, 0); + (void)signal(SIGSYS, osig); + + return 0; +} + +ATF_TC(msgget_query); +ATF_TC_HEAD(msgget_query, tc) +{ + atf_tc_set_md_var(tc, "descr", "Skip msgget_* tests - no SYSVMSG"); +} +ATF_TC_BODY(msgget_query, tc) +{ + atf_tc_skip("No SYSVMSG in kernel"); +} ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, msgget_excl); - ATF_TP_ADD_TC(tp, msgget_exit); - ATF_TP_ADD_TC(tp, msgget_init); - ATF_TP_ADD_TC(tp, msgget_limit); - ATF_TP_ADD_TC(tp, msgget_mode); + if (no_kernel_sysvmsg()) { + ATF_TP_ADD_TC(tp, msgget_query); + } else { + ATF_TP_ADD_TC(tp, msgget_excl); + ATF_TP_ADD_TC(tp, msgget_exit); + ATF_TP_ADD_TC(tp, msgget_init); + ATF_TP_ADD_TC(tp, msgget_limit); + ATF_TP_ADD_TC(tp, msgget_mode); + } return atf_no_error(); } Index: src/tests/lib/libc/sys/t_msgrcv.c diff -u src/tests/lib/libc/sys/t_msgrcv.c:1.4 src/tests/lib/libc/sys/t_msgrcv.c:1.5 --- src/tests/lib/libc/sys/t_msgrcv.c:1.4 Fri Jan 13 20:44:45 2017 +++ src/tests/lib/libc/sys/t_msgrcv.c Sun Oct 8 08:31:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $ */ +/* $NetBSD: t_msgrcv.c,v 1.5 2017/10/08 08:31:05 kre Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $"); +__RCSID("$NetBSD: t_msgrcv.c,v 1.5 2017/10/08 08:31:05 kre Exp $"); #include <sys/msg.h> #include <sys/stat.h> @@ -329,15 +329,56 @@ ATF_TC_CLEANUP(msgrcv_truncate, tc) clean(); } +static volatile int sig_caught; + +static void +sigsys_handler(int signum) +{ + + sig_caught = signum; +} + +static int +no_kernel_sysvmsg(void) +{ + int id; + void (*osig)(int); + + sig_caught = 0; + osig = signal(SIGSYS, sigsys_handler); + id = msgget(MSG_KEY, IPC_CREAT | 0600); + if (sig_caught || id == -1) + return 1; + + (void)msgctl(id, IPC_RMID, 0); + (void)signal(SIGSYS, osig); + + return 0; +} + +ATF_TC(msgrcv_query); +ATF_TC_HEAD(msgrcv_query, tc) +{ + atf_tc_set_md_var(tc, "descr", "Skip msgrcv_* tests - no SYSVMSG"); +} +ATF_TC_BODY(msgrcv_query, tc) +{ + atf_tc_skip("No SYSVMSG in kernel"); +} + ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, msgrcv_basic); - ATF_TP_ADD_TC(tp, msgrcv_block); - ATF_TP_ADD_TC(tp, msgrcv_err); - ATF_TP_ADD_TC(tp, msgrcv_mtype); - ATF_TP_ADD_TC(tp, msgrcv_nonblock); - ATF_TP_ADD_TC(tp, msgrcv_truncate); + if (no_kernel_sysvmsg()) { + ATF_TP_ADD_TC(tp, msgrcv_query); + } else { + ATF_TP_ADD_TC(tp, msgrcv_basic); + ATF_TP_ADD_TC(tp, msgrcv_block); + ATF_TP_ADD_TC(tp, msgrcv_err); + ATF_TP_ADD_TC(tp, msgrcv_mtype); + ATF_TP_ADD_TC(tp, msgrcv_nonblock); + ATF_TP_ADD_TC(tp, msgrcv_truncate); + } return atf_no_error(); } Index: src/tests/lib/libc/sys/t_msgsnd.c diff -u src/tests/lib/libc/sys/t_msgsnd.c:1.3 src/tests/lib/libc/sys/t_msgsnd.c:1.4 --- src/tests/lib/libc/sys/t_msgsnd.c:1.3 Fri Jan 13 20:44:45 2017 +++ src/tests/lib/libc/sys/t_msgsnd.c Sun Oct 8 08:31:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $ */ +/* $NetBSD: t_msgsnd.c,v 1.4 2017/10/08 08:31:05 kre Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $"); +__RCSID("$NetBSD: t_msgsnd.c,v 1.4 2017/10/08 08:31:05 kre Exp $"); #include <sys/msg.h> #include <sys/stat.h> @@ -326,14 +326,55 @@ ATF_TC_CLEANUP(msgsnd_perm, tc) clean(); } +static volatile int sig_caught; + +static void +sigsys_handler(int signum) +{ + + sig_caught = signum; +} + +static int +no_kernel_sysvmsg(void) +{ + int id; + void (*osig)(int); + + sig_caught = 0; + osig = signal(SIGSYS, sigsys_handler); + id = msgget(MSG_KEY, IPC_CREAT | 0600); + if (sig_caught || id == -1) + return 1; + + (void)msgctl(id, IPC_RMID, 0); + (void)signal(SIGSYS, osig); + + return 0; +} + +ATF_TC(msgsnd_query); +ATF_TC_HEAD(msgsnd_query, tc) +{ + atf_tc_set_md_var(tc, "descr", "Skip msgsnd_* tests - no SYSVMSG"); +} +ATF_TC_BODY(msgsnd_query, tc) +{ + atf_tc_skip("No SYSVMSG in kernel"); +} + ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, msgsnd_block); - ATF_TP_ADD_TC(tp, msgsnd_count); - ATF_TP_ADD_TC(tp, msgsnd_err); - ATF_TP_ADD_TC(tp, msgsnd_nonblock); - ATF_TP_ADD_TC(tp, msgsnd_perm); + if (no_kernel_sysvmsg()) { + ATF_TP_ADD_TC(tp, msgsnd_query); + } else { + ATF_TP_ADD_TC(tp, msgsnd_block); + ATF_TP_ADD_TC(tp, msgsnd_count); + ATF_TP_ADD_TC(tp, msgsnd_err); + ATF_TP_ADD_TC(tp, msgsnd_nonblock); + ATF_TP_ADD_TC(tp, msgsnd_perm); + } return atf_no_error(); }