1 // Copyright Leandro Lucarella 2008 - 2010.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file COPYING or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef TEST_SOCKET_UNIX_COMMON_HPP_
8 #define TEST_SOCKET_UNIX_COMMON_HPP_
10 #include <posixx/socket/unix.hpp> // posixx::socket::unix
11 #include <posixx/socket/unix/print.hpp> // address ostream formatting
12 #include <boost/test/unit_test.hpp> // unit testing stuff
13 #include <ostream> // std::ostream
14 #include <unistd.h> // unlink
15 #include <sys/stat.h> // struct stat
17 #define PATH "/tmp/posixx_socket_unix_test"
18 #define PATH1 PATH "1"
19 #define PATH2 PATH "2"
22 void clean_test_address(posixx::socket::unix::socket& socket,
23 const posixx::socket::unix::sockaddr& addr)
25 // remove the socket file, if exists
27 if (stat(addr.sun_path, &st) == 0)
28 BOOST_REQUIRE_EQUAL(unlink(addr.sun_path), 0);
31 static posixx::socket::unix::sockaddr test_address1(PATH1);
32 static posixx::socket::unix::sockaddr test_address2(PATH2);
34 #endif // TEST_SOCKET_UNIX_COMMON_HPP_