summaryrefslogtreecommitdiff
path: root/unittest/gtest_hal_cpu.cpp
blob: e1541fa350c907f187aac95ea97818183a6f773c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

#include <iostream>
#include <gtest/gtest.h>
#include "hw/cpu.h"

using namespace std;

/*
 * main class
 */

#define LOWBATTERY "LowBattery"

struct hw_info *info;
struct cpu_device *cpu_dev;

class CPUHalTest : public testing::Test
{
	public:
		virtual void SetUp()
		{

		}

		virtual void TearDown()
		{

		}
};

/*
 * testcase
 */
TEST_F(CPUHalTest, InitP)
{
	int ret;

	ret = hw_get_info(CPU_HARDWARE_DEVICE_ID,
			(const struct hw_info **)&info);
	if (ret < 0) {
		cout << "There is no device for cpu " << ret << endl;
		return;
	} else {
		EXPECT_EQ(ret, 0) << "Fail to load cpu hal (" << ret << ")";
	}
	if (!info || !info->open) {
		cout << "There is no function for info open" << endl;
		return;
	}
	ret = info->open(info, NULL, (struct hw_common**)&cpu_dev);
	EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")";
}

TEST_F(CPUHalTest, StartBoostP)
{
	int ret;

	if (!cpu_dev || !cpu_dev->start_boost) {
		cout << "There is no function for start_boost" << endl;
		return;
	}

	// prprpr TODO
	ret = cpu_dev->start_boost((void *)LOWBATTERY);
	EXPECT_EQ(ret, 0) << "Fail to start_boost (" << ret << ")";
}

TEST_F(CPUHalTest, StopBoostP)
{
	int ret;

	if (!cpu_dev || !cpu_dev->stop_boost) {
		cout << "There is no function for stop_boost" << endl;
		return;
	}

	// prprpr TODO
	ret = cpu_dev->stop_boost((void *)LOWBATTERY);
	EXPECT_EQ(ret, 0) << "Fail to stop_boost (" << ret << ")";
}

TEST_F(CPUHalTest, DeinitP)
{
	int ret;

	if (!info || !info->close) {
		cout << "There is no function for info close" << endl;
		return;
	}

	ret = info->close((struct hw_common *)cpu_dev);
	EXPECT_EQ(ret, 0) << "Fail to open cpu device (" << ret << ")";
}

int main(int argc, char **argv)
{
	testing::InitGoogleTest(&argc, argv);

	return RUN_ALL_TESTS();
}