1 #ifndef TEST_SOCKET_UNIX_COMMON_HPP_
2 #define TEST_SOCKET_UNIX_COMMON_HPP_
4 #include <posixx/socket/unix.hpp> // posixx::socket::unix
5 #include <boost/test/unit_test.hpp> // unit testing stuff
6 #include <ostream> // std::ostream
7 #include <unistd.h> // unlink
8 #include <sys/stat.h> // struct stat
10 #define PATH "/tmp/posixx_socket_unix_test"
11 #define PATH1 PATH "1"
12 #define PATH2 PATH "2"
15 std::ostream& operator << (std::ostream& os,
16 const posixx::socket::unix::sockaddr& sa) throw()
18 return os << "unix::sockaddr(family=" << sa.sun_family
19 << ", path=" << sa.sun_path << ")";
23 void clean_test_address(posixx::socket::unix::socket& socket,
24 const posixx::socket::unix::sockaddr& addr)
26 // remove the socket file, if exists
28 if (stat(addr.sun_path, &st) == 0)
29 BOOST_REQUIRE_EQUAL(unlink(addr.sun_path), 0);
32 static posixx::socket::unix::sockaddr test_address1(PATH1);
33 static posixx::socket::unix::sockaddr test_address2(PATH2);
35 #endif // TEST_SOCKET_UNIX_COMMON_HPP_