Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/bpf Add a test case for BIOCGBLEN and BIOCSBLEN
details: https://anonhg.NetBSD.org/src/rev/7b8e86e470c2
branches: trunk
changeset: 351059:7b8e86e470c2
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Feb 01 08:04:49 2017 +0000
description:
Add a test case for BIOCGBLEN and BIOCSBLEN
diffstat:
tests/net/bpf/t_bpf.c | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)
diffs (65 lines):
diff -r 7a89318483cb -r 7b8e86e470c2 tests/net/bpf/t_bpf.c
--- a/tests/net/bpf/t_bpf.c Wed Feb 01 07:50:03 2017 +0000
+++ b/tests/net/bpf/t_bpf.c Wed Feb 01 08:04:49 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $ */
+/* $NetBSD: t_bpf.c,v 1.7 2017/02/01 08:04:49 ozaki-r Exp $ */
/*-
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -25,7 +25,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_bpf.c,v 1.6 2017/01/13 21:30:42 christos Exp $");
+__RCSID("$NetBSD: t_bpf.c,v 1.7 2017/02/01 08:04:49 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -166,6 +166,39 @@
}
#endif /* #if (SIZE_MAX > UINT_MAX) */
+ATF_TC(bpf_ioctl_BLEN);
+ATF_TC_HEAD(bpf_ioctl_BLEN, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Checks behaviors of BIOCGBLEN and "
+ "BIOCSBLEN");
+}
+
+ATF_TC_BODY(bpf_ioctl_BLEN, tc)
+{
+ struct ifreq ifr;
+ int ifnum, bpfd;
+ u_int blen = 0;
+
+ RZ(rump_init());
+ RZ(rump_pub_shmif_create(NULL, &ifnum));
+ sprintf(ifr.ifr_name, "shmif%d", ifnum);
+
+ RL(bpfd = rump_sys_open("/dev/bpf", O_RDWR));
+
+ RL(rump_sys_ioctl(bpfd, BIOCGBLEN, &blen));
+ ATF_REQUIRE(blen != 0);
+ blen = 100;
+ RL(rump_sys_ioctl(bpfd, BIOCSBLEN, &blen));
+ RL(rump_sys_ioctl(bpfd, BIOCGBLEN, &blen));
+ ATF_REQUIRE_EQ(blen, 100);
+
+ RL(rump_sys_ioctl(bpfd, BIOCSETIF, &ifr));
+
+ ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(bpfd, BIOCSBLEN, &blen), -1,
+ "Don't allow to change buflen after binding bpf to an interface");
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -173,5 +206,6 @@
#if (SIZE_MAX > UINT_MAX)
ATF_TP_ADD_TC(tp, bpfwritetrunc);
#endif
+ ATF_TP_ADD_TC(tp, bpf_ioctl_BLEN);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index