summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/common/src/test_mocks.c
blob: ab6c65313d7f463d9cbd37809b65fd62c08b7ef4 (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
/* Copyright 2021 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <zephyr/ztest.h>

#include "test/drivers/test_mocks.h"

/* Mocks for common/init_rom.c */
DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int);
DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int);
DEFINE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int);

/* Mocks for common/system.c */
DEFINE_FAKE_VALUE_FUNC(int, system_jumped_late);
DEFINE_FAKE_VALUE_FUNC(int, system_is_locked);
DEFINE_FAKE_VOID_FUNC(system_reset, int);
DEFINE_FAKE_VOID_FUNC(software_panic, uint32_t, uint32_t);
DEFINE_FAKE_VOID_FUNC(assert_post_action, const char *, unsigned int);

/* Mocks for common/lid_angle.c */
DEFINE_FAKE_VOID_FUNC(lid_angle_peripheral_enable, int);

/**
 * @brief Reset all the fakes before each test.
 */
static void fff_reset_rule_before(const struct ztest_unit_test *test,
				  void *data)
{
	ARG_UNUSED(test);
	ARG_UNUSED(data);

	RESET_FAKE(init_rom_map);
	RESET_FAKE(init_rom_unmap);
	RESET_FAKE(init_rom_copy);
	RESET_FAKE(system_jumped_late);
	RESET_FAKE(system_is_locked);
	RESET_FAKE(system_reset);
	RESET_FAKE(software_panic);
	RESET_FAKE(assert_post_action);
	RESET_FAKE(lid_angle_peripheral_enable);
}

ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL);