diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-27 11:12:04 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-27 11:13:14 +0000 |
commit | 7ee6b0f125a092ed99d327bb8d608dd2ff77b7aa (patch) | |
tree | af3e282698191292696752872efcc1e2ebb00638 /tests | |
parent | 656a39c1a062411dca09d1566a7a0709c30f3bc7 (diff) | |
download | src-7ee6b0f125a092ed99d327bb8d608dd2ff77b7aa.tar.gz src-7ee6b0f125a092ed99d327bb8d608dd2ff77b7aa.zip |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sys/netlink/test_snl_generic.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/sys/netlink/test_snl_generic.c b/tests/sys/netlink/test_snl_generic.c index c65d134f080d..f3c11daf19e1 100644 --- a/tests/sys/netlink/test_snl_generic.c +++ b/tests/sys/netlink/test_snl_generic.c @@ -66,11 +66,50 @@ ATF_TC_BODY(test_snl_get_genl_family_failure, tc) ATF_CHECK_EQ(snl_get_genl_family(&ss, "no-such-family"), 0); } +ATF_TC(test_snl_get_genl_family_groups); +ATF_TC_HEAD(test_snl_get_genl_family_groups, tc) +{ + atf_tc_set_md_var(tc, "descr", "Tests getting 'nlctrl' groups"); +} + +ATF_TC_BODY(test_snl_get_genl_family_groups, tc) +{ + struct snl_state ss; + struct snl_writer nw; + struct nlmsghdr *hdr; + + require_netlink(); + + if (!snl_init(&ss, NETLINK_GENERIC)) + atf_tc_fail("snl_init() failed"); + + snl_init_writer(&ss, &nw); + hdr = snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY); + snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, "nlctrl"); + snl_finalize_msg(&nw); + snl_send_message(&ss, hdr); + + hdr = snl_read_reply(&ss, hdr->nlmsg_seq); + ATF_CHECK(hdr != NULL); + ATF_CHECK(hdr->nlmsg_type != NLMSG_ERROR); + + struct _getfamily_attrs attrs = {}; + + ATF_CHECK(snl_parse_nlmsg(&ss, hdr, &_genl_ctrl_getfam_parser, &attrs)); + ATF_CHECK_EQ(attrs.mcast_groups.num_groups, 1); + + struct snl_genl_ctrl_mcast_group *group = attrs.mcast_groups.groups[0]; + + ATF_CHECK(group->mcast_grp_id > 0); + ATF_CHECK(!strcmp(group->mcast_grp_name, "notify")); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, snl_verify_genl_parsers); ATF_TP_ADD_TC(tp, test_snl_get_genl_family_success); ATF_TP_ADD_TC(tp, test_snl_get_genl_family_failure); + ATF_TP_ADD_TC(tp, test_snl_get_genl_family_groups); return (atf_no_error()); } |