blob: df9ed22ebbd58053186617a6ffabd2bee506280b [file] [log] [blame]
Brad Bishope9ac8b42016-12-19 09:30:40 -05001/**
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
23auto server_thread(void* data)
24{
25 auto mgr = static_cast<MainLoop*>(data);
26
27 mgr->run();
28
29 return static_cast<void*>(nullptr);
30}
31
32void runTests(MainLoop& loop)
33{
34 loop.shutdown();
35 std::cout << "Success!\n";
36}
37
38int main()
39{
40 char tmpl[] = "/tmp/hwmon-test.XXXXXX";
41 std::string dir = mkdtemp(tmpl);
42 std::string entry = dir + "/temp1_input";
43 std::ofstream f{entry};
44 f << "1234";
45
Brad Bishopb9e2b072016-12-19 13:47:10 -050046 auto loop = MainLoop(
47 dir,
48 "xyz.openbmc_project.Testing", "/testing");
Brad Bishope9ac8b42016-12-19 09:30:40 -050049 auto t = std::thread(server_thread, &loop);
50
51 runTests(loop);
52
53 // Wait for server thread to exit.
54 t.join();
55 unlink(entry.c_str());
56 rmdir(dir.c_str());
57
58 return 0;
59}
60
61// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4