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
|
/* Copyright 2023 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Basic test of ScopedFastCpu.
*/
#include "common.h"
extern "C" {
#include "console.h"
#include "test_util.h"
}
#include "mock/clock_mock.h"
#include "scoped_fast_cpu.h"
test_static int fast_cpu_disable_at_start()
{
{
TEST_EQ(get_mock_fast_cpu_status(), 0, "%d");
{
/* instantiate, which calls constructor. */
ScopedFastCpu cpu;
TEST_EQ(get_mock_fast_cpu_status(), 1, "%d");
/* destructed here. */
}
TEST_EQ(get_mock_fast_cpu_status(), 0, "%d");
}
return EC_SUCCESS;
}
test_static int fast_cpu_enable_at_start()
{
{
ScopedFastCpu cpu;
TEST_EQ(get_mock_fast_cpu_status(), 1, "%d");
{
/* instantiate, which calls constructor. */
ScopedFastCpu cpu;
TEST_EQ(get_mock_fast_cpu_status(), 1, "%d");
/* destructed here. */
}
TEST_EQ(get_mock_fast_cpu_status(), 1, "%d");
}
return EC_SUCCESS;
}
extern "C" void run_test(int argc, const char **argv)
{
test_reset();
RUN_TEST(fast_cpu_disable_at_start);
RUN_TEST(fast_cpu_enable_at_start);
test_print_result();
}
|