Changeset View
Changeset View
Standalone View
Standalone View
lib/libcasper/services/cap_net/tests/net_test.c
/*- | /*- | ||||
* Copyright (c) 2020 Mariusz Zaborski <oshogbo@FreeBSD.org> | * Copyright (c) 2020 Mariusz Zaborski <oshogbo@FreeBSD.org> | ||||
* Copyright (c) 2020 Ryan Moeller <freqlabs@FreeBSD.org> | |||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
▲ Show 20 Lines • Show All 1,110 Lines • ▼ Show 20 Lines | for (i = 0; caphp->h_addr_list[i] != NULL; i++) { | ||||
ATF_REQUIRE(cap_connect(capnet, s, (struct sockaddr *)&connaddr, | ATF_REQUIRE(cap_connect(capnet, s, (struct sockaddr *)&connaddr, | ||||
sizeof(connaddr)) == 0); | sizeof(connaddr)) == 0); | ||||
close(s); | close(s); | ||||
} | } | ||||
cap_close(capnet); | cap_close(capnet); | ||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(capnet__getprotobyname); | |||||
ATF_TC_BODY(capnet__getprotobyname, tc) | |||||
{ | |||||
cap_channel_t *capnet; | |||||
struct protoent *pp; | |||||
size_t n = 0; | |||||
capnet = create_network_service(); | |||||
pp = cap_getprotobyname(capnet, "tcp"); | |||||
ATF_REQUIRE(pp != NULL); | |||||
ATF_REQUIRE(pp->p_name != NULL); | |||||
ATF_REQUIRE(pp->p_aliases != NULL); | |||||
while (pp->p_aliases[n] != NULL) | |||||
++n; | |||||
ATF_REQUIRE(n > 0); | |||||
ATF_REQUIRE(pp->p_proto != 0); | |||||
cap_close(capnet); | |||||
} | |||||
ATF_TP_ADD_TCS(tp) | ATF_TP_ADD_TCS(tp) | ||||
{ | { | ||||
ATF_TP_ADD_TC(tp, capnet__limits_addr2name_mode); | ATF_TP_ADD_TC(tp, capnet__limits_addr2name_mode); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_addr2name_family); | ATF_TP_ADD_TC(tp, capnet__limits_addr2name_family); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_addr2name); | ATF_TP_ADD_TC(tp, capnet__limits_addr2name); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_deprecated_addr2name_mode); | ATF_TP_ADD_TC(tp, capnet__limits_deprecated_addr2name_mode); | ||||
Show All 13 Lines | ATF_TP_ADD_TCS(tp) | ||||
ATF_TP_ADD_TC(tp, capnet__limits_bind_mode); | ATF_TP_ADD_TC(tp, capnet__limits_bind_mode); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_bind); | ATF_TP_ADD_TC(tp, capnet__limits_bind); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_connect_mode); | ATF_TP_ADD_TC(tp, capnet__limits_connect_mode); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_connect); | ATF_TP_ADD_TC(tp, capnet__limits_connect); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_connecttodns); | ATF_TP_ADD_TC(tp, capnet__limits_connecttodns); | ||||
ATF_TP_ADD_TC(tp, capnet__limits_deprecated_connecttodns); | ATF_TP_ADD_TC(tp, capnet__limits_deprecated_connecttodns); | ||||
ATF_TP_ADD_TC(tp, capnet__getprotobyname); | |||||
return (atf_no_error()); | return (atf_no_error()); | ||||
} | } |