Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Davide Pesavento | 690272d | 2023-09-23 20:33:42 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2023, Regents of the University of California, |
| 4 | * The University of Memphis. |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 5 | * |
| 6 | * This file is part of PSync. |
| 7 | * |
| 8 | * PSync is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU Lesser General Public License as published by the Free Software Foundation, either |
| 10 | * version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public License along with |
| 17 | * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef PSYNC_TESTS_IO_FIXTURE_HPP |
| 21 | #define PSYNC_TESTS_IO_FIXTURE_HPP |
| 22 | |
| 23 | #include "tests/clock-fixture.hpp" |
| 24 | |
Davide Pesavento | 690272d | 2023-09-23 20:33:42 -0400 | [diff] [blame] | 25 | #include <boost/asio/io_context.hpp> |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 26 | |
Davide Pesavento | c45a4ea | 2022-09-19 02:10:53 -0400 | [diff] [blame] | 27 | namespace psync::tests { |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 28 | |
| 29 | class IoFixture : public ClockFixture |
| 30 | { |
| 31 | private: |
| 32 | void |
| 33 | afterTick() final |
| 34 | { |
| 35 | if (m_io.stopped()) { |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 36 | m_io.restart(); |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 37 | } |
| 38 | m_io.poll(); |
| 39 | } |
| 40 | |
| 41 | protected: |
Davide Pesavento | 690272d | 2023-09-23 20:33:42 -0400 | [diff] [blame] | 42 | boost::asio::io_context m_io; |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 43 | }; |
| 44 | |
Davide Pesavento | c45a4ea | 2022-09-19 02:10:53 -0400 | [diff] [blame] | 45 | } // namespace psync::tests |
Davide Pesavento | f91d1df | 2020-11-25 14:50:41 -0500 | [diff] [blame] | 46 | |
| 47 | #endif // PSYNC_TESTS_IO_FIXTURE_HPP |