Brad Bishop | e9ac8b4 | 2016-12-19 09:30:40 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2016 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include "../mainloop.hpp" |
| 17 | #include <iostream> |
| 18 | #include <fstream> |
| 19 | #include <cstdio> |
| 20 | #include <unistd.h> |
| 21 | #include <thread> |
| 22 | |
Brad Bishop | e9ac8b4 | 2016-12-19 09:30:40 -0500 | [diff] [blame] | 23 | void runTests(MainLoop& loop) |
| 24 | { |
| 25 | loop.shutdown(); |
| 26 | std::cout << "Success!\n"; |
| 27 | } |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | char tmpl[] = "/tmp/hwmon-test.XXXXXX"; |
| 32 | std::string dir = mkdtemp(tmpl); |
| 33 | std::string entry = dir + "/temp1_input"; |
| 34 | std::ofstream f{entry}; |
| 35 | f << "1234"; |
| 36 | |
Brad Bishop | 0aec350 | 2017-01-16 22:41:26 -0500 | [diff] [blame] | 37 | MainLoop loop( |
| 38 | sdbusplus::bus::new_default(), |
| 39 | dir, |
Brad Bishop | f3aa9ae | 2017-08-25 09:56:02 -0400 | [diff] [blame] | 40 | dir, |
Brad Bishop | 0aec350 | 2017-01-16 22:41:26 -0500 | [diff] [blame] | 41 | "xyz.openbmc_project.Testing", "/testing"); |
Brad Bishop | 96a315f | 2017-01-16 22:43:33 -0500 | [diff] [blame] | 42 | |
| 43 | auto threadMain = [](auto loop) |
| 44 | { |
| 45 | loop->run(); |
| 46 | }; |
| 47 | auto t = std::thread(threadMain, &loop); |
Brad Bishop | e9ac8b4 | 2016-12-19 09:30:40 -0500 | [diff] [blame] | 48 | |
| 49 | runTests(loop); |
| 50 | |
| 51 | // Wait for server thread to exit. |
| 52 | t.join(); |
| 53 | unlink(entry.c_str()); |
| 54 | rmdir(dir.c_str()); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |