blob: 90a07c01c2acdda637589d788b085e75f02c6fea [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,
Brad Bishopf3aa9ae2017-08-25 09:56:02 -040040 dir,
Brad Bishop0aec3502017-01-16 22:41:26 -050041 "xyz.openbmc_project.Testing", "/testing");
Brad Bishop96a315f2017-01-16 22:43:33 -050042
43 auto threadMain = [](auto loop)
44 {
45 loop->run();
46 };
47 auto t = std::thread(threadMain, &loop);
Brad Bishope9ac8b42016-12-19 09:30:40 -050048
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