Module Name:    src
Committed By:   ozaki-r
Date:           Wed Feb  1 08:04:49 UTC 2017

Modified Files:
        src/tests/net/bpf: t_bpf.c

Log Message:
Add a test case for BIOCGBLEN and BIOCSBLEN


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/net/bpf/t_bpf.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/net/bpf/t_bpf.c
diff -u src/tests/net/bpf/t_bpf.c:1.6 src/tests/net/bpf/t_bpf.c:1.7
--- src/tests/net/bpf/t_bpf.c:1.6	Fri Jan 13 21:30:42 2017
+++ src/tests/net/bpf/t_bpf.c	Wed Feb  1 08:04:49 2017
@@ -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 @@ ATF_TC_BODY(bpfwritetrunc, tc)
 }
 #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 @@ ATF_TP_ADD_TCS(tp)
 #if (SIZE_MAX > UINT_MAX)
 	ATF_TP_ADD_TC(tp, bpfwritetrunc);
 #endif
+	ATF_TP_ADD_TC(tp, bpf_ioctl_BLEN);
 	return atf_no_error();
 }

Reply via email to