Add a test case for BIOCGBLEN and BIOCSBLEN
This commit is contained in:
parent
61f323b2dc
commit
b1bee1e6b4
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue