socket_path_ = string(TEST_DATA_BUILDDIR) + "/kea4.sock";
}
reset();
-
- // This is a workaround for odd problems with gtest. gtest does
- // shady with socket decriptors. In particular, sometimes we
- // get 0 as descriptor for socket() call. Technically it is valid,
- // but then gtest closes descriptor 0 and the socket becomes
- // unusable. This workaround opens up one file decriptor. In case
- // 0 is available, it will be consumed here.
- dummy_fd_ = socket(AF_INET, SOCK_DGRAM, 0);
- if (dummy_fd_ == 0) {
- std::cout << "Socket descriptor 0 workaround is useful." << std::endl;
- }
}
/// @brief Destructor
~CtrlChannelDhcpv4SrvTest() {
server_.reset();
reset();
-
- // close dummy descriptor
- close(dummy_fd_);
};
void createUnixChannelServer() {
client->disconnectFromServer();
ASSERT_NO_THROW(server_->receivePacket(0));
}
-
- /// @brief dummy file descriptor
- ///
- /// See ctor for details.
- int dummy_fd_;
};
TEST_F(CtrlChannelDhcpv4SrvTest, commands) {
// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
#include <dhcp/tests/pkt_filter_test_stub.h>
PktFilterTestStub::openSocket(Iface&,
const isc::asiolink::IOAddress& addr,
const uint16_t port, const bool, const bool) {
- return (SocketInfo(addr, port, 0));
+ int fd = open("/dev/null", O_RDONLY);
+ if (fd < 0) {
+ const char* errmsg = strerror(errno);
+ isc_throw(Unexpected,
+ "PktFilterTestStub: cannot open /dev/null:" << errmsg);
+ }
+
+ return (SocketInfo(addr, port, fd));
}
Pkt4Ptr