xref: /openbmc/sdbusplus/test/async/fdio_timed/suite.hpp (revision 2cd25e64299ecc20e2258727e836a31b7ce6fad3)
1 #pragma once
2 
3 #include <unistd.h>
4 
5 #include <sdbusplus/async.hpp>
6 
7 #include <filesystem>
8 
9 #include <gtest/gtest.h>
10 
11 using namespace std::literals;
12 
13 namespace fs = std::filesystem;
14 
15 class FdioTimedTest : public ::testing::Test
16 {
17   protected:
18     enum class testWriteOperation
19     {
20         writeSync,
21         writeAsync,
22         writeSkip
23     };
24 
25     fs::path path;
26 
27     FdioTimedTest();
28 
29     ~FdioTimedTest() noexcept override;
30 
31     auto writeToFile() -> sdbusplus::async::task<>;
32 
33     auto testFdTimedEvents(bool& ran, testWriteOperation writeOperation,
34                            int testIterations) -> sdbusplus::async::task<>;
35 
36     std::unique_ptr<sdbusplus::async::fdio> fdioInstance;
37     std::optional<sdbusplus::async::context> ctx{std::in_place};
38 
39   private:
40     int fd = -1;
41     int wd = -1;
42 };
43