blob: 07aaef79731846131e7b025ec91619be65d9143b [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
Brad Bishope9ac8b42016-12-19 09:30:40 -050023void runTests(MainLoop& loop)
24{
25 loop.shutdown();
26 std::cout << "Success!\n";
27}
28
29int 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 Bishop0aec3502017-01-16 22:41:26 -050037 MainLoop loop(
38 sdbusplus::bus::new_default(),
39 dir,
40 "xyz.openbmc_project.Testing", "/testing");
Brad Bishop96a315f2017-01-16 22:43:33 -050041
42 auto threadMain = [](auto loop)
43 {
44 loop->run();
45 };
46 auto t = std::thread(threadMain, &loop);
Brad Bishope9ac8b42016-12-19 09:30:40 -050047
48 runTests(loop);
49
50 // Wait for server thread to exit.
51 t.join();
52 unlink(entry.c_str());
53 rmdir(dir.c_str());
54
55 return 0;
56}
57
58// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4