~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to tests/mir_test_framework/cross_process_sync.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-10-10 14:01:26 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20141010140126-n1czko8na1kuz4ll
Tags: upstream-0.8.0+14.10.20141010
ImportĀ upstreamĀ versionĀ 0.8.0+14.10.20141010

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "mir_test_framework/cross_process_sync.h"
20
20
 
21
 
#include <boost/exception/errinfo_errno.hpp>
22
 
 
 
21
#include <boost/exception/info.hpp>
 
22
#include <system_error>
23
23
#include <poll.h>
24
24
#include <unistd.h>
25
25
 
38
38
{
39
39
    if (::pipe(fds) < 0)
40
40
    {
41
 
        BOOST_THROW_EXCEPTION(
42
 
            ::boost::enable_error_info(std::runtime_error("Failed to create pipe"))
43
 
            << boost::errinfo_errno(errno));
 
41
        BOOST_THROW_EXCEPTION(std::system_error(errno,
 
42
                                                std::system_category(),
 
43
                                                "Failed to create pipe"));
44
44
    }
45
45
}
46
46
 
81
81
 
82
82
    if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
83
83
    {
84
 
        BOOST_THROW_EXCEPTION(
85
 
            ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become writable"))
86
 
            << boost::errinfo_errno(errno));
 
84
        BOOST_THROW_EXCEPTION(std::system_error(errno,
 
85
                                                std::system_category(),
 
86
                                                "Error while polling pipe to become writable"));
87
87
    }
88
88
    else if (rc == 0)
89
89
    {
93
93
    int value = 1;
94
94
    if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value)))
95
95
    {
96
 
        BOOST_THROW_EXCEPTION(
97
 
            ::boost::enable_error_info(std::runtime_error("Error while writing to pipe"))
98
 
            << boost::errinfo_errno(errno));
 
96
        BOOST_THROW_EXCEPTION(std::system_error(errno,
 
97
                                                std::system_category(),
 
98
                                                "Error while writing to pipe"));
99
99
    }
100
100
}
101
101
 
112
112
 
113
113
    if ((rc = ::poll(poll_fd, 1, duration.count())) < 0)
114
114
    {
115
 
        BOOST_THROW_EXCEPTION(
116
 
            ::boost::enable_error_info(std::runtime_error("Error while polling pipe to become readable"))
117
 
            << boost::errinfo_errno(errno));
 
115
        BOOST_THROW_EXCEPTION(std::system_error(errno,
 
116
                                                std::system_category(),
 
117
                                                "Error while polling pipe to become readable"));
118
118
    }
119
119
    else if (rc == 0)
120
120
    {
124
124
    int value;
125
125
    if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value)))
126
126
    {
127
 
        BOOST_THROW_EXCEPTION(
128
 
            ::boost::enable_error_info(std::runtime_error("Error while reading from pipe"))
129
 
            << boost::errinfo_errno(errno));
 
127
        BOOST_THROW_EXCEPTION(std::system_error(errno,
 
128
                                                std::system_category(),
 
129
                                                "Error while reading from pipe"));
130
130
    }
131
131
 
132
132
    if (value != 1)